PluginProbe
The Innovative Form Builder – IvyForms / 0.6.1-backup
The Innovative Form Builder – IvyForms v0.6.1-backup
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / Template / CustomTShirtOrderFormTemplate.php

CustomTShirtOrderFormTemplate.php in The Innovative Form Builder – IvyForms 0.6.1-backup, at backend/src/Services/Template/CustomTShirtOrderFormTemplate.php

337 lines 12.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Services\Template;
4
5 // phpcs:disable PSR1.Files.SideEffects
6 if (!defined('ABSPATH')) {
7 exit; // Exit if accessed directly
8 }
9
10 use IvyForms\Services\Translations\BackendStrings;
11
12 class CustomTShirtOrderFormTemplate
13 {
14 /**
15 * Get the custom t-shirt order form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'custom_tshirt_order_form',
23 'name' => BackendStrings::getTemplateStrings()['custom_tshirt_order_form'],
24 'description' => BackendStrings::getTemplateStrings()['custom_tshirt_order_form_desc'],
25 'category' => 'order-forms',
26 'is_pro' => false,
27 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'custom-tshirt-order-form.svg',
28 'form_data' => [
29 'name' => BackendStrings::getTemplateStrings()['custom_tshirt_order_form'],
30 'published' => 1,
31 'showTitle' => 1,
32 'storeEntries' => 1,
33 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
34 'fields' => array_merge(
35 self::getCustomerInformationFields(),
36 self::getTShirtDetailsFields(),
37 self::getDeliveryDetailsFields()
38 ),
39 'settings' => []
40 ]
41 ];
42 }
43
44 /**
45 * Get customer information fields
46 *
47 * @return array<int, array<string, mixed>>
48 */
49 private static function getCustomerInformationFields(): array
50 {
51 return [
52 // Name Field - Parent
53 [
54 'id' => 0,
55 'fieldIndex' => 1,
56 'type' => 'name',
57 'label' => BackendStrings::getTemplateStrings()['full_name'],
58 'parentId' => null,
59 'defaultValue' => '',
60 'placeholder' => '',
61 'required' => true,
62 'readonly' => false,
63 'position' => 1,
64 ],
65 // First Name - Child of Name Field
66 [
67 'id' => 0,
68 'type' => 'text',
69 'label' => BackendStrings::getNewFormStrings()['first_name'],
70 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
71 'required' => true,
72 'parentId' => 0,
73 'fieldIndex' => 1,
74 'defaultValue' => '',
75 'position' => 1,
76 'optionHide' => false,
77 'description' => '',
78 'settings' => json_encode(['nameFieldType' => 'nameField1']),
79 ],
80 // Last Name - Child of Name Field
81 [
82 'id' => 0,
83 'type' => 'text',
84 'label' => BackendStrings::getNewFormStrings()['last_name'],
85 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
86 'required' => true,
87 'parentId' => 0,
88 'fieldIndex' => 1,
89 'defaultValue' => '',
90 'position' => 2,
91 'optionHide' => false,
92 'description' => '',
93 'settings' => json_encode(['nameFieldType' => 'nameField2']),
94 ],
95 // Email Address
96 [
97 'id' => 0,
98 'fieldIndex' => 2,
99 'type' => 'email',
100 'label' => BackendStrings::getTemplateStrings()['email_address'],
101 'placeholder' => '[email protected]',
102 'required' => true,
103 'parentId' => null,
104 'defaultValue' => '',
105 'position' => 2,
106 ],
107 // Phone Number
108 [
109 'id' => 0,
110 'fieldIndex' => 3,
111 'type' => 'phone',
112 'label' => BackendStrings::getTemplateStrings()['phone_number'],
113 'placeholder' => '+1 (_) _-_',
114 'required' => false,
115 'parentId' => null,
116 'defaultValue' => '',
117 'position' => 3,
118 'phoneAutoDetect' => true,
119 ],
120 ];
121 }
122
123 /**
124 * Get t-shirt details fields
125 *
126 * @return array<int, array<string, mixed>>
127 */
128 private static function getTShirtDetailsFields(): array
129 {
130 return [
131 // T-Shirt Design Name
132 [
133 'id' => 0,
134 'fieldIndex' => 4,
135 'type' => 'text',
136 'label' => BackendStrings::getTemplateStrings()['tshirt_design_name'],
137 'placeholder' => BackendStrings::getTemplateStrings()['enter_design_name_or_theme'],
138 'required' => true,
139 'parentId' => null,
140 'defaultValue' => '',
141 'position' => 4,
142 ],
143 // T-Shirt Size
144 [
145 'id' => 0,
146 'fieldIndex' => 5,
147 'type' => 'select',
148 'label' => BackendStrings::getTemplateStrings()['tshirt_size'],
149 'placeholder' => BackendStrings::getTemplateStrings()['select_tshirt_size'],
150 'required' => true,
151 'parentId' => null,
152 'defaultValue' => '',
153 'position' => 5,
154 'fieldOptions' => [
155 [
156 'id' => 0,
157 'label' => BackendStrings::getTemplateStrings()['xs'],
158 'value' => 'xs',
159 'isDefault' => false,
160 'position' => 1
161 ],
162 [
163 'id' => 0,
164 'label' => BackendStrings::getTemplateStrings()['s'],
165 'value' => 's',
166 'isDefault' => false,
167 'position' => 2
168 ],
169 [
170 'id' => 0,
171 'label' => BackendStrings::getTemplateStrings()['m'],
172 'value' => 'm',
173 'isDefault' => false,
174 'position' => 3
175 ],
176 [
177 'id' => 0,
178 'label' => BackendStrings::getTemplateStrings()['l'],
179 'value' => 'l',
180 'isDefault' => false,
181 'position' => 4
182 ],
183 [
184 'id' => 0,
185 'label' => BackendStrings::getTemplateStrings()['xl'],
186 'value' => 'xl',
187 'isDefault' => false,
188 'position' => 5
189 ],
190 [
191 'id' => 0,
192 'label' => BackendStrings::getTemplateStrings()['xxl'],
193 'value' => 'xxl',
194 'isDefault' => false,
195 'position' => 6
196 ],
197 ]
198 ],
199 // Quantity
200 [
201 'id' => 0,
202 'fieldIndex' => 6,
203 'type' => 'number',
204 'label' => BackendStrings::getTemplateStrings()['quantity'],
205 'placeholder' => BackendStrings::getTemplateStrings()['enter_number_of_tshirts'],
206 'required' => true,
207 'parentId' => null,
208 'position' => 6,
209 'minValue' => 1,
210 'maxValue' => 100,
211 ],
212 // Additional Instructions
213 [
214 'id' => 0,
215 'fieldIndex' => 7,
216 'type' => 'textarea',
217 'label' => BackendStrings::getTemplateStrings()['additional_instructions'],
218 'placeholder' => BackendStrings::getTemplateStrings()['provide_special_requests_or_notes'],
219 'parentId' => null,
220 'defaultValue' => '',
221 'position' => 7,
222 'required' => false,
223 'rows' => 3,
224 ],
225 // T-Shirt Color
226 [
227 'id' => 0,
228 'fieldIndex' => 8,
229 'type' => 'select',
230 'label' => BackendStrings::getTemplateStrings()['tshirt_color'],
231 'placeholder' => BackendStrings::getTemplateStrings()['select_tshirt_color'],
232 'required' => true,
233 'parentId' => null,
234 'defaultValue' => '',
235 'position' => 8,
236 'fieldOptions' => [
237 [
238 'id' => 0,
239 'label' => BackendStrings::getTemplateStrings()['white'],
240 'value' => 'white',
241 'isDefault' => false,
242 'position' => 1
243 ],
244 [
245 'id' => 0,
246 'label' => BackendStrings::getTemplateStrings()['black'],
247 'value' => 'black',
248 'isDefault' => false,
249 'position' => 2
250 ],
251 [
252 'id' => 0,
253 'label' => BackendStrings::getTemplateStrings()['red'],
254 'value' => 'red',
255 'isDefault' => false,
256 'position' => 3
257 ],
258 [
259 'id' => 0,
260 'label' => BackendStrings::getTemplateStrings()['blue'],
261 'value' => 'blue',
262 'isDefault' => false,
263 'position' => 4
264 ],
265 [
266 'id' => 0,
267 'label' => BackendStrings::getTemplateStrings()['green'],
268 'value' => 'green',
269 'isDefault' => false,
270 'position' => 5
271 ],
272 [
273 'id' => 0,
274 'label' => BackendStrings::getTemplateStrings()['custom'],
275 'value' => 'custom',
276 'isDefault' => false,
277 'position' => 6
278 ],
279 ]
280 ],
281 ];
282 }
283
284 /**
285 * Get delivery details fields
286 *
287 * @return array<int, array<string, mixed>>
288 */
289 private static function getDeliveryDetailsFields(): array
290 {
291 return [
292 // Gift Wrap
293 [
294 'id' => 0,
295 'fieldIndex' => 9,
296 'type' => 'radio',
297 'label' => BackendStrings::getTemplateStrings()['gift_wrap'],
298 'parentId' => null,
299 'position' => 9,
300 'required' => false,
301 'defaultValue' => '',
302 'placeholder' => '',
303 'fieldOptions' => [
304 [
305 'id' => 0,
306 'label' => BackendStrings::getTemplateStrings()['yes'],
307 'value' => 'yes',
308 'isDefault' => false,
309 'position' => 1
310 ],
311 [
312 'id' => 0,
313 'label' => BackendStrings::getTemplateStrings()['no'],
314 'value' => 'no',
315 'isDefault' => false,
316 'position' => 2
317 ],
318 ]
319 ],
320 // Delivery Date
321 [
322 'id' => 0,
323 'fieldIndex' => 10,
324 'type' => 'date',
325 'label' => BackendStrings::getTemplateStrings()['delivery_date'],
326 'placeholder' => BackendStrings::getTemplateStrings()['select_delivery_date'],
327 'required' => true,
328 'parentId' => null,
329 'defaultValue' => '',
330 'position' => 10,
331 'dateFieldType' => 'picker',
332 'dateFormat' => 'MM/DD/YYYY',
333 ],
334 ];
335 }
336 }
337