← All changes
|
backend/src/Services/Template/WeddingCakeOrderFormTemplate.php
+74
-52
0.8
→
1.5
View file →
| @@ -1,23 +1,18 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace IvyForms\Services\Template; |
| 4 | 4 | |
| 5 | -// phpcs:disable PSR1.Files.SideEffects | |
| 6 | -if (!defined('ABSPATH')) { | |
| 7 | - exit; // Exit if accessed directly | |
| 8 | -} | |
| 9 | - | |
| 10 | 5 | use IvyForms\Services\Translations\BackendStrings; |
| 11 | 6 | |
| 12 | 7 | class WeddingCakeOrderFormTemplate |
| 13 | 8 | { |
| 14 | 9 | /** |
| 15 | - * Get the wedding cake order form template | |
| 10 | + * Get template metadata (without form_data) | |
| 16 | 11 | * |
| 17 | 12 | * @return array<string, mixed> |
| 18 | 13 | */ |
| 19 | - public static function getTemplate(): array | |
| 14 | + public static function getTemplateMeta(): array | |
| 20 | 15 | { |
| 21 | 16 | return [ |
| 22 | 17 | 'id' => 'wedding_cake_order_form', |
| 23 | 18 | 'name' => BackendStrings::getTemplateStrings()['wedding_cake_order_form'], |
| @@ -22,10 +17,24 @@ | ||
| 22 | 17 | 'id' => 'wedding_cake_order_form', |
| 23 | 18 | 'name' => BackendStrings::getTemplateStrings()['wedding_cake_order_form'], |
| 24 | 19 | 'description' => BackendStrings::getTemplateStrings()['wedding_cake_order_form_desc'], |
| 25 | 20 | 'category' => 'order-forms', |
| 21 | + 'subcategory' => 'cake-order-forms', | |
| 26 | 22 | 'is_pro' => false, |
| 27 | - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'wedding-cake-order-form.svg', | |
| 23 | + 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'wedding-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 | + [ | |
| 28 | 37 | 'form_data' => [ |
| 29 | 38 | 'name' => BackendStrings::getTemplateStrings()['wedding_cake_order_form'], |
| 30 | 39 | 'published' => 1, |
| 31 | 40 | 'showTitle' => 1, |
| @@ -37,9 +46,10 @@ | ||
| 37 | 46 | self::getDeliveryDetailsFields() |
| 38 | 47 | ), |
| 39 | 48 | 'settings' => [] |
| 40 | 49 | ] |
| 41 | - ]; | |
| 50 | + ] | |
| 51 | + ); | |
| 42 | 52 | } |
| 43 | 53 | |
| 44 | 54 | /** |
| 45 | 55 | * Get customer information fields |
| @@ -50,9 +60,9 @@ | ||
| 50 | 60 | { |
| 51 | 61 | return [ |
| 52 | 62 | // Bride & Groom Names - Parent |
| 53 | 63 | [ |
| 54 | - 'id' => 0, | |
| 64 | + 'id' => 1, | |
| 55 | 65 | 'fieldIndex' => 1, |
| 56 | 66 | 'type' => 'name', |
| 57 | 67 | 'label' => BackendStrings::getTemplateStrings()['bride_groom_names'], |
| 58 | 68 | 'parentId' => null, |
| @@ -63,14 +73,14 @@ | ||
| 63 | 73 | 'position' => 1, |
| 64 | 74 | ], |
| 65 | 75 | // First Name - Child of Name Field |
| 66 | 76 | [ |
| 67 | - 'id' => 0, | |
| 77 | + 'id' => 2, | |
| 68 | 78 | 'type' => 'text', |
| 69 | 79 | 'label' => BackendStrings::getNewFormStrings()['first_name'], |
| 70 | 80 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_couple_names'], |
| 71 | 81 | 'required' => true, |
| 72 | - 'parentId' => 0, | |
| 82 | + 'parentId' => 1, | |
| 73 | 83 | 'fieldIndex' => 1, |
| 74 | 84 | 'defaultValue' => '', |
| 75 | 85 | 'position' => 1, |
| 76 | 86 | 'optionHide' => false, |
| @@ -78,14 +88,14 @@ | ||
| 78 | 88 | 'settings' => json_encode(['nameFieldType' => 'nameField1']), |
| 79 | 89 | ], |
| 80 | 90 | // Last Name - Child of Name Field |
| 81 | 91 | [ |
| 82 | - 'id' => 0, | |
| 92 | + 'id' => 3, | |
| 83 | 93 | 'type' => 'text', |
| 84 | 94 | 'label' => BackendStrings::getNewFormStrings()['last_name'], |
| 85 | 95 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_couple_lastnames'], |
| 86 | 96 | 'required' => true, |
| 87 | - 'parentId' => 0, | |
| 97 | + 'parentId' => 1, | |
| 88 | 98 | 'fieldIndex' => 1, |
| 89 | 99 | 'defaultValue' => '', |
| 90 | 100 | 'position' => 2, |
| 91 | 101 | 'optionHide' => false, |
| @@ -93,9 +103,9 @@ | ||
| 93 | 103 | 'settings' => json_encode(['nameFieldType' => 'nameField2']), |
| 94 | 104 | ], |
| 95 | 105 | // Email Address |
| 96 | 106 | [ |
| 97 | - 'id' => 0, | |
| 107 | + 'id' => 4, | |
| 98 | 108 | 'fieldIndex' => 2, |
| 99 | 109 | 'type' => 'email', |
| 100 | 110 | 'label' => BackendStrings::getTemplateStrings()['email_address'], |
| 101 | 111 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_email'], |
| @@ -105,9 +115,9 @@ | ||
| 105 | 115 | 'position' => 2, |
| 106 | 116 | ], |
| 107 | 117 | // Phone Number |
| 108 | 118 | [ |
| 109 | - 'id' => 0, | |
| 119 | + 'id' => 5, | |
| 110 | 120 | 'fieldIndex' => 3, |
| 111 | 121 | 'type' => 'phone', |
| 112 | 122 | 'label' => BackendStrings::getTemplateStrings()['phone_number'], |
| 113 | 123 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_phone_number'], |
| @@ -146,9 +156,9 @@ | ||
| 146 | 156 | private static function getWeddingDateField(): array |
| 147 | 157 | { |
| 148 | 158 | return [ |
| 149 | 159 | [ |
| 150 | - 'id' => 0, | |
| 160 | + 'id' => 6, | |
| 151 | 161 | 'fieldIndex' => 4, |
| 152 | 162 | 'type' => 'date', |
| 153 | 163 | 'label' => BackendStrings::getTemplateStrings()['wedding_date'], |
| 154 | 164 | 'placeholder' => BackendStrings::getTemplateStrings()['select_wedding_date'], |
| @@ -170,9 +180,9 @@ | ||
| 170 | 180 | private static function getGuestCountField(): array |
| 171 | 181 | { |
| 172 | 182 | return [ |
| 173 | 183 | [ |
| 174 | - 'id' => 0, | |
| 184 | + 'id' => 7, | |
| 175 | 185 | 'fieldIndex' => 5, |
| 176 | 186 | 'type' => 'number', |
| 177 | 187 | 'label' => BackendStrings::getTemplateStrings()['number_of_guests'], |
| 178 | 188 | 'placeholder' => BackendStrings::getTemplateStrings()['eg_150'], |
| @@ -193,9 +203,9 @@ | ||
| 193 | 203 | private static function getCakeFlavorField(): array |
| 194 | 204 | { |
| 195 | 205 | return [ |
| 196 | 206 | [ |
| 197 | - 'id' => 0, | |
| 207 | + 'id' => 13, | |
| 198 | 208 | 'fieldIndex' => 6, |
| 199 | 209 | 'type' => 'select', |
| 200 | 210 | 'label' => BackendStrings::getTemplateStrings()['cake_flavors'], |
| 201 | 211 | 'placeholder' => BackendStrings::getTemplateStrings()['select_cake_flavors'], |
| @@ -205,9 +215,9 @@ | ||
| 205 | 215 | 'position' => 6, |
| 206 | 216 | 'multiple' => true, |
| 207 | 217 | 'fieldOptions' => [ |
| 208 | 218 | [ |
| 209 | - 'id' => 0, | |
| 219 | + 'id' => 8, | |
| 210 | 220 | 'label' => BackendStrings::getTemplateStrings()['chocolate'], |
| 211 | 221 | 'value' => 'chocolate', |
| 212 | 222 | 'isDefault' => false, |
| 213 | 223 | 'position' => 1 |
| @@ -212,9 +222,9 @@ | ||
| 212 | 222 | 'isDefault' => false, |
| 213 | 223 | 'position' => 1 |
| 214 | 224 | ], |
| 215 | 225 | [ |
| 216 | - 'id' => 0, | |
| 226 | + 'id' => 9, | |
| 217 | 227 | 'label' => BackendStrings::getTemplateStrings()['vanilla'], |
| 218 | 228 | 'value' => 'vanilla', |
| 219 | 229 | 'isDefault' => false, |
| 220 | 230 | 'position' => 2 |
| @@ -219,9 +229,9 @@ | ||
| 219 | 229 | 'isDefault' => false, |
| 220 | 230 | 'position' => 2 |
| 221 | 231 | ], |
| 222 | 232 | [ |
| 223 | - 'id' => 0, | |
| 233 | + 'id' => 10, | |
| 224 | 234 | 'label' => BackendStrings::getTemplateStrings()['red_velvet'], |
| 225 | 235 | 'value' => 'red_velvet', |
| 226 | 236 | 'isDefault' => false, |
| 227 | 237 | 'position' => 3 |
| @@ -226,9 +236,9 @@ | ||
| 226 | 236 | 'isDefault' => false, |
| 227 | 237 | 'position' => 3 |
| 228 | 238 | ], |
| 229 | 239 | [ |
| 230 | - 'id' => 0, | |
| 240 | + 'id' => 11, | |
| 231 | 241 | 'label' => BackendStrings::getTemplateStrings()['lemon'], |
| 232 | 242 | 'value' => 'lemon', |
| 233 | 243 | 'isDefault' => false, |
| 234 | 244 | 'position' => 4 |
| @@ -233,9 +243,9 @@ | ||
| 233 | 243 | 'isDefault' => false, |
| 234 | 244 | 'position' => 4 |
| 235 | 245 | ], |
| 236 | 246 | [ |
| 237 | - 'id' => 0, | |
| 247 | + 'id' => 12, | |
| 238 | 248 | 'label' => BackendStrings::getTemplateStrings()['custom'], |
| 239 | 249 | 'value' => 'custom', |
| 240 | 250 | 'isDefault' => false, |
| 241 | 251 | 'position' => 5 |
| @@ -253,9 +263,9 @@ | ||
| 253 | 263 | private static function getNumberOfTiersField(): array |
| 254 | 264 | { |
| 255 | 265 | return [ |
| 256 | 266 | [ |
| 257 | - 'id' => 0, | |
| 267 | + 'id' => 14, | |
| 258 | 268 | 'fieldIndex' => 7, |
| 259 | 269 | 'type' => 'number', |
| 260 | 270 | 'label' => BackendStrings::getTemplateStrings()['number_of_tiers'], |
| 261 | 271 | 'placeholder' => BackendStrings::getTemplateStrings()['eg_3'], |
| @@ -276,9 +286,9 @@ | ||
| 276 | 286 | private static function getCakeStyleThemeField(): array |
| 277 | 287 | { |
| 278 | 288 | return [ |
| 279 | 289 | [ |
| 280 | - 'id' => 0, | |
| 290 | + 'id' => 15, | |
| 281 | 291 | 'fieldIndex' => 8, |
| 282 | 292 | 'type' => 'textarea', |
| 283 | 293 | 'label' => BackendStrings::getTemplateStrings()['preferred_cake_style_theme'], |
| 284 | 294 | 'placeholder' => BackendStrings::getTemplateStrings()['describe_theme_eg'], |
| @@ -300,9 +310,9 @@ | ||
| 300 | 310 | { |
| 301 | 311 | return [ |
| 302 | 312 | // Address Field - Parent |
| 303 | 313 | [ |
| 304 | - 'id' => 0, | |
| 314 | + 'id' => 16, | |
| 305 | 315 | 'fieldIndex' => 9, |
| 306 | 316 | 'type' => 'address', |
| 307 | 317 | 'label' => BackendStrings::getTemplateStrings()['venue_address'], |
| 308 | 318 | 'parentId' => null, |
| @@ -313,14 +323,14 @@ | ||
| 313 | 323 | 'required' => true, |
| 314 | 324 | ], |
| 315 | 325 | // Street Address - Child of Address Field |
| 316 | 326 | [ |
| 317 | - 'id' => 0, | |
| 327 | + 'id' => 18, | |
| 318 | 328 | 'type' => 'text', |
| 319 | 329 | 'label' => BackendStrings::getTemplateStrings()['address_line_1'], |
| 320 | 330 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'], |
| 321 | 331 | 'required' => true, |
| 322 | - 'parentId' => 0, | |
| 332 | + 'parentId' => 9, | |
| 323 | 333 | 'fieldIndex' => 9, |
| 324 | 334 | 'defaultValue' => '', |
| 325 | 335 | 'position' => 9, |
| 326 | 336 | 'hideLabel' => false, |
| @@ -325,9 +335,10 @@ | ||
| 325 | 335 | 'position' => 9, |
| 326 | 336 | 'hideLabel' => false, |
| 327 | 337 | 'description' => '', |
| 328 | 338 | 'addressType' => 'streetAddress', |
| 329 | - 'settings' => json_encode([ | |
| 339 | + 'settings' => json_encode( | |
| 340 | + [ | |
| 330 | 341 | 'type' => 'streetAddress', |
| 331 | 342 | 'hideLabel' => false, |
| 332 | 343 | 'description' => '', |
| 333 | 344 | 'placeholder' => BackendStrings::getTemplateStrings()['address_line_1'], |
| @@ -332,18 +343,19 @@ | ||
| 332 | 343 | 'description' => '', |
| 333 | 344 | 'placeholder' => BackendStrings::getTemplateStrings()['address_line_1'], |
| 334 | 345 | 'requiredMessage' => '', |
| 335 | 346 | 'visible' => true |
| 336 | - ]), | |
| 347 | + ] | |
| 348 | + ), | |
| 337 | 349 | ], |
| 338 | 350 | // Address Line 2 - Child of Address Field |
| 339 | 351 | [ |
| 340 | - 'id' => 0, | |
| 352 | + 'id' => 20, | |
| 341 | 353 | 'type' => 'text', |
| 342 | 354 | 'label' => BackendStrings::getTemplateStrings()['address_line_2'], |
| 343 | 355 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'], |
| 344 | 356 | 'required' => false, |
| 345 | - 'parentId' => 0, | |
| 357 | + 'parentId' => 9, | |
| 346 | 358 | 'fieldIndex' => 9, |
| 347 | 359 | 'defaultValue' => '', |
| 348 | 360 | 'position' => 9, |
| 349 | 361 | 'hideLabel' => false, |
| @@ -348,9 +360,10 @@ | ||
| 348 | 360 | 'position' => 9, |
| 349 | 361 | 'hideLabel' => false, |
| 350 | 362 | 'description' => '', |
| 351 | 363 | 'addressType' => 'addressLine2', |
| 352 | - 'settings' => json_encode([ | |
| 364 | + 'settings' => json_encode( | |
| 365 | + [ | |
| 353 | 366 | 'type' => 'addressLine2', |
| 354 | 367 | 'hideLabel' => false, |
| 355 | 368 | 'description' => '', |
| 356 | 369 | 'placeholder' => BackendStrings::getTemplateStrings()['address_line_2'], |
| @@ -355,18 +368,19 @@ | ||
| 355 | 368 | 'description' => '', |
| 356 | 369 | 'placeholder' => BackendStrings::getTemplateStrings()['address_line_2'], |
| 357 | 370 | 'requiredMessage' => '', |
| 358 | 371 | 'visible' => true |
| 359 | - ]), | |
| 372 | + ] | |
| 373 | + ), | |
| 360 | 374 | ], |
| 361 | 375 | // City - Child of Address Field |
| 362 | 376 | [ |
| 363 | - 'id' => 0, | |
| 377 | + 'id' => 22, | |
| 364 | 378 | 'type' => 'text', |
| 365 | 379 | 'label' => BackendStrings::getTemplateStrings()['city'], |
| 366 | 380 | 'placeholder' => BackendStrings::getTemplateStrings()['city'], |
| 367 | 381 | 'required' => true, |
| 368 | - 'parentId' => 0, | |
| 382 | + 'parentId' => 9, | |
| 369 | 383 | 'fieldIndex' => 9, |
| 370 | 384 | 'defaultValue' => '', |
| 371 | 385 | 'position' => 9, |
| 372 | 386 | 'hideLabel' => false, |
| @@ -371,9 +385,10 @@ | ||
| 371 | 385 | 'position' => 9, |
| 372 | 386 | 'hideLabel' => false, |
| 373 | 387 | 'description' => '', |
| 374 | 388 | 'addressType' => 'city', |
| 375 | - 'settings' => json_encode([ | |
| 389 | + 'settings' => json_encode( | |
| 390 | + [ | |
| 376 | 391 | 'type' => 'city', |
| 377 | 392 | 'hideLabel' => false, |
| 378 | 393 | 'description' => '', |
| 379 | 394 | 'placeholder' => BackendStrings::getTemplateStrings()['city'], |
| @@ -378,18 +393,19 @@ | ||
| 378 | 393 | 'description' => '', |
| 379 | 394 | 'placeholder' => BackendStrings::getTemplateStrings()['city'], |
| 380 | 395 | 'requiredMessage' => '', |
| 381 | 396 | 'visible' => true |
| 382 | - ]), | |
| 397 | + ] | |
| 398 | + ), | |
| 383 | 399 | ], |
| 384 | 400 | // State/Province - Child of Address Field |
| 385 | 401 | [ |
| 386 | - 'id' => 0, | |
| 402 | + 'id' => 24, | |
| 387 | 403 | 'type' => 'text', |
| 388 | 404 | 'label' => BackendStrings::getTemplateStrings()['state_province'], |
| 389 | 405 | 'placeholder' => BackendStrings::getTemplateStrings()['state'], |
| 390 | 406 | 'required' => true, |
| 391 | - 'parentId' => 0, | |
| 407 | + 'parentId' => 9, | |
| 392 | 408 | 'fieldIndex' => 9, |
| 393 | 409 | 'defaultValue' => '', |
| 394 | 410 | 'position' => 9, |
| 395 | 411 | 'hideLabel' => false, |
| @@ -394,9 +410,10 @@ | ||
| 394 | 410 | 'position' => 9, |
| 395 | 411 | 'hideLabel' => false, |
| 396 | 412 | 'description' => '', |
| 397 | 413 | 'addressType' => 'state', |
| 398 | - 'settings' => json_encode([ | |
| 414 | + 'settings' => json_encode( | |
| 415 | + [ | |
| 399 | 416 | 'type' => 'state', |
| 400 | 417 | 'hideLabel' => false, |
| 401 | 418 | 'description' => '', |
| 402 | 419 | 'placeholder' => BackendStrings::getTemplateStrings()['state'], |
| @@ -401,18 +418,19 @@ | ||
| 401 | 418 | 'description' => '', |
| 402 | 419 | 'placeholder' => BackendStrings::getTemplateStrings()['state'], |
| 403 | 420 | 'requiredMessage' => '', |
| 404 | 421 | 'visible' => true |
| 405 | - ]), | |
| 422 | + ] | |
| 423 | + ), | |
| 406 | 424 | ], |
| 407 | 425 | // Zip/Postal Code - Child of Address Field |
| 408 | 426 | [ |
| 409 | - 'id' => 0, | |
| 427 | + 'id' => 26, | |
| 410 | 428 | 'type' => 'text', |
| 411 | 429 | 'label' => BackendStrings::getTemplateStrings()['zip_postal_code'], |
| 412 | 430 | 'placeholder' => BackendStrings::getTemplateStrings()['zip'], |
| 413 | 431 | 'required' => true, |
| 414 | - 'parentId' => 0, | |
| 432 | + 'parentId' => 9, | |
| 415 | 433 | 'fieldIndex' => 9, |
| 416 | 434 | 'defaultValue' => '', |
| 417 | 435 | 'position' => 9, |
| 418 | 436 | 'hideLabel' => false, |
| @@ -417,9 +435,10 @@ | ||
| 417 | 435 | 'position' => 9, |
| 418 | 436 | 'hideLabel' => false, |
| 419 | 437 | 'description' => '', |
| 420 | 438 | 'addressType' => 'zip', |
| 421 | - 'settings' => json_encode([ | |
| 439 | + 'settings' => json_encode( | |
| 440 | + [ | |
| 422 | 441 | 'type' => 'zip', |
| 423 | 442 | 'hideLabel' => false, |
| 424 | 443 | 'description' => '', |
| 425 | 444 | 'placeholder' => BackendStrings::getTemplateStrings()['zip'], |
| @@ -424,18 +443,19 @@ | ||
| 424 | 443 | 'description' => '', |
| 425 | 444 | 'placeholder' => BackendStrings::getTemplateStrings()['zip'], |
| 426 | 445 | 'requiredMessage' => '', |
| 427 | 446 | 'visible' => true |
| 428 | - ]), | |
| 447 | + ] | |
| 448 | + ), | |
| 429 | 449 | ], |
| 430 | 450 | // Country - Child of Address Field |
| 431 | 451 | [ |
| 432 | - 'id' => 0, | |
| 452 | + 'id' => 28, | |
| 433 | 453 | 'type' => 'text', |
| 434 | 454 | 'label' => BackendStrings::getTemplateStrings()['country'], |
| 435 | 455 | 'placeholder' => BackendStrings::getTemplateStrings()['select_country'], |
| 436 | 456 | 'required' => true, |
| 437 | - 'parentId' => 0, | |
| 457 | + 'parentId' => 9, | |
| 438 | 458 | 'fieldIndex' => 9, |
| 439 | 459 | 'defaultValue' => '', |
| 440 | 460 | 'position' => 9, |
| 441 | 461 | 'hideLabel' => false, |
| @@ -440,9 +460,10 @@ | ||
| 440 | 460 | 'position' => 9, |
| 441 | 461 | 'hideLabel' => false, |
| 442 | 462 | 'description' => '', |
| 443 | 463 | 'addressType' => 'country', |
| 444 | - 'settings' => json_encode([ | |
| 464 | + 'settings' => json_encode( | |
| 465 | + [ | |
| 445 | 466 | 'type' => 'country', |
| 446 | 467 | 'hideLabel' => false, |
| 447 | 468 | 'description' => '', |
| 448 | 469 | 'placeholder' => BackendStrings::getTemplateStrings()['select_country'], |
| @@ -447,9 +468,10 @@ | ||
| 447 | 468 | 'description' => '', |
| 448 | 469 | 'placeholder' => BackendStrings::getTemplateStrings()['select_country'], |
| 449 | 470 | 'requiredMessage' => '', |
| 450 | 471 | 'visible' => true |
| 451 | - ]), | |
| 472 | + ] | |
| 473 | + ), | |
| 452 | 474 | ], |
| 453 | 475 | ]; |
| 454 | 476 | } |
| 455 | 477 | |
| @@ -461,9 +483,9 @@ | ||
| 461 | 483 | private static function getAdditionalRequestsField(): array |
| 462 | 484 | { |
| 463 | 485 | return [ |
| 464 | 486 | [ |
| 465 | - 'id' => 0, | |
| 487 | + 'id' => 29, | |
| 466 | 488 | 'fieldIndex' => 10, |
| 467 | 489 | 'type' => 'textarea', |
| 468 | 490 | 'label' => BackendStrings::getTemplateStrings()['additional_requests'], |
| 469 | 491 | 'placeholder' => BackendStrings::getTemplateStrings()['any_special_instructions_or_details'], |