PluginProbe
The Innovative Form Builder – IvyForms / 0.9
The Innovative Form Builder – IvyForms v0.9
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.9, at backend/src/Services/Template/CustomTShirtOrderFormTemplate.php

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