screens
3 years ago
checkout-form-additional-config.php
4 years ago
checkout-form-additional.php
3 years ago
checkout-form-additional.php
398 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | use ShopEngine\Widgets\Products; |
| 6 | |
| 7 | defined('ABSPATH') || exit; |
| 8 | |
| 9 | |
| 10 | class ShopEngine_Checkout_Form_Additional extends \ShopEngine\Base\Widget |
| 11 | { |
| 12 | |
| 13 | |
| 14 | public function config() { |
| 15 | return new ShopEngine_Checkout_Form_Additional_Config(); |
| 16 | } |
| 17 | |
| 18 | |
| 19 | protected function register_controls() { |
| 20 | /** |
| 21 | * Section: Heading |
| 22 | */ |
| 23 | $this->start_controls_section( |
| 24 | 'shopengine_section_style_heading', |
| 25 | [ |
| 26 | 'label' => esc_html__( 'Heading', 'shopengine' ), |
| 27 | 'tab' => Controls_Manager::TAB_STYLE, |
| 28 | ] |
| 29 | ); |
| 30 | $this->add_control( |
| 31 | 'shopengine_checkout_form_additional_heading', |
| 32 | [ |
| 33 | 'label' => esc_html__( 'Show heading', 'shopengine' ), |
| 34 | 'type' => Controls_Manager::SWITCHER, |
| 35 | 'default' => 'yes', |
| 36 | 'selectors' => [ |
| 37 | '{{WRAPPER}} .shopengine-checkout-form-additional h3' => 'display: block;', |
| 38 | ], |
| 39 | ] |
| 40 | ); |
| 41 | |
| 42 | $this->add_control( |
| 43 | 'shopengine_checkout_form_additional_heading_color', |
| 44 | [ |
| 45 | 'label' => esc_html__( 'Color', 'shopengine' ), |
| 46 | 'type' => Controls_Manager::COLOR, |
| 47 | 'alpha' => false, |
| 48 | 'selectors' => [ |
| 49 | '{{WRAPPER}} .shopengine-checkout-form-additional h3' => 'color: {{VALUE}};', |
| 50 | ], |
| 51 | ] |
| 52 | ); |
| 53 | |
| 54 | $this->add_control( |
| 55 | 'shopengine_checkout_form_additional_heading_size', |
| 56 | [ |
| 57 | 'label' => esc_html__( 'Font Size (px)', 'shopengine' ), |
| 58 | 'type' => Controls_Manager::SLIDER, |
| 59 | 'size_units' => ['px'], |
| 60 | 'selectors' => [ |
| 61 | '{{WRAPPER}} .shopengine-checkout-form-additional h3' => 'font-size: {{SIZE}}{{UNIT}} !important;', |
| 62 | ], |
| 63 | ] |
| 64 | ); |
| 65 | |
| 66 | $this->add_control( |
| 67 | 'shopengine_checkout_form_additional_heading_spacing', |
| 68 | [ |
| 69 | 'label' => esc_html__( 'Spacing Bottom (px)', 'shopengine' ), |
| 70 | 'type' => Controls_Manager::SLIDER, |
| 71 | 'size_units' => ['px'], |
| 72 | 'selectors' => [ |
| 73 | '{{WRAPPER}} .shopengine-checkout-form-additional h3' => 'padding-bottom: {{SIZE}}{{UNIT}} !important;', |
| 74 | ], |
| 75 | 'separator' => 'before', |
| 76 | ] |
| 77 | ); |
| 78 | $this->end_controls_section(); |
| 79 | |
| 80 | |
| 81 | /* |
| 82 | --------------------------------- |
| 83 | Form label |
| 84 | --------------------------------- |
| 85 | */ |
| 86 | |
| 87 | $this->start_controls_section( |
| 88 | 'shopengine_heading_checkout_form_additional_label', |
| 89 | [ |
| 90 | 'label' => esc_html__('Form Label', 'shopengine'), |
| 91 | 'tab' => Controls_Manager::TAB_STYLE, |
| 92 | ] |
| 93 | ); |
| 94 | |
| 95 | $this->add_control( |
| 96 | 'shopengine_checkout_form_additional_label_color', |
| 97 | [ |
| 98 | 'label' => esc_html__('Color', 'shopengine'), |
| 99 | 'type' => Controls_Manager::COLOR, |
| 100 | 'default' => '#3A3A3A', |
| 101 | 'alpha' => false, |
| 102 | 'selectors' => [ |
| 103 | '{{WRAPPER}} .shopengine-checkout-form-additional .form-row label' => 'display: block; color: {{VALUE}};', |
| 104 | ], |
| 105 | ] |
| 106 | ); |
| 107 | |
| 108 | $this->add_group_control( |
| 109 | Group_Control_Typography::get_type(), |
| 110 | [ |
| 111 | 'name' => 'shopengine_orders_body_text_typography', |
| 112 | 'label' => esc_html__('Typography', 'shopengine'), |
| 113 | 'selector' => '{{WRAPPER}} .shopengine-checkout-form-additional .form-row label', |
| 114 | 'exclude' => ['font_family', 'letter_spacing', 'text_decoration', 'text_decoration', 'font_style', 'line_height'], |
| 115 | 'fields_options' => [ |
| 116 | 'typography' => [ |
| 117 | 'default' => 'custom', |
| 118 | ], |
| 119 | 'font_weight' => [ |
| 120 | 'default' => '400', |
| 121 | ], |
| 122 | 'font_size' => [ |
| 123 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 124 | 'default' => [ |
| 125 | 'size' => '15', |
| 126 | 'unit' => 'px', |
| 127 | ], |
| 128 | 'size_units' => ['px'], |
| 129 | ], |
| 130 | ], |
| 131 | ] |
| 132 | ); |
| 133 | |
| 134 | |
| 135 | $this->add_control( |
| 136 | 'shopengine_checkout_form_additional_label_line_height', |
| 137 | [ |
| 138 | 'label' => esc_html__('Spacing Bottom (px)', 'shopengine'), |
| 139 | 'type' => Controls_Manager::SLIDER, |
| 140 | 'default' => [ |
| 141 | 'unit' => 'px', |
| 142 | 'size' => '9', |
| 143 | ], |
| 144 | 'size_units' => ['px'], |
| 145 | 'range' => [ |
| 146 | 'px' => [ |
| 147 | 'min' => 1, |
| 148 | 'max' => 200, |
| 149 | ], |
| 150 | ], |
| 151 | 'selectors' => [ |
| 152 | '{{WRAPPER}} .shopengine-checkout-form-additional .form-row label' => 'margin-bottom: {{SIZE}}{{UNIT}}', |
| 153 | ], |
| 154 | 'separator' => 'before', |
| 155 | ] |
| 156 | ); |
| 157 | |
| 158 | |
| 159 | $this->end_controls_section(); |
| 160 | |
| 161 | /* |
| 162 | --------------------------------- |
| 163 | textarea styles |
| 164 | --------------------------------- |
| 165 | */ |
| 166 | |
| 167 | $this->start_controls_section( |
| 168 | 'shopengine_heading_checkout_form_additional_textarea', |
| 169 | [ |
| 170 | 'label' => esc_html__('Form Textarea', 'shopengine'), |
| 171 | 'tab' => Controls_Manager::TAB_STYLE, |
| 172 | ] |
| 173 | ); |
| 174 | |
| 175 | $this->add_control( |
| 176 | 'shopengine_checkout_form_additional_textarea_color', |
| 177 | [ |
| 178 | 'label' => esc_html__('Color', 'shopengine'), |
| 179 | 'type' => Controls_Manager::COLOR, |
| 180 | 'default' => '#3A3A3A', |
| 181 | 'alpha' => false, |
| 182 | 'selectors' => [ |
| 183 | '{{WRAPPER}} .shopengine-checkout-form-additional .input-text' => 'color: {{VALUE}};', |
| 184 | ], |
| 185 | ] |
| 186 | ); |
| 187 | |
| 188 | $this->add_control( |
| 189 | 'shopengine_checkout_form_additional_textarea_bg_color', |
| 190 | [ |
| 191 | 'label' => esc_html__('Background Color', 'shopengine'), |
| 192 | 'type' => Controls_Manager::COLOR, |
| 193 | 'default' => '#ffffff', |
| 194 | 'alpha' => false, |
| 195 | 'selectors' => [ |
| 196 | '{{WRAPPER}} .shopengine-checkout-form-additional .input-text' => 'background-color: {{VALUE}} !important;', |
| 197 | ], |
| 198 | ] |
| 199 | ); |
| 200 | |
| 201 | $this->add_control( |
| 202 | 'shopengine_checkout_form_additional_textarea_placeholder_color', |
| 203 | [ |
| 204 | 'label' => esc_html__('Placeholder color', 'shopengine'), |
| 205 | 'type' => Controls_Manager::COLOR, |
| 206 | 'default' => '#555555', |
| 207 | 'alpha' => false, |
| 208 | 'selectors' => [ |
| 209 | '{{WRAPPER}} .shopengine-checkout-form-additional .input-text::placeholder' => 'color: {{VALUE}};', |
| 210 | ], |
| 211 | ] |
| 212 | ); |
| 213 | |
| 214 | $this->add_group_control( |
| 215 | Group_Control_Typography::get_type(), |
| 216 | [ |
| 217 | 'name' => 'shopengine_checkout_form_additional_textarea_typography', |
| 218 | 'label' => esc_html__('Text Typography', 'shopengine'), |
| 219 | 'selector' => '{{WRAPPER}} .shopengine-checkout-form-additional .input-text', |
| 220 | 'exclude' => ['font_family', 'letter_spacing', 'text_decoration', 'text_decoration', 'font_style'], |
| 221 | 'fields_options' => [ |
| 222 | 'typography' => [ |
| 223 | 'default' => 'custom', |
| 224 | ], |
| 225 | 'font_weight' => [ |
| 226 | 'default' => '400', |
| 227 | ], |
| 228 | 'font_size' => [ |
| 229 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 230 | 'default' => [ |
| 231 | 'size' => '14', |
| 232 | 'unit' => 'px', |
| 233 | ], |
| 234 | 'size_units' => ['px'], |
| 235 | ], |
| 236 | 'line_height' => [ |
| 237 | 'label' => esc_html__('Line-height (px)', 'shopengine'), |
| 238 | 'default' => [ |
| 239 | 'size' => '17', |
| 240 | 'unit' => 'px', |
| 241 | ], |
| 242 | 'size_units' => ['px'], |
| 243 | ], |
| 244 | ], |
| 245 | ] |
| 246 | ); |
| 247 | |
| 248 | |
| 249 | $this->add_responsive_control( |
| 250 | 'shopengine_checkout_form_additional_textarea_height', |
| 251 | [ |
| 252 | 'label' => esc_html__('Height (px)', 'shopengine'), |
| 253 | 'type' => Controls_Manager::SLIDER, |
| 254 | 'size_units' => ['px'], |
| 255 | 'range' => [ |
| 256 | 'px' => [ |
| 257 | 'min' => 0, |
| 258 | 'max' => 1000, |
| 259 | 'step' => 5, |
| 260 | ], |
| 261 | ], |
| 262 | 'default' => [ |
| 263 | 'unit' => 'px', |
| 264 | 'size' => 90, |
| 265 | ], |
| 266 | 'selectors' => [ |
| 267 | '{{WRAPPER}} .shopengine-checkout-form-additional textarea[name=order_comments]' => 'height: {{SIZE}}{{UNIT}}; width: 100%; background-image: none;', |
| 268 | ], |
| 269 | ] |
| 270 | ); |
| 271 | |
| 272 | $this->add_responsive_control( |
| 273 | 'shopengine_checkout_form_additional_textarea_margin', |
| 274 | [ |
| 275 | 'label' => esc_html__('Padding', 'shopengine'), |
| 276 | 'type' => Controls_Manager::DIMENSIONS, |
| 277 | 'separator' => 'before', |
| 278 | 'default' => [ |
| 279 | 'top' => '10', |
| 280 | 'right' => '18', |
| 281 | 'bottom' => '10', |
| 282 | 'left' => '18', |
| 283 | 'unit' => 'px', |
| 284 | 'isLinked' => false, |
| 285 | ], |
| 286 | 'size_units' => ['px'], |
| 287 | 'selectors' => [ |
| 288 | '{{WRAPPER}} .shopengine-checkout-form-additional .input-text' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 289 | '.rtl {{WRAPPER}} .shopengine-checkout-form-additional .input-text' => 'padding: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};', |
| 290 | ], |
| 291 | ] |
| 292 | ); |
| 293 | |
| 294 | $this->add_group_control( |
| 295 | Group_Control_Border::get_type(), |
| 296 | [ |
| 297 | 'name' => 'shopengine_checkout_form_additional_border', |
| 298 | 'selector' => '{{WRAPPER}} .shopengine-checkout-form-additional .form-row .input-text', |
| 299 | 'separator' => 'before', |
| 300 | 'fields_options' => [ |
| 301 | 'border' => [ |
| 302 | 'default' => 'solid', |
| 303 | ], |
| 304 | 'width' => [ |
| 305 | 'default' => [ |
| 306 | 'top' => '1', |
| 307 | 'right' => '1', |
| 308 | 'bottom' => '1', |
| 309 | 'left' => '1', |
| 310 | 'isLinked' => true, |
| 311 | ], |
| 312 | 'selectors' => [ |
| 313 | '{{WRAPPER}} .shopengine-checkout-form-additional .form-row .input-text' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 314 | '.rtl {{WRAPPER}} .shopengine-checkout-form-additional .form-row .input-text' => 'border-width: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};', |
| 315 | ], |
| 316 | ], |
| 317 | 'color' => [ |
| 318 | 'default' => '#dee3ea', |
| 319 | ], |
| 320 | ], |
| 321 | ] |
| 322 | ); |
| 323 | |
| 324 | $this->add_control( |
| 325 | 'shopengine_checkout_form_additional_textarea_focus_color', |
| 326 | [ |
| 327 | 'label' => esc_html__('Focus Border Color', 'shopengine'), |
| 328 | 'type' => Controls_Manager::COLOR, |
| 329 | 'default' => '#dee3ea', |
| 330 | 'selectors' => [ |
| 331 | '{{WRAPPER}} .shopengine-checkout-form-additional .form-row .input-text:focus' => 'border-color: {{VALUE}}' |
| 332 | ], |
| 333 | 'condition' => [ |
| 334 | 'shopengine_checkout_form_additional_border_border!' => '', |
| 335 | ], |
| 336 | ] |
| 337 | ); |
| 338 | |
| 339 | $this->add_control( |
| 340 | 'shopengine_checkout_form_additional_border_radius', |
| 341 | [ |
| 342 | 'label' => esc_html__('Border Radius', 'shopengine'), |
| 343 | 'type' => Controls_Manager::DIMENSIONS, |
| 344 | 'separator' => 'before', |
| 345 | 'size_units' => ['px'], |
| 346 | 'default' => [ |
| 347 | 'top' => '3', |
| 348 | 'right' => '3', |
| 349 | 'bottom' => '3', |
| 350 | 'left' => '3', |
| 351 | 'unit' => 'px', |
| 352 | 'isLinked' => true, |
| 353 | ], |
| 354 | 'selectors' => [ |
| 355 | '{{WRAPPER}} .shopengine-checkout-form-additional .input-text' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 356 | '.rtl {{WRAPPER}} .shopengine-checkout-form-additional .input-text' => 'border-radius: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};', |
| 357 | ], |
| 358 | ] |
| 359 | ); |
| 360 | |
| 361 | $this->end_controls_section(); |
| 362 | |
| 363 | |
| 364 | /** |
| 365 | * Section: Global Font |
| 366 | */ |
| 367 | $this->start_controls_section( |
| 368 | 'shopengine_section_style_global', |
| 369 | [ |
| 370 | 'label' => esc_html__('Global Font', 'shopengine'), |
| 371 | 'tab' => Controls_Manager::TAB_STYLE, |
| 372 | ] |
| 373 | ); |
| 374 | $this->add_control( |
| 375 | 'shopengine_checkout_form_additional_font_family', |
| 376 | [ |
| 377 | 'label' => esc_html__( 'Font Family', 'shopengine' ), |
| 378 | 'description' => esc_html__( 'This font family is set for this specific widget.', 'shopengine' ), |
| 379 | 'type' => Controls_Manager::FONT, |
| 380 | 'selectors' => [ |
| 381 | '{{WRAPPER}} .shopengine-checkout-form-additional h3, |
| 382 | {{WRAPPER}} .shopengine-checkout-form-additional .form-row label, |
| 383 | {{WRAPPER}} .shopengine-checkout-form-additional .input-text' => 'font-family: {{VALUE}};', |
| 384 | ], |
| 385 | ] |
| 386 | ); |
| 387 | $this->end_controls_section(); |
| 388 | } |
| 389 | |
| 390 | protected function screen() { |
| 391 | |
| 392 | $settings = $this->get_settings_for_display(); |
| 393 | $tpl = Products::instance()->get_widget_template($this->get_name()); |
| 394 | |
| 395 | include $tpl; |
| 396 | } |
| 397 | } |
| 398 |