| @@ -37,9 +37,10 @@ | ||
| 37 | 37 | |
| 38 | 38 | $ignores = [ |
| 39 | 39 | 'apply_coupons', |
| 40 | 40 | 'discounts_recalculated', |
| 41 | - 'remove_coupon' | |
| 41 | + 'remove_coupon', | |
| 42 | + 'payment_method_fee_recalculate', | |
| 42 | 43 | ]; |
| 43 | 44 | |
| 44 | 45 | if (in_array($scope, $ignores)) { |
| 45 | 46 | return; |
| @@ -88,8 +89,16 @@ | ||
| 88 | 89 | { |
| 89 | 90 | $shippingCountry = Arr::get($fillData, 'checkout_data.form_data.shipping_country', null); |
| 90 | 91 | $shippingState = Arr::get($fillData, 'checkout_data.form_data.shipping_state', null); |
| 91 | 92 | |
| 93 | + // Checkout renderer resolves shipping methods with a billing fallback when no | |
| 94 | + // shipping address is set (ship-to-different unchecked). Resolve the same way | |
| 95 | + // here, otherwise this chain zeroes the method/charges the renderer just offered. | |
| 96 | + if (!$shippingCountry) { | |
| 97 | + $shippingCountry = Arr::get($fillData, 'checkout_data.form_data.billing_country', null); | |
| 98 | + $shippingState = Arr::get($fillData, 'checkout_data.form_data.billing_state', null); | |
| 99 | + } | |
| 100 | + | |
| 92 | 101 | $availableShippingMethods = AddressHelper::getShippingMethods($shippingCountry, $shippingState); |
| 93 | 102 | |
| 94 | 103 | if (!$availableShippingMethods || is_wp_error($availableShippingMethods)) { |
| 95 | 104 | Arr::set($fillData, 'checkout_data.shipping_data.shipping_charge', 0); |
| @@ -99,8 +108,9 @@ | ||
| 99 | 108 | foreach ($cartData as &$cartItem) { |
| 100 | 109 | $cartItem['shipping_charge'] = 0; |
| 101 | 110 | $cartItem['itemwise_shipping_charge'] = 0; |
| 102 | 111 | } |
| 112 | + unset($cartItem); | |
| 103 | 113 | |
| 104 | 114 | Arr::set($fillData, 'cart_data', $cartData); |
| 105 | 115 | |
| 106 | 116 | return $fillData; |