Merge pull request #15612 from woocommerce/fix/15592
Recalculate totals after local pickup selection
This commit is contained in:
commit
bdb7194b2e
|
@ -1362,8 +1362,16 @@ class WC_Cart {
|
|||
// Only calculate the grand total + shipping if on the cart/checkout
|
||||
if ( is_checkout() || is_cart() || defined( 'WOOCOMMERCE_CHECKOUT' ) || defined( 'WOOCOMMERCE_CART' ) ) {
|
||||
|
||||
// Calculate the Shipping
|
||||
// Calculate the Shipping.
|
||||
$local_pickup_methods = apply_filters( 'woocommerce_local_pickup_methods', array( 'legacy_local_pickup', 'local_pickup' ) );
|
||||
$had_local_pickup = 0 < count( array_intersect( wc_get_chosen_shipping_method_ids(), $local_pickup_methods ) );
|
||||
$this->calculate_shipping();
|
||||
$has_local_pickup = 0 < count( array_intersect( wc_get_chosen_shipping_method_ids(), $local_pickup_methods ) );
|
||||
|
||||
// If methods changed and local pickup is selected, we need to do a recalculation of taxes.
|
||||
if ( true === apply_filters( 'woocommerce_apply_base_tax_for_local_pickup', true ) && $had_local_pickup !== $has_local_pickup ) {
|
||||
return $this->calculate_totals();
|
||||
}
|
||||
|
||||
// Trigger the fees API where developers can add fees to the cart
|
||||
$this->calculate_fees();
|
||||
|
|
Loading…
Reference in New Issue