screens
2 years ago
checkout-shipping-methods-config.php
4 years ago
checkout-shipping-methods.php
3 years ago
checkout-shipping-methods.php
297 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | use ShopEngine\Widgets\Products; |
| 6 | |
| 7 | defined('ABSPATH') || exit; |
| 8 | |
| 9 | class ShopEngine_Checkout_Shipping_Methods extends \ShopEngine\Base\Widget { |
| 10 | |
| 11 | public function config() { |
| 12 | return new ShopEngine_Checkout_Shipping_Methods_Config(); |
| 13 | } |
| 14 | |
| 15 | protected function register_controls() { |
| 16 | /** |
| 17 | ------------------------------- |
| 18 | Checkbox label title |
| 19 | ------------------------------- |
| 20 | */ |
| 21 | |
| 22 | $this->start_controls_section( |
| 23 | 'shopengine_title_section', |
| 24 | [ |
| 25 | 'label' => esc_html__('Title', 'shopengine'), |
| 26 | 'tab' => Controls_Manager::TAB_STYLE, |
| 27 | ] |
| 28 | ); |
| 29 | |
| 30 | $this->add_control( |
| 31 | 'shopengine_title_color', |
| 32 | [ |
| 33 | 'label' => esc_html__('Title Color', 'shopengine'), |
| 34 | 'type' => Controls_Manager::COLOR, |
| 35 | 'alpha' => false, |
| 36 | 'default' => '#3A3A3A', |
| 37 | 'selectors' => [ |
| 38 | '{{WRAPPER}} .shopengine-checkout-shipping-methods .woocommerce-shipping-totals.shipping td::before' => 'color: {{VALUE}}', |
| 39 | ], |
| 40 | ] |
| 41 | ); |
| 42 | |
| 43 | $this->add_group_control( |
| 44 | Group_Control_Typography::get_type(), |
| 45 | [ |
| 46 | 'name' => 'shopengine_title_typography', |
| 47 | 'label' => esc_html__('Typography', 'shopengine'), |
| 48 | 'exclude' => ['font_family', 'letter_spacing', 'text_decoration', 'text_decoration', 'font_style', 'line_height'], |
| 49 | 'selector' => '{{WRAPPER}} .shopengine-checkout-shipping-methods .woocommerce-shipping-totals.shipping td::before', |
| 50 | 'fields_options' => [ |
| 51 | 'typography' => [ |
| 52 | 'default' => 'custom', |
| 53 | ], |
| 54 | 'font_weight' => [ |
| 55 | 'default' => '700', |
| 56 | ], |
| 57 | 'font_size' => [ |
| 58 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 59 | 'default' => [ |
| 60 | 'size' => '14', |
| 61 | 'unit' => 'px', |
| 62 | ], |
| 63 | 'size_units' => ['px'], |
| 64 | ], |
| 65 | ], |
| 66 | ] |
| 67 | ); |
| 68 | |
| 69 | $this->add_control( |
| 70 | 'shopengine_table_titl_margin_bottom', |
| 71 | [ |
| 72 | 'label' => esc_html__('Margin Bottom', 'shopengine'), |
| 73 | 'type' => Controls_Manager::SLIDER, |
| 74 | 'size_units' => ['px'], |
| 75 | 'range' => [ |
| 76 | 'px' => [ |
| 77 | 'min' => 0, |
| 78 | 'max' => 300, |
| 79 | 'step' => 1, |
| 80 | ], |
| 81 | ], |
| 82 | 'default' => [ |
| 83 | 'size' => 20, |
| 84 | 'size_units' => 'px' |
| 85 | ], |
| 86 | 'selectors' => [ |
| 87 | '{{WRAPPER}} .shopengine-checkout-shipping-methods .woocommerce-shipping-totals.shipping td::before' => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 88 | ], |
| 89 | ] |
| 90 | ); |
| 91 | |
| 92 | $this->end_controls_section(); |
| 93 | |
| 94 | /** |
| 95 | --------------------------------- |
| 96 | Content Section |
| 97 | ------------------------------------ |
| 98 | */ |
| 99 | |
| 100 | $this->start_controls_section( |
| 101 | 'shopengine_content_section', |
| 102 | [ |
| 103 | 'label' => esc_html__('Label style', 'shopengine'), |
| 104 | 'tab' => Controls_Manager::TAB_STYLE, |
| 105 | ] |
| 106 | ); |
| 107 | |
| 108 | $this->add_control( |
| 109 | 'shopengine_payment_label_text_color', |
| 110 | [ |
| 111 | 'label' => esc_html__('Label Text Color', 'shopengine'), |
| 112 | 'type' => Controls_Manager::COLOR, |
| 113 | 'alpha' => false, |
| 114 | 'default' => '#3A3A3A', |
| 115 | 'selectors' => [ |
| 116 | '{{WRAPPER}} .shopengine-checkout-shipping-methods .woocommerce-shipping-totals ul li :is(label, .amount, span)' => 'color: {{VALUE}} !important;', |
| 117 | ], |
| 118 | ] |
| 119 | ); |
| 120 | |
| 121 | $this->add_group_control( |
| 122 | Group_Control_Typography::get_type(), |
| 123 | [ |
| 124 | 'name' => 'shopengine_payment_label_typography', |
| 125 | 'label' => esc_html__(' Label Typography ', 'shopengine'), |
| 126 | 'selector' => '{{WRAPPER}} .shopengine-checkout-shipping-methods .woocommerce-shipping-totals ul li :is(label, .amount, span, bdi)', |
| 127 | 'exclude' => ['letter_spacing', 'text_decoration', 'text_transform', 'font_style', 'letter_spacing'], |
| 128 | |
| 129 | 'fields_options' => [ |
| 130 | 'typography' => [ |
| 131 | 'default' => 'custom', |
| 132 | ], |
| 133 | 'font_weight' => [ |
| 134 | 'default' => '600', |
| 135 | ], |
| 136 | 'font_size' => [ |
| 137 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 138 | 'default' => [ |
| 139 | 'size' => '14', |
| 140 | 'unit' => 'px', |
| 141 | ], |
| 142 | 'size_units' => ['px'], |
| 143 | ], |
| 144 | 'line_height' => [ |
| 145 | 'label' => esc_html__('Line Height (px)', 'shopengine'), |
| 146 | 'default' => [ |
| 147 | 'size' => '17', |
| 148 | 'unit' => 'px', |
| 149 | ], |
| 150 | 'size_units' => ['px'], |
| 151 | ], |
| 152 | ], |
| 153 | ] |
| 154 | ); |
| 155 | |
| 156 | $this->add_control( |
| 157 | 'shopengine_payment_label_gap', |
| 158 | [ |
| 159 | 'label' => esc_html__('Gap Between', 'shopengine'), |
| 160 | 'type' => Controls_Manager::SLIDER, |
| 161 | 'size_units' => ['px'], |
| 162 | 'range' => [ |
| 163 | 'px' => [ |
| 164 | 'min' => 0, |
| 165 | 'max' => 300, |
| 166 | 'step' => 1, |
| 167 | ], |
| 168 | ], |
| 169 | 'default' => [ |
| 170 | 'size' => 20, |
| 171 | 'size_units' => 'px' |
| 172 | ], |
| 173 | 'selectors' => [ |
| 174 | '{{WRAPPER}} .shopengine-checkout-shipping-methods #shipping_method' => 'display:flex; flex-direction: column; gap: {{SIZE}}{{UNIT}};', |
| 175 | ], |
| 176 | ] |
| 177 | ); |
| 178 | |
| 179 | $this->end_controls_section(); // end ./ content section |
| 180 | |
| 181 | /** |
| 182 | --------------------------------- |
| 183 | checkbox Section |
| 184 | ------------------------------------ |
| 185 | */ |
| 186 | |
| 187 | $this->start_controls_section( |
| 188 | 'shopengine_payment_methods', |
| 189 | [ |
| 190 | 'label' => esc_html__('Checkbox style', 'shopengine'), |
| 191 | 'tab' => Controls_Manager::TAB_STYLE, |
| 192 | ] |
| 193 | ); |
| 194 | |
| 195 | $this->add_control( |
| 196 | 'shopengine_payment_input_color', |
| 197 | [ |
| 198 | 'label' => esc_html__('Checked Input Color', 'shopengine'), |
| 199 | 'type' => Controls_Manager::COLOR, |
| 200 | 'alpha' => false, |
| 201 | 'default' => '#000', |
| 202 | 'selectors' => [ |
| 203 | '{{WRAPPER}} .shopengine-checkout-shipping-methods .woocommerce-shipping-totals ul li input' => 'accent-color: {{VALUE}};' |
| 204 | ], |
| 205 | ] |
| 206 | ); |
| 207 | |
| 208 | $this->add_responsive_control( |
| 209 | 'shopengine_payment_methods_checkbox_position_y', |
| 210 | [ |
| 211 | 'label' => esc_html__('Checkbox Position (Y)', 'shopengine'), |
| 212 | 'type' => Controls_Manager::SLIDER, |
| 213 | 'size_units' => ['px'], |
| 214 | 'range' => [ |
| 215 | 'px' => [ |
| 216 | 'min' => -100, |
| 217 | 'max' => 100, |
| 218 | 'step' => 1, |
| 219 | ], |
| 220 | ], |
| 221 | 'default' => [ |
| 222 | 'unit' => 'px', |
| 223 | 'size' => 0, |
| 224 | ], |
| 225 | 'selectors' => [ |
| 226 | '{{WRAPPER}} .shopengine-checkout-shipping-methods .woocommerce-shipping-totals ul li input' => 'transform: translateY({{SIZE}}{{UNIT}});' |
| 227 | ], |
| 228 | ] |
| 229 | ); |
| 230 | |
| 231 | $this->add_responsive_control( |
| 232 | 'shopengine_payment_methods_checkbox_margin', |
| 233 | [ |
| 234 | 'label' => esc_html__('Margin (px)', 'shopengine'), |
| 235 | 'type' => Controls_Manager::DIMENSIONS, |
| 236 | 'size_units' => ['px'], |
| 237 | 'default' => [ |
| 238 | 'top' => '0', |
| 239 | 'right' => '8', |
| 240 | 'bottom' => '0', |
| 241 | 'left' => '0', |
| 242 | 'unit' => 'px', |
| 243 | 'isLinked' => false, |
| 244 | ], |
| 245 | 'selectors' => [ |
| 246 | '{{WRAPPER}} .shopengine-checkout-shipping-methods .woocommerce-shipping-totals ul li input' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', |
| 247 | ], |
| 248 | |
| 249 | ] |
| 250 | ); |
| 251 | |
| 252 | $this->end_controls_section(); // end ./ checkbox Section |
| 253 | |
| 254 | |
| 255 | /** |
| 256 | ------------------------ |
| 257 | Section: Global Font |
| 258 | ------------------------ |
| 259 | */ |
| 260 | $this->start_controls_section( |
| 261 | 'shopengine_section_style_global', |
| 262 | [ |
| 263 | 'label' => esc_html__('Global Font', 'shopengine'), |
| 264 | 'tab' => Controls_Manager::TAB_STYLE, |
| 265 | ] |
| 266 | ); |
| 267 | $this->add_control( |
| 268 | 'shopengine_checkout_shipping_methods_font_family', |
| 269 | [ |
| 270 | 'label' => esc_html__( 'Font Family', 'shopengine' ), |
| 271 | 'description' => esc_html__( 'This font family is set for this specific widget.', 'shopengine' ), |
| 272 | 'type' => Controls_Manager::FONT, |
| 273 | 'selectors' => [ |
| 274 | '{{WRAPPER}} .shopengine-checkout-shipping-methods .woocommerce-shipping-totals :is(th, label, td, td:before)' => 'font-family: {{VALUE}};', |
| 275 | ], |
| 276 | ] |
| 277 | ); |
| 278 | |
| 279 | |
| 280 | $this->end_controls_section(); |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * Render widget output on the frontend. |
| 285 | * |
| 286 | * Written in PHP and used to generate the final HTML. |
| 287 | * |
| 288 | * @since 1.0.0 |
| 289 | * @access protected |
| 290 | */ |
| 291 | protected function screen() { |
| 292 | $tpl = Products::instance()->get_widget_template($this->get_name()); |
| 293 | |
| 294 | include $tpl; |
| 295 | } |
| 296 | } |
| 297 |