Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save encoderit-arman/99dcaea394f3df3f88334fc82666b626 to your computer and use it in GitHub Desktop.
Save encoderit-arman/99dcaea394f3df3f88334fc82666b626 to your computer and use it in GitHub Desktop.
How to Refresh Checkout Page WooCommerce
jQuer -
jQuery('body').trigger('update_checkout');
/* to update info on your checkout page, you need to trigger the update_checkout function
so add this in your javascript file for your theme or plugin
*/
/* what this does is update the order review table but what it doesn't do is update shipping costs;
the calculate_shipping function of your shipping class will not be called again;
so if you were like me and you made a shipping method plugin, and you had to change costs based on the payment method, then
this is the only way to ensure it does just that
*/
php -
<?php
# add this in your plugin file, and that's it, the calculate_shipping method of your shipping plugin class will be called again
function action_woocommerce_checkout_update_order_review($array, $int)
{
WC()->cart->calculate_shipping();
return;
}
add_action('woocommerce_checkout_update_order_review', 'action_woocommerce_checkout_update_order_review', 10, 2);
?>
credit - https://njengah.com/woocommerce-refresh-checkout-page/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment