product-sku.php
190 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use ShopEngine\Widgets\Products; |
| 8 | |
| 9 | |
| 10 | class ShopEngine_Product_Sku extends \ShopEngine\Base\Widget { |
| 11 | |
| 12 | public function config() { |
| 13 | return new ShopEngine_Product_Sku_Config(); |
| 14 | } |
| 15 | |
| 16 | protected function register_controls() { |
| 17 | |
| 18 | $this->start_controls_section( |
| 19 | 'shopengine_section_product_sku', |
| 20 | array( |
| 21 | 'label' => esc_html__('SKU', 'shopengine'), |
| 22 | 'tab' => Controls_Manager::TAB_STYLE, |
| 23 | ) |
| 24 | ); |
| 25 | |
| 26 | $this->add_responsive_control( |
| 27 | 'shopengine_product_sku_align', |
| 28 | \ShopEngine\Utils\Controls_Helper::get_alignment_conf( |
| 29 | 'elementor%s-align-', '', |
| 30 | [ |
| 31 | '{{WRAPPER}} .shopengine-sku .sku-wrapper' => 'justify-content: {{VALUE}}', |
| 32 | '.rtl {{WRAPPER}}.elementor-align-left .shopengine-sku .sku-wrapper' => 'justify-content:start;', |
| 33 | '.rtl {{WRAPPER}}.elementor-align-right .shopengine-sku .sku-wrapper' => 'justify-content:end;', |
| 34 | ], |
| 35 | ) |
| 36 | ); |
| 37 | |
| 38 | $this->add_control( |
| 39 | 'shopengine_heading_product_sku_label', |
| 40 | [ |
| 41 | 'label' => esc_html__('SKU Label', 'shopengine'), |
| 42 | 'type' => Controls_Manager::HEADING, |
| 43 | 'separator' => 'before', |
| 44 | ] |
| 45 | ); |
| 46 | |
| 47 | $this->add_control( |
| 48 | 'shopengine_product_sku_label_show', |
| 49 | [ |
| 50 | 'label' => esc_html__('Show Label', 'shopengine'), |
| 51 | 'type' => Controls_Manager::SWITCHER, |
| 52 | 'label_on' => esc_html__('Show', 'shopengine'), |
| 53 | 'label_off' => esc_html__('Hide', 'shopengine'), |
| 54 | 'return_value' => 'yes', |
| 55 | 'default' => 'yes', |
| 56 | ] |
| 57 | ); |
| 58 | |
| 59 | $this->add_control( |
| 60 | 'shopengine_product_sku_label_color', |
| 61 | [ |
| 62 | 'label' => esc_html__('Color', 'shopengine'), |
| 63 | 'type' => Controls_Manager::COLOR, |
| 64 | 'alpha' => false, |
| 65 | 'default' => '#101010', |
| 66 | 'selectors' => [ |
| 67 | '{{WRAPPER}} .shopengine-sku .sku-label' => 'color: {{VALUE}};', |
| 68 | ], |
| 69 | 'condition' => [ |
| 70 | 'shopengine_product_sku_label_show!' => '', |
| 71 | ] |
| 72 | ] |
| 73 | ); |
| 74 | |
| 75 | $this->add_control( |
| 76 | 'shopengine_product_cats_label_text_decoration', |
| 77 | [ |
| 78 | 'label' => esc_html__('Text Decoration', 'shopengine'), |
| 79 | 'type' => Controls_Manager::SELECT, |
| 80 | 'default' => 'none', |
| 81 | 'options' => [ |
| 82 | 'underline' => esc_html__( 'Underline', 'shopengine' ), |
| 83 | 'overline' => esc_html__( 'Overline', 'shopengine' ), |
| 84 | 'line-through' => esc_html__( 'Line Through', 'shopengine' ), |
| 85 | 'none' => esc_html__( 'None', 'shopengine' ), |
| 86 | ], |
| 87 | 'selectors' => [ |
| 88 | '{{WRAPPER}} .shopengine-sku .sku-label' => 'text-decoration: {{VALUE}} !important; text-underline-offset: 3px;', |
| 89 | ], |
| 90 | 'condition' => [ |
| 91 | 'shopengine_product_sku_label_show!' => '', |
| 92 | ], |
| 93 | ] |
| 94 | ); |
| 95 | |
| 96 | $this->add_control( |
| 97 | 'shopengine_heading_product_sku_value', |
| 98 | array( |
| 99 | 'label' => esc_html__('SKU Value', 'shopengine'), |
| 100 | 'type' => Controls_Manager::HEADING, |
| 101 | 'separator' => 'before', |
| 102 | ) |
| 103 | ); |
| 104 | |
| 105 | $this->add_control( |
| 106 | 'shopengine_product_sku_value_color', |
| 107 | [ |
| 108 | 'label' => esc_html__('Color', 'shopengine'), |
| 109 | 'type' => Controls_Manager::COLOR, |
| 110 | 'alpha' => false, |
| 111 | 'default' => '#A0A0A0', |
| 112 | 'selectors' => [ |
| 113 | '{{WRAPPER}} .shopengine-sku .sku-value' => 'color: {{VALUE}};', |
| 114 | '{{WRAPPER}} .shopengine-sku p' => 'display: none;', |
| 115 | ], |
| 116 | ] |
| 117 | ); |
| 118 | |
| 119 | $this->add_control( |
| 120 | 'shopengine_product_sku_typography_heading', |
| 121 | [ |
| 122 | 'label' => esc_html__('Global Typography', 'shopengine'), |
| 123 | 'type' => Controls_Manager::HEADING, |
| 124 | 'separator' => 'before', |
| 125 | ] |
| 126 | ); |
| 127 | |
| 128 | $this->add_group_control( |
| 129 | Group_Control_Typography::get_type(), |
| 130 | [ |
| 131 | 'name' => 'shopengine_product_sku_typography', |
| 132 | 'label' => esc_html__('Typography', 'shopengine'), |
| 133 | 'description' => esc_html__('This typography is set for this specific widget.', 'shopengine'), |
| 134 | 'selector' => '{{WRAPPER}} .shopengine-sku .sku-label, {{WRAPPER}} .shopengine-sku .sku-value', |
| 135 | 'exclude' => ['letter_spacing', 'text_decoration', 'font_style'], |
| 136 | 'fields_options' => [ |
| 137 | 'typography' => [ |
| 138 | 'default' => 'custom', |
| 139 | ], |
| 140 | 'font_size' => [ |
| 141 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 142 | 'size_units' => ['px'], |
| 143 | 'default' => [ |
| 144 | 'size' => '14', |
| 145 | 'unit' => 'px', |
| 146 | ], |
| 147 | ], |
| 148 | 'font_weight' => [ |
| 149 | 'default' => '500', |
| 150 | ], |
| 151 | 'text_transform' => [ |
| 152 | 'default' => 'none', |
| 153 | ], |
| 154 | 'text_decoration' => [ |
| 155 | 'default' => 'none', |
| 156 | 'selectors' => [ |
| 157 | '{{WRAPPER}} .shopengine-sku .sku-label, {{WRAPPER}} .shopengine-sku .sku-value' => 'text-decoration: {{VALUE}}; text-underline-offset: 3px;', |
| 158 | ], |
| 159 | ], |
| 160 | 'line_height' => [ |
| 161 | 'label' => esc_html__('Line Height (px)', 'shopengine'), |
| 162 | 'default' => [ |
| 163 | 'size' => '17', |
| 164 | 'unit' => 'px', |
| 165 | ], |
| 166 | 'size_units' => ['px'], |
| 167 | 'tablet_default' => [ |
| 168 | 'unit' => 'px', |
| 169 | ], |
| 170 | 'mobile_default' => [ |
| 171 | 'unit' => 'px', |
| 172 | ], |
| 173 | ], |
| 174 | ], |
| 175 | ] |
| 176 | ); |
| 177 | |
| 178 | $this->end_controls_section(); |
| 179 | } |
| 180 | |
| 181 | protected function screen() { |
| 182 | |
| 183 | $settings = $this->get_settings_for_display(); |
| 184 | |
| 185 | $tpl = Products::instance()->get_widget_template($this->get_name()); |
| 186 | |
| 187 | include $tpl; |
| 188 | } |
| 189 | } |
| 190 |