So, i trigger update_checkout
via javascript. Then, i have function to be called in woocommerce_review_order_before_shipping
hook. The function is to add/remove free_shipping
shipping method (it’s based on Cash on Delivery availability).
There are two radio buttons of payment method:
- Direct Transfer
- Cash on Delivery
The script already works. So when i choose COD (Cash on Delivery), the free shipping method is selected automatically.
But, the problem is the total price did not changed, this indicates that the cost is still available. Well, it changed, but it is late. I said late because the total price is canged when i change the payment method by choosing Direct Bank Transfer radio button.
The question is,
- why the total price doesn’t update realtime when the payment method is changed? Ok, it changed but in the next change event.
- what is WooCommerce API to update the total price OR to update the cost? Where in the hook should i place this?
🙂 Thank you very much for answering
Have you tried this function in WC_AJAX:
By calling:
Those two functions from WC API should help.
calculate_totals() and calculate_shipping().