PluginProbe
The Innovative Form Builder – IvyForms / 0.8
The Innovative Form Builder – IvyForms v0.8
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 1.2 1.3
ivyforms / backend / src / Services / Template / CustomCakeOrderFormTemplate.php

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

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