<?php

class Pzy_Product_Sku extends \Elementor\Widget_Base
{
    public function get_name()
    {
        return 'pzy_product_sku';
    }

    public function get_title()
    {
        return esc_html__('شناسه محصول ', 'pezeshkyar');
    }

    public function get_icon()
    {
        return 'eicon-map-pin';
    }

    public function get_categories()
    {
        return ['pezeshkyar'];
    }

    public function get_keywords()
    {
        return ['pzy', 'product', 'sku'];
    }

    protected function register_controls()
    {

        $this->start_controls_section(
            'style_section',
            [
                'label' => esc_html__('Style', 'pezeshkyar'),
                'tab' => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_control(
            'sku_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .pzy-sku-wrapper' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'sku_typography',
                'selector' => '{{WRAPPER}} .pzy-sku-wrapper',
            ]
        );
        $this->add_control(
            'sku_value_heading',
            [
                'label' => esc_html__( 'متمایز کردن مقدار شناسه محصول', 'textdomain' ),
                'type' => \Elementor\Controls_Manager::HEADING,
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'sku_value_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .pzy-sku-wrapper .pzy-sku' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'sku_value_typography',
                'selector' => '{{WRAPPER}} .pzy-sku-wrapper .pzy-sku',
            ]
        );

        $this->end_controls_section();
    }

    protected function render()
    {
        global $product;
        if (!$product) {
            return;
        }
        pzy_show_sku();
    }
}