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

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