• Hello,
    I have a question: how can I force to reload whole cart page after every time when cart update button is clicked? I have a small function in functions.php :
    add_action( ‘woocommerce_before_cart’, ‘message’ )
    and I need to reload it every time when the cart is updated.

    Regards

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • You should try woocommerce_update_cart_action_cart_updated action hook.Try this:

    add_action( 'woocommerce_update_cart_action_cart_updated', 'on_action_cart_updated', 20, 1 );
    function on_action_cart_updated( $cart_updated ){
    
    // here you can write code to reload page
    
    }

    Code goes in function.php file of your active child theme (or active theme).

    • This reply was modified 3 years, 9 months ago by Ahir Hemant.
    Thread Starter swardasz

    (@swardasz)

    Thank you Ahir – I’ve try your code and insert in the function body the following code:

    header(“Refresh:0”);

    but this doesn’t work.

    When I change the product quantity in the cart and then press the button “Update cart” the cart page doesn’t be reloaded.

    Thread Starter swardasz

    (@swardasz)

    To explain it more exactly:
    1. in functions.php I have a function message_before_cart() that is executed also in functions.php by:
    add_action( ‘woocommerce_before_cart’, ‘message_before_cart’ );

    2. But this function “message_before_cart” are executed only once when the cart page is loaded
    3. I need to reload the message_before_cart (so the cart page) every time when the user change the product quiantity and press the Cart update button
    4. I added to functions.php the following code:
    add_action( ‘woocommerce_update_cart_action_cart_updated’, ‘on_action_cart_updated’, 20, 1 );
    function on_action_cart_updated( $cart_updated ){
    header(“Refresh:0”);
    }
    but it doesn’t work – the cart page don’t be reloaded after cart update
    5. I even added to functions.php the following code:
    add_action( ‘woocommerce_update_cart_action_cart_updated’, ‘on_action_cart_updated’, 20, 1 );
    function on_action_cart_updated( $cart_updated ){
    header(“Refresh:0”);
    add_action( ‘woocommerce_before_cart’, ‘message_before_cart’ );
    } but it also doesn’t reload the message (and page).
    Is there any other option to do reload the cart?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to force reloading whole cart page’ is closed to new replies.