PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.5.3
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.5.3
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
fluent-cart / app / Http / Requests / OrderRequest.php

OrderRequest.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.5.3, at app/Http/Requests/OrderRequest.php

228 lines 11.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Http\Requests;
4
5 use FluentCart\Framework\Foundation\RequestGuard;
6
7 class OrderRequest extends RequestGuard
8 {
9
10 /**
11 * @return array
12 */
13 public function rules(): array
14 {
15 return [
16 'status' => 'nullable|sanitizeText|maxLength:50',
17 'invoice_no' => 'nullable|sanitizeText|maxLength:100',
18 'fulfillment_type' => 'nullable|sanitizeText|maxLength:50',
19 'type' => 'nullable|sanitizeText|maxLength:50',
20 'payment_method' => 'nullable|sanitizeText|maxLength:50',
21 'payment_method_title' => 'nullable|sanitizeText|maxLength:50',
22 'payment_status' => 'nullable|sanitizeText|maxLength:50',
23 'currency' => 'nullable|sanitizeText|maxLength:10',
24 'subtotal' => 'numeric',
25 'discount_tax' => 'numeric',
26 'manual_discount_total' => 'numeric',
27 'coupon_discount_total' => 'numeric',
28 'shipping_tax' => 'numeric',
29 'shipping_total' => 'numeric',
30 'tax_total' => 'numeric',
31 'total_amount' => 'numeric',
32 'rate' => 'numeric',
33 'note' => 'nullable|sanitizeTextArea|maxLength:5000',
34 'uuid' => 'nullable|sanitizeText|maxLength:100',
35 'ip_address' => 'nullable|sanitizeText|maxLength:100',
36 'completed_at' => 'nullable|sanitizeText|maxLength:100',
37 'refunded_at' => 'nullable|sanitizeText|maxLength:100',
38 'customer_id' => 'required|numeric',
39 'user_tz' => 'nullable|sanitizeText|maxLength:50',
40
41 'order_items' => 'required|array',
42 "order_items.*.id" => 'numeric|min:1',
43 "order_items.*.order_id" => 'numeric|min:1',
44 "order_items.*.post_id" => 'numeric|min:1',
45 "order_items.*.variation_id" => 'numeric|min:1',
46 "order_items.*.object_id" => 'numeric|min:1',
47 "order_items.*.fulfillment_type" => 'nullable|sanitizeText',
48 "order_items.*.payment_type" => 'nullable|sanitizeText|maxLength:100',
49 "order_items.*.quantity" => 'numeric|min:1',
50 "order_items.*.post_title" => 'nullable|sanitizeText|maxLength:255',
51 "order_items.*.title" => 'nullable|sanitizeText|maxLength:255',
52 "order_items.*.price" => 'numeric',
53 "order_items.*.unit_price" => 'numeric',
54 "order_items.*.shipping_charge" => 'nullable|numeric',
55 "order_items.*.item_cost" => 'numeric',
56 "order_items.*.item_total" => 'numeric',
57 "order_items.*.tax_amount" => 'numeric',
58 "order_items.*.discount_total" => 'numeric',
59 "order_items.*.total" => 'numeric',
60 "order_items.*.line_total" => 'numeric',
61 "order_items.*.cart_index" => 'nullable|numeric',
62 "order_items.*.rate" => 'nullable|numeric',
63 "order_items.*.line_meta" => 'nullable|array',
64 "order_items.*.other_info" => 'nullable|array',
65
66 "discount.type" => 'nullable|sanitizeText|maxLength:100',
67 "discount.value" => 'nullable|numeric',
68 "discount.label" => 'nullable|sanitizeText|maxLength:100',
69 "discount.reason" => 'nullable|sanitizeText|maxLength:100',
70 "discount.action" => 'nullable|sanitizeText|maxLength:100',
71
72 'shipping' => 'nullable|array',
73 "shipping.*.type" => 'nullable|sanitizeText|maxLength:100',
74 "shipping.*.rate_name" => 'nullable|sanitizeText|maxLength:100',
75 "shipping.*.custom_price" => 'nullable|numeric',
76
77 'deletedItems' => 'nullable|array',
78 'tax_behavior' => 'nullable|numeric|min:0',
79 'tax_lines' => 'nullable|array',
80 'tax_lines.*.rate_id' => 'nullable|numeric|min:0',
81 'tax_lines.*.tax_amount' => 'nullable|numeric|min:0',
82 'tax_lines.*.label' => 'nullable|sanitizeText',
83 'tax_lines.*.is_compound'=> 'nullable',
84
85 'applied_coupon' => 'nullable|array',
86 "applied_coupon.*.id" => 'nullable|numeric|min:1',
87 "applied_coupon.*.order_id" => 'nullable|numeric|min:1',
88 "applied_coupon.*.coupon_id" => 'required|numeric|min:1',
89 //"applied_coupon.*.title" => 'required|string|max:100',
90 "applied_coupon.*.code" => 'required|sanitizeText|maxLength:100',
91 //"applied_coupon.*.status" => 'required|string|max:100',
92 //"applied_coupon.*.type" => 'required|string|max:100',
93 "applied_coupon.*.amount" => 'nullable|numeric',
94 "applied_coupon.*.discounted_amount" => 'required|numeric',
95 "applied_coupon.*.discount" => 'nullable|numeric',
96 "applied_coupon.*.stackable" => 'required|numeric',
97 "applied_coupon.*.priority" => 'nullable|numeric',
98 "applied_coupon.*.max_uses" => 'nullable|numeric',
99 "applied_coupon.*.use_count" => 'nullable|numeric',
100 "applied_coupon.*.max_per_customer" => 'nullable|numeric|min:1',
101 "applied_coupon.*.min_purchase_amount" => 'nullable|numeric',
102 "applied_coupon.*.max_discount_amount" => 'nullable|numeric',
103 "applied_coupon.*.notes" => 'nullable|sanitizeTextArea|maxLength:100',
104 'trigger' => 'nullable|string',
105 ];
106 }
107
108
109 /**
110 * @return array
111 */
112 public function messages(): array
113 {
114 return [
115 'customer_id.required' => esc_html__('Customer selection is required', 'fluent-cart'),
116 'order_items.required' => esc_html__('Item selection is required', 'fluent-cart'),
117 ];
118 }
119
120
121 /**
122 * @return array
123 */
124 public function sanitize()
125 {
126 return [
127 'id' => 'intval',
128 'status' => 'sanitize_text_field',
129 'invoice_no' => 'sanitize_text_field',
130 'fulfillment_type' => 'sanitize_text_field',
131 'type' => 'sanitize_text_field',
132 'customer_id' => 'intval',
133 'payment_method' => 'sanitize_text_field',
134 'payment_method_title' => 'sanitize_text_field',
135 'payment_status' => 'sanitize_text_field',
136 'currency' => 'sanitize_text_field',
137 'subtotal' => 'floatval',
138 'discount_tax' => 'floatval',
139 'manual_discount_total' => 'floatval',
140 'coupon_discount_total' => 'floatval',
141 'shipping_tax' => 'floatval',
142 'shipping_total' => 'floatval',
143 'tax_total' => 'floatval',
144 'tax_behavior' => 'intval',
145 'total_amount' => 'floatval',
146 'rate' => 'sanitize_text_field',
147 'note' => 'sanitize_text_field',
148 'uuid' => 'sanitize_text_field',
149 'ip_address' => 'sanitize_text_field',
150 'billing_address_id' => 'intval',
151 'shipping_address_id' => 'intval',
152 'completed_at' => 'sanitize_text_field',
153 'refunded_at' => 'sanitize_text_field',
154 'user_tz' => 'sanitize_text_field',
155
156 "order_items.*.id" => 'intval',
157 "order_items.*.order_id" => 'intval',
158 "order_items.*.post_id" => 'intval',
159 "order_items.*.object_id" => 'intval',
160 "order_items.*.payment_type" => 'sanitize_text_field',
161 "order_items.*.quantity" => 'intval',
162 "order_items.*.post_title" => 'sanitize_text_field',
163 "order_items.*.title" => 'sanitize_text_field',
164 "order_items.*.shipping_charge" => 'intval',
165 "order_items.*.price" => 'floatval',
166 "order_items.*.unit_price" => 'floatval',
167 "order_items.*.item_cost" => 'floatval',
168 "order_items.*.item_total" => 'floatval',
169 "order_items.*.tax_amount" => 'floatval',
170 "order_items.*.discount_total" => 'floatval',
171 "order_items.*.total" => 'floatval',
172 "order_items.*.line_total" => 'floatval',
173 "order_items.*.cart_index" => 'intval',
174 "order_items.*.rate" => 'floatval',
175 "order_items.*.line_meta" => function ($value) {
176 return is_array($value) ? $value : [];
177 },
178 "order_items.*.other_info" => function ($value) {
179 return is_array($value) ? $value : [];
180 },
181
182 "discount.type" => 'sanitize_text_field',
183 "discount.value" => 'floatval',
184 "discount.label" => 'sanitize_text_field',
185 "discount.reason" => 'sanitize_text_field',
186 "discount.action" => 'sanitize_text_field',
187
188 "shipping.*.type" => 'sanitize_text_field',
189 "shipping.*.rate_name" => 'sanitize_text_field',
190 "shipping.*.custom_price" => 'floatval',
191
192 "deletedItems" => function ($value) {
193 return is_array($value) ? $value : [];
194 },
195 "tax_lines" => function ($value) {
196 return is_array($value) ? $value : [];
197 },
198 "tax_lines.*.rate_id" => 'intval',
199 "tax_lines.*.tax_amount" => 'intval',
200 "tax_lines.*.label" => 'sanitize_text_field',
201 "tax_lines.*.is_compound"=> function ($value) {
202 return (bool) $value;
203 },
204
205 "applied_coupon.*.id" => 'intval',
206 "applied_coupon.*.order_id" => 'intval',
207 "applied_coupon.*.coupon_id" => 'intval',
208 "applied_coupon.*.title" => 'sanitize_text_field',
209 "applied_coupon.*.discount" => 'intval',
210 "applied_coupon.*.code" => 'sanitize_text_field',
211 "applied_coupon.*.status" => 'sanitize_text_field',
212 "applied_coupon.*.type" => 'sanitize_text_field',
213 "applied_coupon.*.amount" => 'intval',
214 "applied_coupon.*.discounted_amount" => 'intval',
215 "applied_coupon.*.stackable" => 'intval',
216 "applied_coupon.*.priority" => 'intval',
217 "applied_coupon.*.max_uses" => 'intval',
218 "applied_coupon.*.use_count" => 'intval',
219 "applied_coupon.*.max_per_customer" => 'intval',
220 "applied_coupon.*.min_purchase_amount" => 'intval',
221 "applied_coupon.*.max_discount_amount" => 'intval',
222 "applied_coupon.*.notes" => 'sanitize_text_field',
223 'trigger' => 'sanitize_text_field',
224 ];
225
226 }
227 }
228