← All changes
|
app/Http/Requests/FrontendRequests/CouponRequest.php
+13
-0
1.5.1
→
1.6.5
View file →
| @@ -28,8 +28,15 @@ | ||
| 28 | 28 | "order_items.*.unit_price" => 'numeric', |
| 29 | 29 | "order_items.*.item_cost" => 'numeric', |
| 30 | 30 | "order_items.*.item_total" => 'numeric', |
| 31 | 31 | "order_items.*.tax_amount" => 'numeric', |
| 32 | + // nullable: the admin UI serializes variation line items with subtotal null | |
| 33 | + // (cartService.js computes unit_price*quantity - cost, and productService.js | |
| 34 | + // never sets `cost` on variation rows, so NaN JSON-encodes as null). The bare | |
| 35 | + // numeric rule 422'd every coupon apply on such orders. CouponServiceAdmin | |
| 36 | + // falls back to unit_price*quantity for non-numeric subtotals, keeping the | |
| 37 | + // min/max purchase-amount enforcement this field was whitelisted for. | |
| 38 | + "order_items.*.subtotal" => 'nullable|numeric', | |
| 32 | 39 | "order_items.*.discount_total" => 'numeric', |
| 33 | 40 | "order_items.*.total" => 'numeric', |
| 34 | 41 | "order_items.*.line_total" => 'numeric', |
| 35 | 42 | "order_items.*.cart_index" => 'nullable|numeric', |
| @@ -74,8 +81,14 @@ | ||
| 74 | 81 | "order_items.*.unit_price" => 'floatval', |
| 75 | 82 | "order_items.*.item_cost" => 'floatval', |
| 76 | 83 | "order_items.*.item_total" => 'floatval', |
| 77 | 84 | "order_items.*.tax_amount" => 'floatval', |
| 85 | + // floatval(null) would coerce to 0.0 and silently zero the items total the | |
| 86 | + // min/max purchase gates sum — keep null as null so the service layer can | |
| 87 | + // recompute it from unit_price * quantity instead. | |
| 88 | + "order_items.*.subtotal" => function ($value) { | |
| 89 | + return is_numeric($value) ? floatval($value) : null; | |
| 90 | + }, | |
| 78 | 91 | "order_items.*.discount_total" => 'floatval', |
| 79 | 92 | "order_items.*.total" => 'floatval', |
| 80 | 93 | "order_items.*.line_total" => 'floatval', |
| 81 | 94 | "order_items.*.cart_index" => 'intval', |