PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.1.2
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.1.2
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / modules / bricks / elements / class-cartflows-bricks-order-details-form.php

class-cartflows-bricks-order-details-form.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.1.2, at modules/bricks/elements/class-cartflows-bricks-order-details-form.php

590 lines 18.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Bricks Classes.
4 *
5 * @package cartflows
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * Order Details Form Widget
14 *
15 * @since 1.6.15
16 */
17 class Cartflows_Bricks_Order_Details_Form extends \Bricks\Element {
18 /**
19 * Category of the element.
20 *
21 * @var instance
22 */
23 public $category = 'CartFlows';
24
25 /**
26 * Name of the element.
27 *
28 * @var instance
29 */
30
31 public $name = 'bricks-order-details-form';
32
33 /**
34 * Icon of the element.
35 *
36 * @var instance
37 */
38 public $icon = 'fa-solid fa-star';
39
40 /**
41 * Label of the element.
42 *
43 * @var instance
44 */
45 public function get_label() {
46 return esc_html__( 'Order Details Form', 'cartflows' );
47 }
48
49 /**
50 * Retrieve Widget Keywords.
51 *
52 * @since 1.6.15
53 * @access public
54 *
55 * @return string Widget keywords.
56 */
57 public function get_keywords() {
58 return array( 'cartflows', 'order details', 'form' );
59 }
60
61 /**
62 * Retrieve the list of scripts the widget depended on.
63 *
64 * Used to set scripts dependencies for the widget.
65 *
66 * @return void
67 */
68 public function set_control_groups() {
69 $this->control_groups['section_thankyou_fields'] = array(
70 'title' => esc_html__( 'Global', 'cartflows' ),
71 'tab' => 'content',
72 );
73 $this->control_groups['order_details_form_spacing_styling'] = array(
74 'title' => esc_html__( 'Spacing', 'cartflows' ),
75 'tab' => 'content',
76 );
77 $this->control_groups['order_details_form_heading_styling'] = array(
78 'title' => esc_html__( 'Heading', 'cartflows' ),
79 'tab' => 'style',
80 );
81 $this->control_groups['order_details_form_general_styling'] = array(
82 'title' => esc_html__( 'General', 'cartflows' ),
83 'tab' => 'style',
84 );
85 $this->control_groups['order_details_form_order_review_styling'] = array(
86 'title' => esc_html__( 'Order Overview', 'cartflows' ),
87 'tab' => 'style',
88 );
89 $this->control_groups['section_downloads_styling'] = array(
90 'title' => esc_html__( 'Downloads', 'cartflows' ),
91 'tab' => 'style',
92 );
93 $this->control_groups['section_order_details_styling'] = array(
94 'title' => esc_html__( 'Order Details', 'cartflows' ),
95 'tab' => 'style',
96 );
97 $this->control_groups['section_customer_details_styling'] = array(
98 'title' => esc_html__( 'Customer Details', 'cartflows' ),
99 'tab' => 'style',
100 );
101 }
102
103 /**
104 * Register Order Details Form controls.
105 */
106 public function set_controls() {
107
108 // Content Tab.
109 $this->register_thankyou_controls();
110
111 // Style Tab.
112 $this->register_spacing_controls();
113 $this->register_heading_style_controls();
114 $this->register_general_style_controls();
115 $this->register_section_order_review_style_controls();
116 $this->register_section_downloads_style_controls();
117 $this->register_section_order_details_style_controls();
118 $this->register_section_customer_details_style_controls();
119 }
120
121 /**
122 * Register Thank you page Controls.
123 */
124 public function register_thankyou_controls() {
125
126 $this->controls['layout'] = array(
127 'label' => esc_html__( 'Layout', 'cartflows' ),
128 'type' => 'select',
129 'options' => array(
130 'legacy-tq-layout' => esc_html__( 'Layout 1', 'cartflows' ),
131 'modern-tq-layout' => esc_html__( 'Layout 2', 'cartflows' ),
132 'tq-layout-3' => esc_html__( 'Layout 3', 'cartflows' ),
133 ),
134 'default' => 'legacy-tq-layout',
135 'reload' => true,
136 'reloadScripts' => true,
137 'group' => 'section_thankyou_fields',
138 );
139
140 $this->controls['thankyou_text'] = array(
141 'label' => esc_html__( 'Thank You Text', 'cartflows' ),
142 'type' => 'text',
143 'placeholder' => esc_html__( 'Thank you. Your order has been received.', 'cartflows' ),
144 'label_block' => true,
145 'group' => 'section_thankyou_fields',
146 'description' => esc_html__( 'The Thank You Text is only applicable for the old layout.', 'cartflows' ),
147 );
148
149 $this->controls['show_order_overview'] = array(
150 'label' => esc_html__( 'Order Overview', 'cartflows' ),
151 'type' => 'checkbox',
152 'default' => true,
153 'group' => 'section_thankyou_fields',
154 );
155
156 $this->controls['show_order_details'] = array(
157 'label' => esc_html__( 'Order Details', 'cartflows' ),
158 'type' => 'checkbox',
159 'default' => true,
160 'group' => 'section_thankyou_fields',
161 );
162
163 $this->controls['show_billing_address'] = array(
164 'label' => esc_html__( 'Billing Address', 'cartflows' ),
165 'type' => 'checkbox',
166 'default' => true,
167 'group' => 'section_thankyou_fields',
168 );
169
170 $this->controls['show_shipping_address'] = array(
171 'label' => esc_html__( 'Shipping Address', 'cartflows' ),
172 'type' => 'checkbox',
173 'default' => true,
174 'group' => 'section_thankyou_fields',
175 );
176 }
177
178 /**
179 * Register spacing Styling Controls.
180 */
181 public function register_spacing_controls() {
182
183 $this->controls['heading_spacing'] = array(
184 'label' => esc_html__( 'Heading Bottom Spacing', 'cartflows' ),
185 'type' => 'number',
186 'group' => 'order_details_form_spacing_styling',
187 'css' => array(
188 array(
189 'property' => 'margin-bottom',
190 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order .woocommerce-thankyou-order-received',
191 ),
192 ),
193 );
194
195 $this->controls['sections_spacing'] = array(
196 'label' => esc_html__( 'Spacing Between Sections', 'cartflows' ),
197 'type' => 'number',
198 'group' => 'order_details_form_spacing_styling',
199 'css' => array(
200 array(
201 'property' => 'margin-bottom',
202 'selector' => '.cartflows-bricks__order-details-form .woocommerce-order ul.order_details',
203
204 ),
205 array(
206 'property' => 'margin-bottom',
207 'selector' => '.cartflows-bricks__order-details-form .woocommerce-order .woocommerce-order-details',
208 ),
209 array(
210 'property' => 'margin-bottom',
211 'selector' => '.cartflows-bricks__order-details-form .woocommerce-order-details.mollie-instructions',
212 ),
213 ),
214 );
215 }
216
217 /**
218 * Register heading Styling Controls.
219 *
220 * @since 1.6.15
221 * @access protected
222 */
223 public function register_heading_style_controls() {
224
225 $this->controls['heading_typography'] = array(
226 'label' => esc_html__( 'Typography', 'cartflows' ),
227 'type' => 'typography',
228 'css' => array(
229 array(
230 'property' => 'font',
231 'selector' => '.cartflows-bricks__order-details-form .woocommerce-order .woocommerce-thankyou-order-received',
232 ),
233 ),
234 'group' => 'order_details_form_heading_styling',
235 );
236
237 $this->controls['heading_background_color'] = array(
238 'label' => esc_html__( 'Background Color', 'cartflows' ),
239 'type' => 'background',
240 'css' => array(
241 array(
242 'property' => 'background-color',
243 'selector' => '.cartflows-bricks__order-details-form .woocommerce-order .woocommerce-thankyou-order-received',
244 ),
245 ),
246 'group' => 'order_details_form_heading_styling',
247 );
248 }
249
250
251 /**
252 * Register General Styling Controls.
253 *
254 * @since 1.6.15
255 * @access protected
256 */
257 public function register_general_style_controls() {
258
259 $this->controls['section_all_background_color'] = array(
260 'label' => esc_html__( 'Background Color', 'cartflows' ),
261 'type' => 'background',
262 'css' => array(
263 array(
264 'property' => 'background-color',
265 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order .woocommerce-thankyou-order-received',
266 ),
267 ),
268 'group' => 'order_details_form_general_styling',
269 );
270
271
272 $this->controls['section_heading_typography'] = array(
273 'label' => esc_html__( 'Sections Heading Typography', 'cartflows' ),
274 'type' => 'typography',
275 'css' => array(
276 array(
277 'property' => 'font',
278 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order h2',
279 ),
280 ),
281 'group' => 'order_details_form_general_styling',
282 );
283
284 $this->controls['section_text_typography'] = array(
285 'label' => esc_html__( 'Sections Text Typography', 'cartflows' ),
286 'type' => 'typography',
287 'css' => array(
288 array(
289 'property' => 'font',
290 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order .woocommerce-order-overview.woocommerce-thankyou-order-details.order_details li, .cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order.wcf-modern-tq-layout .woocommerce-order-overview.woocommerce-thankyou-order-details.order_details li p, .cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order.wcf-tq-layout-3 .woocommerce-order-overview.woocommerce-thankyou-order-details.order_details li p',
291 ),
292 array(
293 'property' => 'font',
294 'selector' => '.cartflows-bricks__order-details-form .woocommerce-order-downloads table.shop_table',
295 ),
296 ),
297 'group' => 'order_details_form_general_styling',
298 );
299
300 $this->controls['section_all_background_color'] = array(
301 'label' => esc_html__( 'Sections Background Color', 'cartflows' ),
302 'type' => 'background',
303 'css' => array(
304 array(
305 'property' => 'background-color',
306 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order',
307 ),
308 array(
309 'property' => 'background-color',
310 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order-details',
311 ),
312 array(
313 'property' => 'background-color',
314 'selector' => '.cartflows-bricks__order-details-form .woocommerce-order-downloads',
315 ),
316 array(
317 'property' => 'background-color',
318 'selector' => '.cartflows-bricks__order-details-form .woocommerce-order ul.order_details',
319 ),
320 array(
321 'property' => 'background-color',
322 'selector' => '.cartflows-bricks__order-details-form .woocommerce-order .woocommerce-customer-details',
323 ),
324 array(
325 'property' => 'background-color',
326 'selector' => '.cartflows-bricks__order-details-form .woocommerce-order .woocommerce-bacs-bank-details',
327 ),
328 ),
329 'group' => 'order_details_form_general_styling',
330 );
331 }
332
333 /**
334 * Register Section Order Review Styling Controls.
335 *
336 * @since 1.6.15
337 * @access protected
338 */
339 public function register_section_order_review_style_controls() {
340
341 $this->controls['section_order_review_typography'] = array(
342 'label' => esc_html__( 'Typography', 'cartflows' ),
343 'type' => 'typography',
344 'group' => 'order_details_form_order_review_styling',
345 'css' => array(
346 array(
347 'property' => 'font',
348 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order .woocommerce-order-overview.woocommerce-thankyou-order-details.order_details li, .cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order.wcf-modern-tq-layout .woocommerce-order-overview.woocommerce-thankyou-order-details.order_details li p, .cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order.wcf-tq-layout-3 .woocommerce-order-overview.woocommerce-thankyou-order-details.order_details li p',
349 ),
350 ),
351
352 );
353
354 $this->controls['section_order_review_background_color'] = array(
355 'label' => esc_html__( 'Background Color', 'cartflows' ),
356 'type' => 'color',
357 'group' => 'order_details_form_order_review_styling',
358 'css' => array(
359 array(
360 'property' => 'background-color',
361 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order .woocommerce-order-overview.woocommerce-thankyou-order-details.order_details',
362 ),
363 ),
364 );
365 }
366
367 /**
368 * Register Section Order downloads Styling Controls.
369 *
370 * @since 1.6.15
371 * @access protected
372 */
373 public function register_section_downloads_style_controls() {
374
375 $this->controls['section_downloads_heading_typography'] = array(
376 'label' => esc_html__( 'Heading Typography', 'cartflows' ),
377 'type' => 'typography',
378 'group' => 'section_downloads_styling',
379 'css' => array(
380 array(
381 'property' => 'font',
382 'selector' => '.cartflows-bricks__order-details-form .woocommerce-order h2.woocommerce-order-downloads__title',
383 ),
384 array(
385 'property' => 'font',
386 'selector' => ' .cartflows-bricks__order-details-form .woocommerce-order .woocommerce-order-downloads h2.woocommerce-order-downloads__title',
387 ),
388 ),
389
390 );
391
392 $this->controls['section_downloads_text_typography'] = array(
393 'label' => esc_html__( 'Text Typography', 'cartflows' ),
394 'type' => 'typography',
395 'group' => 'section_downloads_styling',
396 'css' => array(
397 array(
398 'property' => 'font',
399 'selector' => '.cartflows-bricks__order-details-form .woocommerce-order .woocommerce-order-downloads table.shop_table',
400 ),
401 ),
402
403 );
404
405 $this->controls['section_downloads_background_color'] = array(
406 'label' => esc_html__( 'Background Color', 'cartflows' ),
407 'type' => 'color',
408 'group' => 'section_downloads_styling',
409 'css' => array(
410 array(
411 'property' => 'background-color',
412 'selector' => '.cartflows-bricks__order-details-form .woocommerce-order .woocommerce-order-downloads',
413 ),
414 ),
415 );
416 }
417
418 /**
419 * Register Section Order Details Styling Controls.
420 */
421 public function register_section_order_details_style_controls() {
422
423
424 $this->controls['section_order_details_heading_typography'] = array(
425 'label' => esc_html__( 'Heading Typography', 'cartflows' ),
426 'type' => 'typography',
427 'group' => 'section_order_details_styling',
428 'css' => array(
429 array(
430 'property' => 'font',
431 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order .woocommerce-order-details .woocommerce-order-details__title',
432 ),
433 ),
434
435 );
436
437
438 $this->controls['section_order_details_text_typography'] = array(
439 'label' => esc_html__( 'Text Typography', 'cartflows' ),
440 'type' => 'typography',
441 'group' => 'section_order_details_styling',
442 'css' => array(
443 array(
444 'property' => 'font',
445 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order .woocommerce-order-details .woocommerce-table',
446 ),
447 ),
448
449 );
450
451 $this->controls['section_order_details_background_color'] = array(
452 'label' => esc_html__( 'Background Color', 'cartflows' ),
453 'type' => 'color',
454 'group' => 'section_order_details_styling',
455 'css' => array(
456 array(
457 'property' => 'background-color',
458 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order .woocommerce-order-details',
459 ),
460 ),
461 );
462 }
463
464
465 /**
466 * Register Section Customer Details Styling Controls.
467 */
468 public function register_section_customer_details_style_controls() {
469
470 $this->controls['section_customer_details_heading_typography'] = array(
471 'label' => esc_html__( 'Heading Typography', 'cartflows' ),
472 'type' => 'typography',
473 'group' => 'section_customer_details_styling',
474 'css' => array(
475 array(
476 'property' => 'font',
477 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order .woocommerce-customer-details .woocommerce-column__title',
478 ),
479 ),
480
481 );
482
483 $this->controls['section_customer_details_text_typography'] = array(
484 'label' => esc_html__( 'Text Typography', 'cartflows' ),
485 'type' => 'typography',
486 'group' => 'section_customer_details_styling',
487 'css' => array(
488 array(
489 'property' => 'font',
490 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order .woocommerce-customer-details address, .cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order.wcf-modern-tq-layout .woocommerce-customer-details tr *, .cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order.wcf-tq-layout-3 .woocommerce-customer-details tr *',
491 ),
492 ),
493
494 );
495
496 $this->controls['section_customer_details_background_color'] = array(
497 'label' => esc_html__( 'Background Color', 'cartflows' ),
498 'type' => 'color',
499 'group' => 'section_customer_details_styling',
500 'css' => array(
501 array(
502 'property' => 'background-color',
503 'selector' => '.cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order:not(.wcf-modern-tq-layout) .woocommerce-customer-details, .cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order.wcf-modern-tq-layout .woocommerce-customer-details .customer-details-box, .cartflows-bricks__order-details-form .wcf-thankyou-wrap .woocommerce-order.wcf-tq-layout-3 .woocommerce-customer-details .customer-details-box',
504 ),
505 ),
506 );
507 }
508
509 /**
510 * Render Order Details Form output on the frontend.
511 *
512 * Written in PHP and used to generate the final HTML.
513 *
514 * @return void
515 */
516 public function render() {
517 $this->set_attribute( '_root', 'data-element-id', $this->id );
518 /* Add bricks setting options to filters */
519 $this->dynamic_option_filters();
520 $order_overview = 'no';
521
522 if ( isset( $this->settings['show_order_overview'] ) && true === $this->settings['show_order_overview'] ) {
523 $order_overview = 'yes';
524 }
525
526 $order_details = 'no';
527 if ( isset( $this->settings['show_order_details'] ) && true === $this->settings['show_order_details'] ) {
528 $order_details = 'yes';
529 }
530
531 $shipping_address = 'no';
532 if ( isset( $this->settings['show_shipping_address'] ) && true === $this->settings['show_shipping_address'] ) {
533 $shipping_address = 'yes';
534 }
535
536 $billing_address = 'no';
537 if ( isset( $this->settings['show_billing_address'] ) && true === $this->settings['show_billing_address'] ) {
538 $billing_address = 'yes';
539 }
540
541
542
543 ?>
544 <div <?php echo $this->render_attributes( '_root' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> >
545 <div class = "cartflows-bricks__order-details-form cartflows-bricks__display-order-overview-<?php echo esc_attr( $order_overview ); ?> cartflows-bricks__display-order-details-<?php echo esc_attr( $order_details ); ?> cartflows-bricks__display-billing-address-<?php echo esc_attr( $billing_address ); ?> cartflows-bricks__display-shipping-address-<?php echo esc_attr( $shipping_address ); ?>">
546 <?php echo do_shortcode( '[cartflows_order_details]' ); ?>
547 </div>
548 </div>
549 <?php
550 }
551
552 /**
553 * Dynamic options of elementor and add filters.
554 *
555 * @return void
556 */
557 public function dynamic_option_filters() {
558
559 if ( ! empty( $this->settings['thankyou_text'] ) ) {
560
561 add_filter(
562 'cartflows_thankyou_meta_wcf-tq-text',
563 function ( $text ) {
564
565 $text = $this->settings['thankyou_text'];
566
567 return $text;
568 },
569 10,
570 1
571 );
572 }
573
574 if ( ! empty( $this->settings['layout'] ) ) {
575
576 add_filter(
577 'cartflows_thankyou_meta_wcf-tq-layout',
578 function ( $text ) {
579
580 $text = $this->settings['layout'];
581
582 return $text;
583 },
584 10,
585 1
586 );
587 }
588 }
589 }
590