← All changes
|
app/Services/Coupon/Concerns/CanCalculateLineTotal.php
+10
-2
1.3.21
→
1.7.0
View file →
| @@ -33,8 +33,13 @@ | ||
| 33 | 33 | $this->previouslyAppliedCoupons->put($coupon->code, $coupon); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $this->formatDiscountNumbers(); |
| 37 | + | |
| 38 | + foreach ($lineItems as $id => $lineItem) { | |
| 39 | + $lineItems[$id]['coupon_discount'] = (int) $lineItem['discount_total']; | |
| 40 | + } | |
| 41 | + | |
| 37 | 42 | $this->calculatedLineItems = $lineItems; |
| 38 | 43 | |
| 39 | 44 | } |
| 40 | 45 | |
| @@ -154,10 +159,13 @@ | ||
| 154 | 159 | 'hash' => App::request()->get(Helper::INSTANT_CHECKOUT_URL_PARAM) |
| 155 | 160 | ]); |
| 156 | 161 | |
| 157 | 162 | if ($cart) { |
| 158 | - $upgradeDiscount = Arr::get($cart, 'checkout_data.manual_discount.amount', 0); | |
| 159 | - $totalPrice = $totalPrice - $upgradeDiscount; | |
| 163 | + // Prorate credit is a post-tax adjustment to the payable total, not a | |
| 164 | + // discount, so it must NOT reduce the coupon-applicable base. Only a | |
| 165 | + // real manual discount reduces the base here. | |
| 166 | + $manualDiscount = Arr::get($cart, 'checkout_data.manual_discount.amount', 0); | |
| 167 | + $totalPrice = $totalPrice - $manualDiscount; | |
| 160 | 168 | if ($totalPrice < 0) { |
| 161 | 169 | $totalPrice = 0; |
| 162 | 170 | } |
| 163 | 171 | } |