Merge pull request #15612 from woocommerce/fix/15592

Recalculate totals after local pickup selection
This commit is contained in:
Claudiu Lodromanean 2017-06-14 08:55:50 -07:00 committed by GitHub
commit bdb7194b2e
1 changed files with 9 additions and 1 deletions

View File

@ -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();