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

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