PluginProbe
The Innovative Form Builder – IvyForms / 1.5.1
The Innovative Form Builder – IvyForms v1.5.1
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 / PostPurchaseFeedbackFormTemplate.php

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

286 lines 9.0 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 PostPurchaseFeedbackFormTemplate
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' => 'post_purchase_feedback_form',
18 'name' => BackendStrings::getTemplateStrings()['post_purchase_feedback_form'],
19 'description' => BackendStrings::getTemplateStrings()['post_purchase_feedback_form_desc'],
20 'category' => 'feedback-forms',
21 'subcategory' => 'customer-feedback-forms',
22 'is_pro' => false,
23 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'post-purchase-feedback-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()['post_purchase_feedback_form'],
39 'published' => 1,
40 'showTitle' => 1,
41 'storeEntries' => 1,
42 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
43 'fields' => array_merge(
44 self::getOrderNumberField(),
45 self::getDeliveryStatusField(),
46 self::getCheckoutRatingField(),
47 self::getDeliveryRatingField(),
48 self::getInfluencedPurchaseCheckboxField(),
49 self::getAdditionalCommentsTextareaField()
50 ),
51 'settings' => []
52 ]
53 ]
54 );
55 }
56
57 /**
58 * Order number (optional)
59 *
60 * @return array<int, array<string, mixed>>
61 */
62 private static function getOrderNumberField(): array
63 {
64 return [[
65 'id' => 1,
66 'fieldIndex' => 1,
67 'type' => 'number',
68 'label' => BackendStrings::getTemplateStrings()['order_number'],
69 'placeholder' => 'e.g. 123456',
70 'required' => false,
71 'parentId' => null,
72 'defaultValue' => '',
73 'position' => 1,
74 ]];
75 }
76
77 /**
78 * Delivery status (radio, required)
79 *
80 * @return array<int, array<string, mixed>>
81 */
82 private static function getDeliveryStatusField(): array
83 {
84 return [[
85 'id' => 5,
86 'fieldIndex' => 2,
87 'type' => 'radio',
88 'label' => BackendStrings::getTemplateStrings()['delivery_status'],
89 'required' => true,
90 'parentId' => null,
91 'defaultValue' => '',
92 'placeholder' => '',
93 'position' => 2,
94 'fieldOptions' => [
95 [
96 'label' => BackendStrings::getTemplateStrings()['delivered_on_time'],
97 'value' => 'delivered_on_time',
98 'position' => 1,
99 ],
100 [
101 'label' => BackendStrings::getTemplateStrings()['slightly_delayed'],
102 'value' => 'slightly_delayed',
103 'position' => 2,
104 ],
105 [
106 'label' => BackendStrings::getTemplateStrings()['significantly_delayed'],
107 'value' => 'significantly_delayed',
108 'position' => 3,
109 ],
110 ]
111 ]];
112 }
113
114 /**
115 * Checkout experience rating (required)
116 *
117 * @return array<int, array<string, mixed>>
118 */
119 private static function getCheckoutRatingField(): array
120 {
121 return [[
122 'id' => 6,
123 'fieldIndex' => 3,
124 'type' => 'rating',
125 'label' => BackendStrings::getTemplateStrings()['checkout_experience'],
126 'required' => true,
127 'defaultValue' => '',
128 'placeholder' => '',
129 'position' => 3,
130 'labelPosition' => 'default',
131 'ratingIcon' => 'star',
132 'fieldOptions' => self::getStandardRatingOptions(1),
133 'showValues' => false,
134 'showRatingText' => true,
135 ]];
136 }
137
138 /**
139 * Delivery experience rating (required)
140 *
141 * @return array<int, array<string, mixed>>
142 */
143 private static function getDeliveryRatingField(): array
144 {
145 return [[
146 'id' => 7,
147 'fieldIndex' => 4,
148 'type' => 'rating',
149 'label' => BackendStrings::getTemplateStrings()['delivery_experience'],
150 'required' => true,
151 'defaultValue' => '',
152 'placeholder' => '',
153 'position' => 4,
154 'labelPosition' => 'default',
155 'ratingIcon' => 'star',
156 'fieldOptions' => self::getStandardRatingOptions(6),
157 'showValues' => false,
158 'showRatingText' => true,
159 ]];
160 }
161
162 /**
163 * What influenced your purchase experience? (checkbox, optional)
164 *
165 * @return array<int, array<string, mixed>>
166 */
167 private static function getInfluencedPurchaseCheckboxField(): array
168 {
169 return [[
170 'id' => 13,
171 'fieldIndex' => 5,
172 'type' => 'checkbox',
173 'label' => BackendStrings::getTemplateStrings()['what_influenced_purchase_experience'],
174 'required' => false,
175 'parentId' => null,
176 'defaultValue' => '',
177 'placeholder' => '',
178 'position' => 5,
179 'fieldOptions' => [
180 [
181 'id' => 8,
182 'label' => BackendStrings::getTemplateStrings()['pricing'],
183 'value' => 'pricing',
184 'isDefault' => false,
185 'position' => 1,
186 ],
187 [
188 'id' => 9,
189 'label' => BackendStrings::getTemplateStrings()['payment_options'],
190 'value' => 'payment_options',
191 'isDefault' => false,
192 'position' => 2,
193 ],
194 [
195 'id' => 10,
196 'label' => BackendStrings::getTemplateStrings()['shipping_cost'],
197 'value' => 'shipping_cost',
198 'isDefault' => false,
199 'position' => 3,
200 ],
201 [
202 'id' => 11,
203 'label' => BackendStrings::getTemplateStrings()['delivery_speed'],
204 'value' => 'delivery_speed',
205 'isDefault' => false,
206 'position' => 4,
207 ],
208 [
209 'id' => 12,
210 'label' => BackendStrings::getTemplateStrings()['packaging'],
211 'value' => 'packaging',
212 'isDefault' => false,
213 'position' => 5,
214 ],
215 ]
216 ]];
217 }
218
219 /**
220 * Additional comments (optional)
221 *
222 * @return array<int, array<string, mixed>>
223 */
224 private static function getAdditionalCommentsTextareaField(): array
225 {
226 return [[
227 'id' => 14,
228 'fieldIndex' => 6,
229 'type' => 'textarea',
230 'label' => BackendStrings::getTemplateStrings()['additional_comments'],
231 'placeholder' => BackendStrings::getTemplateStrings()['additional_comments_placeholder'],
232 'required' => false,
233 'parentId' => null,
234 'defaultValue' => '',
235 'position' => 6,
236 'labelPosition' => 'default',
237 ]];
238 }
239
240 /**
241 * Standard rating options (1-5)
242 *
243 * @return array<int, array<string, mixed>>
244 */
245 private static function getStandardRatingOptions(int $startId): array
246 {
247 return [
248 [
249 'id' => $startId,
250 'label' => BackendStrings::getNewFormStrings()['good'],
251 'value' => '1',
252 'isDefault' => false,
253 'position' => 1,
254 ],
255 [
256 'id' => $startId + 1,
257 'label' => BackendStrings::getNewFormStrings()['nice'],
258 'value' => '2',
259 'isDefault' => false,
260 'position' => 2,
261 ],
262 [
263 'id' => $startId + 2,
264 'label' => BackendStrings::getNewFormStrings()['very_good'],
265 'value' => '3',
266 'isDefault' => false,
267 'position' => 3,
268 ],
269 [
270 'id' => $startId + 3,
271 'label' => BackendStrings::getNewFormStrings()['awesome'],
272 'value' => '4',
273 'isDefault' => false,
274 'position' => 4,
275 ],
276 [
277 'id' => $startId + 4,
278 'label' => BackendStrings::getNewFormStrings()['amazing'],
279 'value' => '5',
280 'isDefault' => false,
281 'position' => 5,
282 ],
283 ];
284 }
285 }
286