I'm doing a Progress Bar Shopping Experience (in my WooCommerce site). First the user select the plan (demo, home, business, premium), then select the products he wants, and finally I've to show them the cart table. I use the following code to send the items using AJAX (In the same template):

      global $woocommerce;
      $woocommerce->cart->add_to_cart( 2932, 30 );

      echo do_shortcode('[woocommerce_cart]');
<?php get_header(); ?>  
<script type="text/javascript">
  var serializedOrderForm ='action=update_cart_order';                       

              type: 'POST',
              data: serializedOrderForm
          .fail(function( jqXHR, textStatus, errorThrown ) {
              jQuery("#p1content3").html("<div class='alert'>Ha Ocurrido un Error al Procesar la Orden</div>");

<div id="p1content3"></div>
<?php echo do_shortcode('[woocommerce_cart]');?>

<?php get_footer(); ?>
<?php get_sidebar(); ?>

My problem is that the table (the first one) that return the AJAX is WITHOUT the price discounts of the plugin "woocommerce dynamic pricing discounts".

But if inside any template i use:

  <? echo do_shortcode('[woocommerce_cart]'); ?>

Its return the table (second table) WITH the price discounts...

You can see the example here: http://cl.galyleo.net/prueba-carro/ of the code with the 2 cases.

Any ideas?

  • I admit I do not have any WooCommerce experience, but that said, why are you doing a die() at the end of your function? I'd imagine that'd kill everything that runs AFTER your function is called & completed...? Just a thought.
    – Pat
    Commented Aug 19, 2014 at 16:13
  • That is because is an ajax call Commented Aug 19, 2014 at 17:17
  • I change my example to a simplier one, as you can see the die() is for the ajax call, checkout the example page for better understanding Commented Aug 19, 2014 at 17:32
  • 1
    You need to put the die() inside a function that is called by the ajax request. Search this site for an ajax example and then go from there. Here's one of my answers on it: wordpress.stackexchange.com/questions/96795/… Commented Aug 19, 2014 at 17:43
  • Mmm I doubt that the die() has the fault here... As you could see in my example page, my code works... and i tried using the WP AJAX API but the same happen... so as you can see my problem is with the output of the do_shortcode (check the page) because directly in template i get the result i want (with de plugin) but if i do it with an ajax call the plugin dont work (any of the filter and actions of the plugins arent executed) Commented Aug 19, 2014 at 18:15

1 Answer 1


All AJAX calls in WordPress run through admin. So if you wrap something inside

if ( ! is_admin() )
    // stuff

then the AJAX call would not be able to know about this part. In other words, it does not get executed. I don't know what this plugin specifically does, but if only one part does not get executed, there's a high chance that this is the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.