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

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

406 lines 13.9 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 CustomCakeOrderFormTemplate
13 {
14 /**
15 * Get the custom cake order form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'custom_cake_order_form',
23 'name' => BackendStrings::getTemplateStrings()['custom_cake_order_form'],
24 'description' => BackendStrings::getTemplateStrings()['custom_cake_order_form_desc'],
25 'category' => 'order-forms',
26 'subcategory' => 'cake-order-forms',
27 'is_pro' => false,
28 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'custom-cake-order-form.svg',
29 'form_data' => [
30 'name' => BackendStrings::getTemplateStrings()['custom_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' => 'enter_your_email_address',
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' => 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 array_merge(
132 self::getOccasionField(),
133 self::getCakeFlavorField(),
134 self::getCakeSizeField(),
135 self::getDesignInspirationField(),
136 self::getCakeMessageField()
137 );
138 }
139
140 /**
141 * Get occasion field
142 *
143 * @return array<int, array<string, mixed>>
144 */
145 private static function getOccasionField(): array
146 {
147 return [
148 [
149 'id' => 12,
150 'fieldIndex' => 4,
151 'type' => 'select',
152 'label' => BackendStrings::getTemplateStrings()['occasion'],
153 'placeholder' => BackendStrings::getTemplateStrings()['select_the_occasion'],
154 'required' => true,
155 'parentId' => null,
156 'defaultValue' => '',
157 'position' => 4,
158 'fieldOptions' => [
159 [
160 'id' => 6,
161 'label' => BackendStrings::getTemplateStrings()['birthday'],
162 'value' => 'birthday',
163 'isDefault' => false,
164 'position' => 1
165 ],
166 [
167 'id' => 7,
168 'label' => BackendStrings::getTemplateStrings()['wedding'],
169 'value' => 'wedding',
170 'isDefault' => false,
171 'position' => 2
172 ],
173 [
174 'id' => 8,
175 'label' => BackendStrings::getTemplateStrings()['anniversary'],
176 'value' => 'anniversary',
177 'isDefault' => false,
178 'position' => 3
179 ],
180 [
181 'id' => 9,
182 'label' => BackendStrings::getTemplateStrings()['baby_shower'],
183 'value' => 'baby_shower',
184 'isDefault' => false,
185 'position' => 4
186 ],
187 [
188 'id' => 10,
189 'label' => BackendStrings::getTemplateStrings()['graduation'],
190 'value' => 'graduation',
191 'isDefault' => false,
192 'position' => 5
193 ],
194 [
195 'id' => 11,
196 'label' => BackendStrings::getTemplateStrings()['other'],
197 'value' => 'other',
198 'isDefault' => false,
199 'position' => 6
200 ],
201 ]
202 ],
203 ];
204 }
205
206 /**
207 * Get cake flavor field
208 *
209 * @return array<int, array<string, mixed>>
210 */
211 private static function getCakeFlavorField(): array
212 {
213 return [
214 [
215 'id' => 19,
216 'fieldIndex' => 5,
217 'type' => 'select',
218 'label' => BackendStrings::getTemplateStrings()['cake_flavor'],
219 'placeholder' => BackendStrings::getTemplateStrings()['choose_cake_flavor'],
220 'required' => true,
221 'parentId' => null,
222 'defaultValue' => '',
223 'position' => 5,
224 'fieldOptions' => [
225 [
226 'id' => 13,
227 'label' => BackendStrings::getTemplateStrings()['chocolate'],
228 'value' => 'chocolate',
229 'isDefault' => false,
230 'position' => 1
231 ],
232 [
233 'id' => 14,
234 'label' => BackendStrings::getTemplateStrings()['vanilla'],
235 'value' => 'vanilla',
236 'isDefault' => false,
237 'position' => 2
238 ],
239 [
240 'id' => 15,
241 'label' => BackendStrings::getTemplateStrings()['red_velvet'],
242 'value' => 'red_velvet',
243 'isDefault' => false,
244 'position' => 3
245 ],
246 [
247 'id' => 16,
248 'label' => BackendStrings::getTemplateStrings()['lemon'],
249 'value' => 'lemon',
250 'isDefault' => false,
251 'position' => 4
252 ],
253 [
254 'id' => 17,
255 'label' => BackendStrings::getTemplateStrings()['marble'],
256 'value' => 'marble',
257 'isDefault' => false,
258 'position' => 5
259 ],
260 [
261 'id' => 18,
262 'label' => BackendStrings::getTemplateStrings()['other'],
263 'value' => 'other',
264 'isDefault' => false,
265 'position' => 6
266 ],
267 ]
268 ],
269 ];
270 }
271
272 /**
273 * Get cake size field
274 *
275 * @return array<int, array<string, mixed>>
276 */
277 private static function getCakeSizeField(): array
278 {
279 return [
280 [
281 'id' => 24,
282 'fieldIndex' => 6,
283 'type' => 'select',
284 'label' => BackendStrings::getTemplateStrings()['cake_size'],
285 'placeholder' => BackendStrings::getTemplateStrings()['select_cake_size'],
286 'required' => true,
287 'parentId' => null,
288 'defaultValue' => '',
289 'position' => 6,
290 'fieldOptions' => [
291 [
292 'id' => 20,
293 'label' => BackendStrings::getTemplateStrings()['6_inch_serves_8'],
294 'value' => '6_inch',
295 'isDefault' => false,
296 'position' => 1
297 ],
298 [
299 'id' => 21,
300 'label' => BackendStrings::getTemplateStrings()['8_inch_serves_12'],
301 'value' => '8_inch',
302 'isDefault' => false,
303 'position' => 2
304 ],
305 [
306 'id' => 22,
307 'label' => BackendStrings::getTemplateStrings()['10_inch_serves_20'],
308 'value' => '10_inch',
309 'isDefault' => false,
310 'position' => 3
311 ],
312 [
313 'id' => 23,
314 'label' => BackendStrings::getTemplateStrings()['tiered_custom_size'],
315 'value' => 'tiered_custom',
316 'isDefault' => false,
317 'position' => 4
318 ],
319 ]
320 ],
321 ];
322 }
323
324 /**
325 * Get design inspiration field
326 *
327 * @return array<int, array<string, mixed>>
328 */
329 private static function getDesignInspirationField(): array
330 {
331 return [
332 [
333 'id' => 25,
334 'fieldIndex' => 7,
335 'type' => 'website',
336 'label' => BackendStrings::getTemplateStrings()['design_inspiration_link'],
337 'placeholder' => BackendStrings::getTemplateStrings()['paste_link_design_inspiration'],
338 'required' => false,
339 'parentId' => null,
340 'defaultValue' => '',
341 'position' => 7,
342 ],
343 ];
344 }
345
346 /**
347 * Get cake message field
348 *
349 * @return array<int, array<string, mixed>>
350 */
351 private static function getCakeMessageField(): array
352 {
353 return [
354 [
355 'id' => 26,
356 'fieldIndex' => 8,
357 'type' => 'text',
358 'label' => BackendStrings::getTemplateStrings()['cake_message'],
359 'placeholder' => BackendStrings::getTemplateStrings()['enter_short_message_for_cake'],
360 'required' => false,
361 'parentId' => null,
362 'defaultValue' => '',
363 'position' => 8,
364 ],
365 ];
366 }
367
368 /**
369 * Get delivery details fields
370 *
371 * @return array<int, array<string, mixed>>
372 */
373 private static function getDeliveryDetailsFields(): array
374 {
375 return [
376 // Delivery Date
377 [
378 'id' => 27,
379 'fieldIndex' => 9,
380 'type' => 'date',
381 'label' => BackendStrings::getTemplateStrings()['delivery_date'],
382 'placeholder' => BackendStrings::getTemplateStrings()['select_delivery_date'],
383 'required' => true,
384 'parentId' => null,
385 'defaultValue' => '',
386 'position' => 9,
387 'dateFieldType' => 'picker',
388 'dateFormat' => 'MM/DD/YYYY',
389 ],
390 // Additional Notes
391 [
392 'id' => 28,
393 'fieldIndex' => 10,
394 'type' => 'textarea',
395 'label' => BackendStrings::getTemplateStrings()['additional_notes'],
396 'placeholder' => BackendStrings::getTemplateStrings()['write_additional_instructions_or_preferences'],
397 'parentId' => null,
398 'defaultValue' => '',
399 'position' => 10,
400 'required' => false,
401 'rows' => 3,
402 ],
403 ];
404 }
405 }
406