<?php

class PZY_MiniCart extends \Elementor\Widget_Base
{
    public function get_name()
    {
        return 'pzy_minicart';
    }

    public function get_title()
    {
        return esc_html__('مینی کارت', 'pezeshkyar');
    }

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

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

    public function get_keywords()
    {
        return ['pzy', 'cart', 'minicart'];
    }

    public function get_script_depends()
    {
        return ['feather-icons','pzy-minicart'];
    }

    protected function register_controls()
    {
        $this->start_controls_section(
            'show_cart_button',
            [
                'label' => esc_html__('دکمه نمایش سبد خرید', 'pezeshkyar'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
            'show_cart_button_icon',
            [
                'label' => esc_html__('آیکون سبد خرید', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::ICONS,
                'default' => [
                    'value' => 'fas fa-shopping-cart',
                    'library' => 'fa-solid',
                ],
            ]
        );
        $this->end_controls_section();

        $this->start_controls_section(
            'show_cart_button_style',
            [
                'label' => esc_html__('دکمه نمایش سبد خرید', 'pezeshkyar'),
                'tab' => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_control(
            'show_cart_button_popover_toggle',
            [
                'label' => esc_html__('سفارشی سازی دکمه', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::POPOVER_TOGGLE,
                'return_value' => 'yes',
                'default' => 'yes',
            ]
        );

        $this->start_popover();

        $this->add_group_control(
            \Elementor\Group_Control_Border::get_type(),
            [
                'name' => 'show_cart_button_border',
                'selector' => '{{WRAPPER}} .pzy-card-button',
            ]
        );
        $this->add_responsive_control(
            'show_cart_button_size',
            [
                'label' => esc_html__('سایز', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 48,
                ],
                'selectors' => [
                    '{{WRAPPER}} .pzy-card-button' => 'display:flex;align-items:center;justify-content:center;width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'show_cart_button_radius',
            [
                'label' => esc_html__('شعاع', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .pzy-card-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'show_cart_button_padding',
            [
                'label' => esc_html__('فاصله داخلی', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .pzy-card-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'show_cart_button_bg_color',
            [
                'label' => esc_html__('رنگ پس زمینه', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'default' => '#fff',
                'selectors' => [
                    '{{WRAPPER}} .pzy-card-button' => 'background-color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'show_cart_button_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .pzy-card-button .shopping-cart svg' => 'stroke: {{VALUE}}',
                    '{{WRAPPER}} .pzy-card-button' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->end_popover();

        $this->add_control(
            'show_cart_icon_size',
            [
                'label' => esc_html__('سایز آیکون سبد خرید', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 20,
                ],
                'selectors' => [
                    '{{WRAPPER}} .pzy-card-button .shopping-cart svg' => 'width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};',
                ],
            ]
        );

        $this->add_control(
            'show_cart_count_popover_toggle',
            [
                'label' => esc_html__('سفارشی سازی تعداد اقلام', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::POPOVER_TOGGLE,
                'return_value' => 'yes',
                'default' => 'yes',
            ]
        );

        $this->start_popover();

        $this->add_control(
            'show_cart_count_radius',
            [
                'label' => esc_html__('شعاع', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .card-count' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'show_cart_count_padding',
            [
                'label' => esc_html__('فاصله داخلی', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .card-count' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'show_cart_count_width',
            [
                'label' => esc_html__('عرض', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 16,
                ],
                'selectors' => [
                    '{{WRAPPER}} .card-count' => 'width: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'show_cart_count_height',
            [
                'label' => esc_html__('ارتفاع', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 16,
                ],
                'selectors' => [
                    '{{WRAPPER}} .card-count' => 'height: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'show_cart_count_bg_color',
            [
                'label' => esc_html__('رنگ پس زمینه', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'default' => '#fff',
                'selectors' => [
                    '{{WRAPPER}} .card-count' => 'background-color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'show_cart_count_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .card-count' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'show_cart_count_top',
            [
                'label' => esc_html__('فاصله از بالا', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 10,
                ],
                'selectors' => [
                    '{{WRAPPER}} .card-count' => 'top: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'show_cart_count_left',
            [
                'label' => esc_html__('فاصله از چپ', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 22,
                ],
                'selectors' => [
                    '{{WRAPPER}} .card-count' => 'left: {{SIZE}}{{UNIT}};',
                ],
            ]
        );

        $this->end_popover();

        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'show_cart_count_typography',
                'selector' => '{{WRAPPER}} .card-count',
            ]
        );

        $this->end_controls_section();

        $this->start_controls_section(
            'mini_cart_section',
            [
                'label' => esc_html__('خلاصه سبد خرید', 'pezeshkyar'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_responsive_control(
            'minicart_horizontal_position',
            [
                'label' => esc_html__('موقعیت افقی', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SELECT,
                'default' => 'left',
                'options' => [
                    'right' => esc_html__('راست', 'pezeshkyar'),
                    'left' => esc_html__('چپ', 'pezeshkyar'),
                ],
                'selectors' => [
                    '{{WRAPPER}} .pzy-minicart' => '{{VALUE}}: 0;',
                ],
            ]
        );
        $this->add_control(
            'minicart_top',
            [
                'label' => esc_html__('فاصله از بالا', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 40,
                ],
                'selectors' => [
                    '{{WRAPPER}} .pzy-minicart' => 'top: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'minicart_width',
            [
                'label' => esc_html__('عرض', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 392,
                ],
                'selectors' => [
                    '{{WRAPPER}} .pzy-minicart' => 'width: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Border::get_type(),
            [
                'name' => 'minicart_border',
                'selector' => '{{WRAPPER}} .pzy-minicart',
            ]
        );
        $this->add_control(
            'minicart_radius',
            [
                'label' => esc_html__('شعاع', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .pzy-minicart' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'minicart_padding',
            [
                'label' => esc_html__('فاصله داخلی', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .pzy-minicart' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'minicart_bg_color',
            [
                'label' => esc_html__('رنگ پس زمینه', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'default' => '#fff',
                'selectors' => [
                    '{{WRAPPER}} .pzy-minicart' => 'background-color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'items_space',
            [
                'label' => esc_html__('فاصله بین ردیف ها', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 12,
                ],
                'selectors' => [
                    '{{WRAPPER}} .pzy-woocommerce-mini-cart-item' => 'padding-bottom: {{SIZE}}{{UNIT}};',
                    '{{WRAPPER}} .pzy-woocommerce-mini-cart-item:not(:first-child)' => 'padding-top: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'items_divider_size',
            [
                'label' => esc_html__('اندازه جدا کننده', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 1,
                ],
                'selectors' => [
                    '{{WRAPPER}} .pzy-woocommerce-mini-cart-item' => 'border-bottom: {{SIZE}}{{UNIT}} solid #fff;',
                ],
            ]
        );
        $this->add_control(
            'items_divider_border_color',
            [
                'label' => esc_html__('رنگ جدا کننده', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'default' => '#fff',
                'selectors' => [
                    '{{WRAPPER}} .pzy-woocommerce-mini-cart-item' => 'border-bottom-color: {{VALUE}}',
                ],
            ]
        );
        $this->end_controls_section();

        $this->start_controls_section(
            'cart_items_image',
            [
                'label' => esc_html__('تصویر محصول', 'pezeshkyar'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
            'cart_items_image_width',
            [
                'label' => esc_html__('عرض', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 92,
                ],
                'selectors' => [
                    '{{WRAPPER}} .pzy-product-thumbnail' => 'width: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Border::get_type(),
            [
                'name' => 'cart_items_image_border',
                'selector' => '{{WRAPPER}} .pzy-product-thumbnail',
            ]
        );
        $this->add_control(
            'cart_items_image_radius',
            [
                'label' => esc_html__('شعاع', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 15,
                ],
                'selectors' => [
                    '{{WRAPPER}} .pzy-product-thumbnail' => 'border-radius: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->end_controls_section();

        $this->start_controls_section(
            'cart_items_title',
            [
                'label' => esc_html__('نام محصول', 'pezeshkyar'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'items_title_typography',
                'selector' => '{{WRAPPER}} .pzy-product-title',
            ]
        );
        $this->add_control(
            'items_title_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .pzy-product-title,{{WRAPPER}} .pzy-product-title a' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'thumbnail_title_gap',
            [
                'label' => esc_html__('فضای بین عنوان و تصویر محصول', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 12,
                ],
                'selectors' => [
                    '{{WRAPPER}} .pzy-product-thumbnail-title' => 'gap: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'thumbnail_title_margin_bottom',
            [
                'label' => esc_html__('فاصله از پایین', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 12,
                ],
                'selectors' => [
                    '{{WRAPPER}} .pzy-product-thumbnail-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->end_controls_section();

        $this->start_controls_section(
            'cart_items_remove_button',
            [
                'label' => esc_html__('دکمه حذف آیتم', 'pezeshkyar'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );


//        remove_from_cart_button
        $this->add_control(
            'cart_items_remove_button_top',
            [
                'label' => esc_html__('فاصله از بالا', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 0,
                ],
                'selectors' => [
                    '{{WRAPPER}} .remove_from_cart_button' => 'top: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'cart_items_remove_button_left',
            [
                'label' => esc_html__('فاصله از چپ', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 0,
                ],
                'selectors' => [
                    '{{WRAPPER}} .remove_from_cart_button' => 'left: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'cart_items_remove_button_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .remove_from_cart_button svg' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'cart_items_remove_button_size',
            [
                'label' => esc_html__('اندازه آیکن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'default' => [
                    'unit' => 'px',
                    'size' => 24,
                ],
                'selectors' => [
                    '{{WRAPPER}} .remove_from_cart_button svg' => 'width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->end_controls_section();

        $this->start_controls_section(
            'cart_items_discount_badge',
            [
                'label' => esc_html__('کادر تخفیف', 'pezeshkyar'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'discount_badge_typography',
                'selector' => '{{WRAPPER}} .pzy-product-discount',
            ]
        );
        $this->add_control(
            'discount_badge_bg_color',
            [
                'label' => esc_html__('رنگ پس زمینه', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .pzy-product-discount' => 'background-color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'discount_badge_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .pzy-product-discount' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'discount_badge_padding',
            [
                'label' => esc_html__('فاصله داخلی', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .pzy-product-discount' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'discount_badge_radius',
            [
                'label' => esc_html__('شعاع', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .pzy-product-discount' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->end_controls_section();

        $this->start_controls_section(
            'cart_items_regular_price',
            [
                'label' => esc_html__('قیمت قدیمی محصول', 'pezeshkyar'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'regular_price_typography',
                'selector' => '{{WRAPPER}} .regular-price',
            ]
        );
        $this->add_control(
            'regular_price_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .regular-price' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->end_controls_section();

        $this->start_controls_section(
            'cart_items_price',
            [
                'label' => esc_html__('قیمت محصول', 'pezeshkyar'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'price_typography',
                'selector' => '{{WRAPPER}} .sale-price',
            ]
        );
        $this->add_control(
            'price_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sale-price' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'price_currency_symbol_typography',
                'selector' => '{{WRAPPER}} .sale-price .woocommerce-Price-currencySymbol',
            ]
        );
        $this->add_control(
            'price_currency_symbol_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sale-price .woocommerce-Price-currencySymbol' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->end_controls_section();

        $this->start_controls_section(
            'cart_items_quantity',
            [
                'label' => esc_html__('تعداد محصول', 'pezeshkyar'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Border::get_type(),
            [
                'name' => 'border',
                'selector' => '{{WRAPPER}} .pzy-add-to-cart-quantity',
            ]
        );
        $this->add_control(
            'quantity_bg_color',
            [
                'label' => esc_html__('رنگ پس زمینه', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'default' => "#fff",
                'selectors' => [
                    '{{WRAPPER}} .pzy-add-to-cart-quantity' => 'background-color: {{VALUE}};',
                ],
            ]
        );
        $this->add_control(
            'quantity_radius',
            [
                'label' => esc_html__('شعاع', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .pzy-add-to-cart-quantity' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'quantity_padding',
            [
                'label' => esc_html__('فاصله داخلی', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .pzy-add-to-cart-quantity' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );

        $this->add_control(
            'quantity_input',
            [
                'label' => esc_html__('فیلد تعداد', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::HEADING,
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'quantity_input_width',
            [
                'label' => esc_html__('عرض', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .quantity .qty' => 'width: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'quantity_input_bg_color',
            [
                'label' => esc_html__('رنگ پس زمینه', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'default' => "#fff",
                'selectors' => [
                    '{{WRAPPER}} .quantity .qty' => 'background-color: {{VALUE}};border:none;',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'quantity_input_typography',
                'selector' => '{{WRAPPER}} .quantity .qty',
            ]
        );
        $this->add_control(
            'quantity_input_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .quantity .qty' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'quantity_buttons',
            [
                'label' => esc_html__('دکمه های افزایش و کاهش تعداد محصول', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::HEADING,
                'separator' => 'before',
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'quantity_buttons_typography',
                'selector' => '{{WRAPPER}} .quantity .pzy-change-quantity',
            ]
        );
        $this->add_control(
            'quantity_buttons_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .quantity .pzy-change-quantity' => 'color: {{VALUE}}',
                    '{{WRAPPER}} .quantity .pzy-change-quantity svg path' => 'stroke: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'quantity_buttons_bg_color',
            [
                'label' => esc_html__('رنگ پس زمینه', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .quantity .pzy-change-quantity' => 'background-color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'quantity_buttons_padding',
            [
                'label' => esc_html__('فاصله داخلی', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .quantity .pzy-change-quantity' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Border::get_type(),
            [
                'name' => 'quantity_buttons_border',
                'selector' => '{{WRAPPER}} .quantity .pzy-change-quantity',
            ]
        );
        $this->add_control(
            'quantity_buttons_radius',
            [
                'label' => esc_html__('شعاع', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .quantity .pzy-change-quantity' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->end_controls_section();

        $this->start_controls_section(
            'total_price',
            [
                'label' => esc_html__('قیمت کل', 'pezeshkyar'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
            'cart_total_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .pzy-total-price' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'cart_total_typography',
                'selector' => '{{WRAPPER}} .pzy-total-price',
            ]
        );
        $this->add_control(
            'cart_total_price_unit_title',
            [
                'label' => esc_html__('واحد پولی', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::HEADING,
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'cart_total_title_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .pzy-total-price-title' => 'color: {{VALUE}}',
                    '{{WRAPPER}} .pzy-total-price .woocommerce-Price-currencySymbol' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'cart_total_title_typography',
                'selector' => '{{WRAPPER}} .pzy-total-price-title,{{WRAPPER}} .pzy-total-price .woocommerce-Price-currencySymbol',
            ]
        );
        $this->end_controls_section();

        $this->start_controls_section(
            'cart_button',
            [
                'label' => esc_html__('دکمه ثبت سفارش', 'pezeshkyar'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'cart_button_typography',
                'selector' => '{{WRAPPER}} .pzy-minicart-button',
            ]
        );
        $this->add_control(
            'cart_button_bg_color',
            [
                'label' => esc_html__('رنگ پس زمینه', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .pzy-minicart-button' => 'background-color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'cart_button_text_color',
            [
                'label' => esc_html__('رنگ متن', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .pzy-minicart-button' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'cart_button_radius',
            [
                'label' => esc_html__('شعاع', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .pzy-minicart-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'cart_button_padding',
            [
                'label' => esc_html__('فاصله داخلی', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .pzy-minicart-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'cart_button_margin',
            [
                'label' => esc_html__('حاشیه خارجی', 'pezeshkyar'),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%', 'em', 'rem', 'custom'],
                'selectors' => [
                    '{{WRAPPER}} .pzy-minicart-total' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->end_controls_section();

    }

    public function render()
    {
        $cart_icon = $this->get_settings_for_display('show_cart_button_icon');
        ?>
        <div class="pzy-position-relative pzy-d-inline-block">
            <div class="pzy-card-button">
                <span class="shopping-cart"><?php \Elementor\Icons_Manager::render_icon($cart_icon, ['aria-hidden' => 'true', 'className' => 'shopping-cart']); ?></span>
                <span class="card-count pzy-d-flex pzy-align-items-center pzy-justify-content-center pzy-position-absolute"><?php echo WC()->cart->get_cart_contents_count() ?></span>
            </div>
            <div class="pzy-minicart pzy-hide pzy-position-absolute">
                <?php
                pzy_get_mini_cart_content();
                ?>
            </div>
        </div>
        <?php
        echo <<<EOL
<script>
feather.replace();
</script>
EOL;
    }
}