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 / BirthdayCakeOrderFormTemplate.php

BirthdayCakeOrderFormTemplate.php in The Innovative Form Builder – IvyForms 0.9, at backend/src/Services/Template/BirthdayCakeOrderFormTemplate.php

448 lines 16.7 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 BirthdayCakeOrderFormTemplate
13 {
14 /**
15 * Get the birthday cake order form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'birthday_cake_order_form',
23 'name' => BackendStrings::getTemplateStrings()['birthday_cake_order_form'],
24 'description' => BackendStrings::getTemplateStrings()['birthday_cake_order_form_desc'],
25 'category' => 'order-forms',
26 'subcategory' => 'cake-order-forms',
27 'is_pro' => false,
28 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'birthday-cake-order-form.svg',
29 'form_data' => [
30 'name' => BackendStrings::getTemplateStrings()['birthday_cake_order_form'],
31 'published' => 1,
32 'showTitle' => 1,
33 'storeEntries' => 1,
34 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
35 'fields' => array_merge(
36 self::getCustomerInformationFields(),
37 self::getCakeDetailsFields(),
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' => BackendStrings::getTemplateStrings()['enter_your_email'],
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' => BackendStrings::getTemplateStrings()['enter_your_phone_number'],
115 'required' => true,
116 'parentId' => null,
117 'defaultValue' => '',
118 'position' => 3,
119 'phoneAutoDetect' => true,
120 ],
121 ];
122 }
123
124 /**
125 * Get cake details fields
126 *
127 * @return array<int, array<string, mixed>>
128 */
129 private static function getCakeDetailsFields(): array
130 {
131 return [
132 // Cake Flavor
133 [
134 'id' => 11,
135 'fieldIndex' => 4,
136 'type' => 'select',
137 'label' => BackendStrings::getTemplateStrings()['cake_flavor'],
138 'placeholder' => BackendStrings::getTemplateStrings()['select_cake_flavor'],
139 'required' => true,
140 'parentId' => null,
141 'defaultValue' => '',
142 'position' => 4,
143 'fieldOptions' => [
144 [
145 'id' => 6,
146 'label' => BackendStrings::getTemplateStrings()['chocolate'],
147 'value' => 'chocolate',
148 'isDefault' => false,
149 'position' => 1
150 ],
151 [
152 'id' => 7,
153 'label' => BackendStrings::getTemplateStrings()['vanilla'],
154 'value' => 'vanilla',
155 'isDefault' => false,
156 'position' => 2
157 ],
158 [
159 'id' => 8,
160 'label' => BackendStrings::getTemplateStrings()['red_velvet'],
161 'value' => 'red_velvet',
162 'isDefault' => false,
163 'position' => 3
164 ],
165 [
166 'id' => 9,
167 'label' => BackendStrings::getTemplateStrings()['lemon'],
168 'value' => 'lemon',
169 'isDefault' => false,
170 'position' => 4
171 ],
172 [
173 'id' => 10,
174 'label' => BackendStrings::getTemplateStrings()['custom'],
175 'value' => 'custom',
176 'isDefault' => false,
177 'position' => 5
178 ],
179 ]
180 ],
181 // Cake Size
182 [
183 'id' => 15,
184 'fieldIndex' => 5,
185 'type' => 'select',
186 'label' => BackendStrings::getTemplateStrings()['cake_size'],
187 'placeholder' => BackendStrings::getTemplateStrings()['select_cake_size'],
188 'required' => true,
189 'parentId' => null,
190 'defaultValue' => '',
191 'position' => 5,
192 'fieldOptions' => [
193 [
194 'id' => 12,
195 'label' => BackendStrings::getTemplateStrings()['small_6_inch'],
196 'value' => 'small_6',
197 'isDefault' => false,
198 'position' => 1
199 ],
200 [
201 'id' => 13,
202 'label' => BackendStrings::getTemplateStrings()['medium_8_inch'],
203 'value' => 'medium_8',
204 'isDefault' => false,
205 'position' => 2
206 ],
207 [
208 'id' => 14,
209 'label' => BackendStrings::getTemplateStrings()['large_10_inch'],
210 'value' => 'large_10',
211 'isDefault' => false,
212 'position' => 3
213 ],
214 ]
215 ],
216 // Number of Guests
217 [
218 'id' => 16,
219 'fieldIndex' => 6,
220 'type' => 'number',
221 'label' => BackendStrings::getTemplateStrings()['number_of_guests'],
222 'placeholder' => BackendStrings::getTemplateStrings()['eg_20'],
223 'required' => true,
224 'parentId' => null,
225 'defaultValue' => '',
226 'position' => 6,
227 'minValue' => 1,
228 'maxValue' => 500,
229 ],
230 // Birthday Message on Cake
231 [
232 'id' => 17,
233 'fieldIndex' => 7,
234 'type' => 'text',
235 'label' => BackendStrings::getTemplateStrings()['birthday_message_on_cake'],
236 'placeholder' => BackendStrings::getTemplateStrings()['happy_10th_birthday'],
237 'required' => true,
238 'parentId' => null,
239 'defaultValue' => '',
240 'position' => 7,
241 ],
242 // Special Requests / Design Ideas
243 [
244 'id' => 18,
245 'fieldIndex' => 8,
246 'type' => 'textarea',
247 'label' => BackendStrings::getTemplateStrings()['special_requests_design_ideas'],
248 'placeholder' => BackendStrings::getTemplateStrings()['describe_cake_design_decorations'],
249 'required' => false,
250 'parentId' => null,
251 'defaultValue' => '',
252 'position' => 8,
253 'rows' => 4,
254 ],
255 ];
256 }
257
258 /**
259 * Get delivery details fields
260 *
261 * @return array<int, array<string, mixed>>
262 */
263 private static function getDeliveryDetailsFields(): array
264 {
265 return array_merge(
266 [
267 // Delivery Date
268 [
269 'id' => 19,
270 'fieldIndex' => 9,
271 'type' => 'date',
272 'label' => BackendStrings::getTemplateStrings()['delivery_date'],
273 'placeholder' => BackendStrings::getTemplateStrings()['select_delivery_date'],
274 'required' => true,
275 'parentId' => null,
276 'defaultValue' => '',
277 'position' => 9,
278 'dateFieldType' => 'picker',
279 'dateFormat' => 'MM/DD/YYYY',
280 ],
281 // Delivery Address Field - Parent
282 [
283 'id' => 20,
284 'fieldIndex' => 10,
285 'type' => 'address',
286 'label' => BackendStrings::getTemplateStrings()['delivery_address'],
287 'parentId' => null,
288 'defaultValue' => '',
289 'placeholder' => '',
290 'readonly' => false,
291 'position' => 10,
292 'required' => false,
293 ],
294 ],
295 self::getDeliveryAddressFields()
296 );
297 }
298
299 /**
300 * Get delivery address child fields
301 *
302 * @return array<int, array<string, mixed>>
303 */
304 private static function getDeliveryAddressFields(): array
305 {
306 return [
307 // Address Line 1 - Child of Address Field
308 [
309 'id' => 22,
310 'type' => 'text',
311 'label' => BackendStrings::getTemplateStrings()['address_line_1'],
312 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
313 'required' => true,
314 'parentId' => 10,
315 'fieldIndex' => 10,
316 'defaultValue' => '',
317 'position' => 1,
318 'hideLabel' => false,
319 'description' => '',
320 'addressType' => 'streetAddress',
321 'settings' => json_encode([
322 'type' => 'streetAddress',
323 'hideLabel' => false,
324 'description' => '',
325 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
326 'requiredMessage' => '',
327 'visible' => true
328 ]),
329 ],
330 // Address Line 2 - Child of Address Field
331 [
332 'id' => 24,
333 'type' => 'text',
334 'label' => BackendStrings::getTemplateStrings()['address_line_2'],
335 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
336 'required' => false,
337 'parentId' => 10,
338 'fieldIndex' => 10,
339 'defaultValue' => '',
340 'position' => 2,
341 'hideLabel' => false,
342 'description' => '',
343 'addressType' => 'addressLine2',
344 'settings' => json_encode([
345 'type' => 'addressLine2',
346 'hideLabel' => false,
347 'description' => '',
348 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
349 'requiredMessage' => '',
350 'visible' => true
351 ]),
352 ],
353 // City - Child of Address Field
354 [
355 'id' => 26,
356 'type' => 'text',
357 'label' => BackendStrings::getTemplateStrings()['city'],
358 'placeholder' => BackendStrings::getTemplateStrings()['city'],
359 'required' => true,
360 'parentId' => 10,
361 'fieldIndex' => 10,
362 'defaultValue' => '',
363 'position' => 3,
364 'hideLabel' => false,
365 'description' => '',
366 'addressType' => 'city',
367 'settings' => json_encode([
368 'type' => 'city',
369 'hideLabel' => false,
370 'description' => '',
371 'placeholder' => BackendStrings::getTemplateStrings()['city'],
372 'requiredMessage' => '',
373 'visible' => true
374 ]),
375 ],
376 // State/Province - Child of Address Field
377 [
378 'id' => 28,
379 'type' => 'text',
380 'label' => BackendStrings::getTemplateStrings()['state_province'],
381 'placeholder' => BackendStrings::getTemplateStrings()['state'],
382 'required' => true,
383 'parentId' => 10,
384 'fieldIndex' => 10,
385 'defaultValue' => '',
386 'position' => 4,
387 'hideLabel' => false,
388 'description' => '',
389 'addressType' => 'state',
390 'settings' => json_encode([
391 'type' => 'state',
392 'hideLabel' => false,
393 'description' => '',
394 'placeholder' => BackendStrings::getTemplateStrings()['state'],
395 'requiredMessage' => '',
396 'visible' => true
397 ]),
398 ],
399 // Zip/Postal Code - Child of Address Field
400 [
401 'id' => 30,
402 'type' => 'text',
403 'label' => BackendStrings::getTemplateStrings()['zip_postal_code'],
404 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
405 'required' => true,
406 'parentId' => 10,
407 'fieldIndex' => 10,
408 'defaultValue' => '',
409 'position' => 5,
410 'hideLabel' => false,
411 'description' => '',
412 'addressType' => 'zip',
413 'settings' => json_encode([
414 'type' => 'zip',
415 'hideLabel' => false,
416 'description' => '',
417 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
418 'requiredMessage' => '',
419 'visible' => true
420 ]),
421 ],
422 // Country - Child of Address Field
423 [
424 'id' => 32,
425 'type' => 'text',
426 'label' => BackendStrings::getTemplateStrings()['country'],
427 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
428 'required' => true,
429 'parentId' => 10,
430 'fieldIndex' => 10,
431 'defaultValue' => '',
432 'position' => 6,
433 'hideLabel' => false,
434 'description' => '',
435 'addressType' => 'country',
436 'settings' => json_encode([
437 'type' => 'country',
438 'hideLabel' => false,
439 'description' => '',
440 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
441 'requiredMessage' => '',
442 'visible' => true
443 ]),
444 ],
445 ];
446 }
447 }
448