Support » Plugin: WooCommerce » WooCommerce with WooTheme Ajax Fragments Conflict

  • I’ve been making a custom cart widget for WooCommerce – it’s working perfectly with non woothemes but with woothemes, if they have their own cart hard coded in to the theme, then my widget stops automatically updating with ajax.

    The code that woocommerce uses to update by ajax in their themes is:

    add_filter('add_to_cart_fragments', 'woocommerce_cart_link');
    function woocommerce_cart_link() {
        global $woocommerce;
        <a href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> <?php _e('in your shopping cart', 'woothemes'); ?>" class="cart-button ">
        <span class="label"><?php _e('My Basket:', 'woothemes'); ?></span>
        <?php echo $woocommerce->cart->get_cart_total();  ?>
        <span class="items"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count); ?></span>
        $fragments['a.cart-button'] = ob_get_clean();
        return $fragments;

    I am using similar code in my custom cart in two places, for updating things – even though I use the code twice, it works fine, but when the code is used in a wootheme, the ajax stops working – I’m assuming it’s some kind of conflict, but my functions are named differently so I can’t see where a conflict may be.

    Any help is much appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • I am having a similar issue. I’m using the exact same code you show above. But here’s the way it breaks for me: It only works if I’m logged in. If I visit the site as a guest (aka not logged in) the AJAX features don’t work. In other words, if you click “Add to Cart” the cart totals don’t update until the page is refreshed.

    (p.s. also, and worse yet, the checkout page displays an inline frame of the site’s front page instead of the cart totals if I’m not logged in – an issue for another thread I suppose)

    lets have a look at your other code too?

    try removing the WT filter and see if that makes a difference…

    just remove this lien

    ‘add_filter(‘add_to_cart_fragments’, ‘woocommerce_cart_link’);’

    I removed all the custom functions that I put into functions.php – still happens.

    Something interesting is that when I have Jetpack installed, the checkout page (after about 3 seconds) goes blank and all that is left is the smiley face in the upper left corner – which is jetpack’s analytics image.

    Here’s everything I’ve tried so far, and none of it works:

    1. turn off ajax (add to cart) in woocommerce
    2. disable groups plugin
    3. turn off guest checkout so users have to log in to buy
    4. Remove custom functions in functions.php
    5. deactivate woocommerce and reactivate
    6. Clear transient data (woocommerce > settings)
    7. Remove ecommerce event tracking code (woocommerce > settings > integration)
    8. Uninstall woocommerce (delete plugin files) and reinstall from a fresh download

    None of this worked. I tried loggin in as a “subscriber” and it still breaks. The only time it all works is when an ADMIN is logged in. I’m stuck at this point.

    I found out the problem!

    The culprit was a plugin called “under construction.” I use it on live sites but not on my local server. Which is why the site breaks as soon as I move it to the public server.

    The “under construction” plugin, when activated causes the AJAX in the checkout to break. I verified this over and over again by activating the plugin, testing, then deactivating and testing again.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WooCommerce with WooTheme Ajax Fragments Conflict’ is closed to new replies.