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

433 lines 16.2 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' => 0,
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' => 0,
69 'type' => 'text',
70 'label' => BackendStrings::getNewFormStrings()['first_name'],
71 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
72 'required' => true,
73 'parentId' => 0,
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' => 0,
84 'type' => 'text',
85 'label' => BackendStrings::getNewFormStrings()['last_name'],
86 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
87 'required' => true,
88 'parentId' => 0,
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' => 0,
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' => 0,
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' => 0,
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' => 0,
146 'label' => BackendStrings::getTemplateStrings()['chocolate'],
147 'value' => 'chocolate',
148 'isDefault' => false,
149 'position' => 1
150 ],
151 [
152 'id' => 0,
153 'label' => BackendStrings::getTemplateStrings()['vanilla'],
154 'value' => 'vanilla',
155 'isDefault' => false,
156 'position' => 2
157 ],
158 [
159 'id' => 0,
160 'label' => BackendStrings::getTemplateStrings()['red_velvet'],
161 'value' => 'red_velvet',
162 'isDefault' => false,
163 'position' => 3
164 ],
165 [
166 'id' => 0,
167 'label' => BackendStrings::getTemplateStrings()['lemon'],
168 'value' => 'lemon',
169 'isDefault' => false,
170 'position' => 4
171 ],
172 [
173 'id' => 0,
174 'label' => BackendStrings::getTemplateStrings()['custom'],
175 'value' => 'custom',
176 'isDefault' => false,
177 'position' => 5
178 ],
179 ]
180 ],
181 // Cake Size
182 [
183 'id' => 0,
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' => 0,
195 'label' => BackendStrings::getTemplateStrings()['small_6_inch'],
196 'value' => 'small_6',
197 'isDefault' => false,
198 'position' => 1
199 ],
200 [
201 'id' => 0,
202 'label' => BackendStrings::getTemplateStrings()['medium_8_inch'],
203 'value' => 'medium_8',
204 'isDefault' => false,
205 'position' => 2
206 ],
207 [
208 'id' => 0,
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' => 0,
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' => 0,
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' => 0,
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 [
266 // Delivery Date
267 [
268 'id' => 0,
269 'fieldIndex' => 9,
270 'type' => 'date',
271 'label' => BackendStrings::getTemplateStrings()['delivery_date'],
272 'placeholder' => BackendStrings::getTemplateStrings()['select_delivery_date'],
273 'required' => true,
274 'parentId' => null,
275 'defaultValue' => '',
276 'position' => 9,
277 'dateFormat' => 'MM/DD/YYYY',
278 ],
279 // Delivery Address Field - Parent
280 [
281 'id' => 0,
282 'fieldIndex' => 10,
283 'type' => 'address',
284 'label' => BackendStrings::getTemplateStrings()['delivery_address'],
285 'parentId' => null,
286 'defaultValue' => '',
287 'placeholder' => '',
288 'readonly' => false,
289 'position' => 10,
290 'required' => false,
291 ],
292 // Address Line 1 - Child of Address Field
293 [
294 'id' => 0,
295 'type' => 'text',
296 'label' => BackendStrings::getTemplateStrings()['address_line_1'],
297 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
298 'required' => true,
299 'parentId' => 0,
300 'fieldIndex' => 10,
301 'defaultValue' => '',
302 'position' => 1,
303 'hideLabel' => false,
304 'description' => '',
305 'addressType' => 'streetAddress',
306 'settings' => json_encode([
307 'type' => 'streetAddress',
308 'hideLabel' => false,
309 'description' => '',
310 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
311 'requiredMessage' => '',
312 'visible' => true
313 ]),
314 ],
315 // Address Line 2 - Child of Address Field
316 [
317 'id' => 0,
318 'type' => 'text',
319 'label' => BackendStrings::getTemplateStrings()['address_line_2'],
320 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
321 'required' => false,
322 'parentId' => 0,
323 'fieldIndex' => 10,
324 'defaultValue' => '',
325 'position' => 2,
326 'hideLabel' => false,
327 'description' => '',
328 'addressType' => 'addressLine2',
329 'settings' => json_encode([
330 'type' => 'addressLine2',
331 'hideLabel' => false,
332 'description' => '',
333 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
334 'requiredMessage' => '',
335 'visible' => true
336 ]),
337 ],
338 // City - Child of Address Field
339 [
340 'id' => 0,
341 'type' => 'text',
342 'label' => BackendStrings::getTemplateStrings()['city'],
343 'placeholder' => BackendStrings::getTemplateStrings()['city'],
344 'required' => true,
345 'parentId' => 0,
346 'fieldIndex' => 10,
347 'defaultValue' => '',
348 'position' => 3,
349 'hideLabel' => false,
350 'description' => '',
351 'addressType' => 'city',
352 'settings' => json_encode([
353 'type' => 'city',
354 'hideLabel' => false,
355 'description' => '',
356 'placeholder' => BackendStrings::getTemplateStrings()['city'],
357 'requiredMessage' => '',
358 'visible' => true
359 ]),
360 ],
361 // State/Province - Child of Address Field
362 [
363 'id' => 0,
364 'type' => 'text',
365 'label' => BackendStrings::getTemplateStrings()['state_province'],
366 'placeholder' => BackendStrings::getTemplateStrings()['state'],
367 'required' => true,
368 'parentId' => 0,
369 'fieldIndex' => 10,
370 'defaultValue' => '',
371 'position' => 4,
372 'hideLabel' => false,
373 'description' => '',
374 'addressType' => 'state',
375 'settings' => json_encode([
376 'type' => 'state',
377 'hideLabel' => false,
378 'description' => '',
379 'placeholder' => BackendStrings::getTemplateStrings()['state'],
380 'requiredMessage' => '',
381 'visible' => true
382 ]),
383 ],
384 // Zip/Postal Code - Child of Address Field
385 [
386 'id' => 0,
387 'type' => 'text',
388 'label' => BackendStrings::getTemplateStrings()['zip_postal_code'],
389 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
390 'required' => true,
391 'parentId' => 0,
392 'fieldIndex' => 10,
393 'defaultValue' => '',
394 'position' => 5,
395 'hideLabel' => false,
396 'description' => '',
397 'addressType' => 'zip',
398 'settings' => json_encode([
399 'type' => 'zip',
400 'hideLabel' => false,
401 'description' => '',
402 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
403 'requiredMessage' => '',
404 'visible' => true
405 ]),
406 ],
407 // Country - Child of Address Field
408 [
409 'id' => 0,
410 'type' => 'text',
411 'label' => BackendStrings::getTemplateStrings()['country'],
412 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
413 'required' => true,
414 'parentId' => 0,
415 'fieldIndex' => 10,
416 'defaultValue' => '',
417 'position' => 6,
418 'hideLabel' => false,
419 'description' => '',
420 'addressType' => 'country',
421 'settings' => json_encode([
422 'type' => 'country',
423 'hideLabel' => false,
424 'description' => '',
425 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
426 'requiredMessage' => '',
427 'visible' => true
428 ]),
429 ],
430 ];
431 }
432 }
433