PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / Elementor / widgets / checkout / additional-fields / config.php
shop-press / Elementor / widgets / checkout / additional-fields Last commit date
config.php 2 years ago
config.php
122 lines
1 <?php
2 namespace ShopPress\Elementor\Widgets;
3
4 defined( 'ABSPATH' ) || exit;
5
6 use Elementor\Controls_Manager;
7 use ShopPress\Elementor\ShopPressWidgets;
8
9 class AdditionalFields extends ShopPressWidgets {
10
11 public function get_name() {
12 return 'sp-checkout-additional-fields';
13 }
14
15 public function get_title() {
16 return __( 'Additional Fields', 'shop-press' );
17 }
18
19 public function get_icon() {
20 return 'sp-widget sp-eicon-additional-fields';
21 }
22
23 public function get_categories() {
24 return array( 'sp_woo_checkout' );
25 }
26
27 public function setup_styling_options() {
28 $this->register_group_styler(
29 'wrapper',
30 __( 'Wrapper', 'shop-press' ),
31 array(
32 'wrapper' => array(
33 'label' => esc_html__( 'Wrapper', 'shop-press' ),
34 'type' => 'styler',
35 'selector' => '.sp-checkout-additional-fields',
36 'wrapper' => '{{WRAPPER}}',
37 ),
38 )
39 );
40
41 $this->register_group_styler(
42 'title',
43 __( 'Title', 'shop-press' ),
44 array(
45 'title' => array(
46 'label' => esc_html__( 'Title', 'shop-press' ),
47 'type' => 'styler',
48 'selector' => '.woocommerce-additional-fields h3',
49 'wrapper' => '{{WRAPPER}}',
50 ),
51 )
52 );
53
54 $this->register_group_styler(
55 'textarea',
56 __( 'Textarea', 'shop-press' ),
57 array(
58 'textarea' => array(
59 'label' => esc_html__( 'Textarea', 'shop-press' ),
60 'type' => 'styler',
61 'selector' => 'textarea#order_comments ',
62 'wrapper' => '{{WRAPPER}}',
63 ),
64 )
65 );
66 $this->register_group_styler(
67 'label',
68 __( 'Label', 'shop-press' ),
69 array(
70 'label' => array(
71 'label' => esc_html__( 'Label', 'shop-press' ),
72 'type' => 'styler',
73 'selector' => '#order_comments_field label',
74 'wrapper' => '{{WRAPPER}}',
75 ),
76 'require' => array(
77 'label' => esc_html__( 'Require', 'shop-press' ),
78 'type' => 'styler',
79 'selector' => '#order_comments_field label .optional',
80 'wrapper' => '{{WRAPPER}}',
81 ),
82 )
83 );
84 }
85
86 protected function register_controls() {
87 $this->start_controls_section(
88 'section_content',
89 array(
90 'label' => __( 'General', 'shop-press' ),
91 )
92 );
93
94 $this->add_control(
95 'hide_additional_fields_title',
96 array(
97 'label' => __( 'Hide Title', 'shop-press' ),
98 'type' => Controls_Manager::SWITCHER,
99 )
100 );
101
102 $this->end_controls_section();
103 $this->setup_styling_options();
104
105 do_action( 'shoppress/elementor/widget/register_controls_init', $this );
106 }
107
108 protected function render() {
109 $settings = $this->get_settings_for_display();
110
111 do_action( 'shoppress/widget/before_render', $settings );
112
113 $args = array(
114 'hide_title' => $settings['hide_additional_fields_title'],
115 );
116
117 if ( $this->checkout_editor_preview() ) {
118 sp_load_builder_template( 'checkout/checkout-additional-fields', $args );
119 }
120 }
121 }
122