• Resolved Yekusiel Eckstein

    (@yekusiel)


    I am using WooCommerce blocks for the first time. I am using it for both my cart and checkout pages.

    I was having an issue, where if I modified a product’s quantity from within the cart page, the product price and shipping price would indeed be reflected in the cart totals. However when I clicked proceed to checkout, it would still show the original quantity and original product/shipping pricing. It would not update unless I either manually refreshed the checkout page, or otherwise interacted with the checkout page in a way that triggered a cart refresh (such as adding my shipping address, which would trigger a shipping price calculation).

    In case anyone else is experiencing this issue, I was able to fix it with the following functions.

    Javascript:

    jQuery(document).ready(function($) {
    const { extensionCartUpdate } = wc.blocksCheckout;

    function triggerServerSideUpdate() {
        extensionCartUpdate({
            namespace: 'auto-refresh-checkout',
            data: {
            },
        });
    }
    
    $('body').on('init_checkout', triggerServerSideUpdate);

    });

    PHP:

    add_action(‘woocommerce_blocks_loaded’, function() {
    woocommerce_store_api_register_update_callback(
    [
    ‘namespace’ => ‘auto-refresh-checkout’,
    ‘callback’ => function($data) {
    }
    ]
    );
    });

    The strange part is that my callback function is empty, which means in reality it does nothing. It seems that all that is needed is to somehow trigger a server action when the checkout page initially loads, in order for it to refresh the order totals.

    I don’t know if this is a WooCommerce issue, or something to do with my own setup, but if it’s a bug, I hope it gets fixed because it is rather troublesome.

    Anyhow, I hope this helps somebody.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Zubair Zahid (woo-hc)

    (@doublezed2)

    Hello Yekusiel Eckstein,

    Thank you for contacting WooCommerce support with your query about using WooCommerce blocks on your cart and checkout pages.

    I understand that you are experiencing an issue where modifying a product’s quantity within the cart page updates the cart totals correctly but does not reflect these changes on the checkout page unless the page is refreshed or another action triggers a cart refresh.

    Considering that refreshing the page seems to resolve the discrepancy, this issue may be related to caching. Caching may prevent the updated information from immediately being displayed on the checkout page.

    To further investigate and assist you with this issue, could you please provide me with a copy of your site’s System Status Report? This will help me understand your site’s environment and settings. You can acquire this report by going to WooCommerce > Status in your WP Admin. Then click ‘Get system report’ followed by ‘Copy for support’.

    Once you have copied the report, kindly paste it into a Gist at https://gist.github.com. After saving the Gist, please share the Gist link with me here.

    I’m looking forward to your response. 🙂

    Best regards.

    Thread Starter Yekusiel Eckstein

    (@yekusiel)

    Hi Zubair, thanks for replying.

    I suppose caching could play a role, but does it really make sense that one page reload would get the latest cart details? I would think a cache would be more aggressive than that. Also, I tried it while logged in, and usually pages aren’t cached for logged in users.

    Also, did you see the code solution I shared above that fixed it? If caching was the problem, would that code make a difference?

    In any case, here is the information you requested:
    https://gist.github.com/Yekusiel/e51eeeefe67b8541db9c7f9d39b06c47

    Plugin Support Zubair Zahid (woo-hc)

    (@doublezed2)

    Hello Yekusiel Eckstein.

    Thank you for your reply and for sharing the system status report.

    First of all, I must mention that I appreciate your proactive approach in both bringing this issue to our attention and in offering a solution to the community. It’s invaluable when users collaborate and share knowledge like this.

    You’re quite right. Properly configured caching should indeed be set to deliberately exclude certain dynamic pages like the Cart and Checkout from being cached, ensuring that they always reflect the most up-to-date information.

    I also see from the system status report (SSR) that you have currently deactivated the WP Rocket plugin. If you’re still encountering the same issue with your custom code removed, it does point towards a possible malfunction elsewhere, as opposed to a classic caching conflict.

    When attempting to replicate the issue on my test site, I wasn’t able to reproduce the same behavior, which leads me to believe that there is something unique at play in your environment.

    To further diagnose the problem, it would be immensely helpful if you could set up a Staging site where the custom code can be removed. This would allow us to troubleshoot properly.

    Thank you once again for your cooperation. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Quantity changes not reflected on block checkout page’ is closed to new replies.