PluginProbe
The Innovative Form Builder – IvyForms / 0.9.1
The Innovative Form Builder – IvyForms v0.9.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 0.9.1, at backend/src/Services/Template/PostPurchaseFeedbackFormTemplate.php

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