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

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