← All changes
|
app/Http/Requests/FrontendRequests/CouponRequest.php
+20
-3
1.3.21
→
1.6.5
View file →
| @@ -28,14 +28,21 @@ | ||
| 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', |
| 36 | 43 | "order_items.*.rate" => 'nullable|numeric', |
| 37 | - "order_items.*.line_meta" => 'nullable|sanitizeTextArea', | |
| 44 | + "order_items.*.line_meta" => 'nullable', | |
| 38 | 45 | "order_items.*.other_info" => 'nullable|array', |
| 39 | 46 | 'applied_coupons' => 'nullable|array', |
| 40 | 47 | |
| 41 | 48 | 'customer_email' => 'nullable|sanitizeText|email', |
| @@ -74,15 +81,25 @@ | ||
| 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', |
| 82 | 95 | "order_items.*.rate" => 'floatval', |
| 83 | - "order_items.*.line_meta" => 'sanitize_text_field', | |
| 84 | - "order_items.*.other_info" => 'sanitize_text_field', | |
| 96 | + "order_items.*.line_meta" => function ($value) { | |
| 97 | + return is_array($value) ? $value : sanitize_text_field((string) $value); | |
| 98 | + }, | |
| 99 | + "order_items.*.other_info" => function ($value) { | |
| 100 | + return is_array($value) ? $value : sanitize_text_field((string) $value); | |
| 101 | + }, | |
| 85 | 102 | 'applied_coupons.*' => 'intval', |
| 86 | 103 | |
| 87 | 104 | 'customer_email' => function ($value) { |
| 88 | 105 | if(empty($value)) { |