0

I'm loading a WooCommerce shortcode via ajax which fires and works correctly. However, WooCommerce plugins don't appear to load or be initialised after the ajax call. If I run this shortcode on page load then the plugins do initialise and I get the functionality I expect.

Is there something I'm missing in my ajax call?

jQuery.ajax({
    type:"POST",
    url: '../../wp-admin/admin-ajax.php',
    data: {
        action: "selectProduceSize",
        productID: productID
    },
    success:function(data){
        $('.wooBoxSummary').html(data); 
    },
    error: function(errorThrown){
        alert(errorThrown);
    }   
});

function

function selectProductSize() {
  $productID = $_POST['productID'];
  echo do_shortcode('[product_page id="'.$productID.'"]');
  die();
}
add_action('wp_ajax_selectBoxSize', 'selectBoxSize');
add_action('wp_ajax_nopriv_selectBoxSize', 'selectBoxSize');
  • Your question should be updated to include the shortest code necessary to reproduce the issue you have. Actually your code is not testable as it's incomplete. – LoicTheAztec Mar 19 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.