user1049961 user1049961 - 1 year ago 82
PHP Question

update_order_review( ) on button click

I have a custom button on my checkout page, on click I'm adding a product to cart via AJAX.


$('#add_domain_product').on('click', function() {
url: Ajax.ajaxurl,
type: "POST",
data: {
action: 'add_domain_product',
success: function (data, status, xhr) {
// update command is executed.



add_action('wp_ajax_add_domain_product', 'bs_add_domain_product');
function bs_add_domain_product() {
global $woocommerce;

After that, I'd need to refresh the order review, so it displays my newly added product also. How can I do that?

Answer Source

All you need to do is call a trigger on the body to update the cart.

$( 'body' ).trigger( 'update_checkout' );

This will automatically call all the subsequent AJAX calls needed to refresh the cart information, including the order review.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download