I am rendering WooCommerce Cart items in a custom html table wrapper by a form that points to a custom PHP file.

<form class="woocommerce-cart-form" action="/update-cart.php" method="POST">
    <input type="submit" name="update_cart" value="Update cart">

When I click on update cart, I get redirected via POST to update-cart.php where I do some business related actions with the PHP $_REQUEST.

After doing those actions, I want to call to the WooCommerce original update action, but I am stucked.

This is what I have tried:

// Non of this has worked for me

do_action('woocommerce_update_cart_action_cart_updated'); // 1

WC()->cart->persistent_cart_update(); // 2

do_action('update_cart_action'); // 3

How should I call WooCommerce's update action?

Thank you.

  • 1
    What exactly are you trying to update in the cart? The update_cart form handler is WC_Form_Handler::update_cart_action(); you could read that and see how it does whatever you want to do.
    – Rup
    Feb 12, 2021 at 15:07
  • I cannot instantiate WC_Form_Handler class, I am getting a 'class not found'. How can I get a WooCommerce class instance?
    – rogervila
    Feb 12, 2021 at 16:15
  • 1
    I don't think you should be, unless you want to process updates from a posted form? And it's a static method anyway: I'd guess you'll have to require_once wp-content/plugins/woocommerce/includes/class-wp-form-handler.php if it really isn't found, and then you can call WC_Form_Handler::update_cart_action() statically.
    – Rup
    Feb 12, 2021 at 16:36
  • 1
    Actually looking at class-woocommerce.php, WC_Form_Handler is loaded automatically for all frontend requests, so you shouldn't have to load it yourself. But if you really do have to, try include_once WC_ABSPATH . 'includes/class-wc-form-handler.php';
    – Rup
    Feb 12, 2021 at 16:52
  • You are right, the class is already loaded. If you answer the question I will mark it as the solution. Thank you very much.
    – rogervila
    Feb 12, 2021 at 17:17

1 Answer 1


The default form handler is a static method which you can call with


Your Answer

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

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