<?php
/**
 * Cart Display Widget — Content Controls
 * Required inside register_controls(); $this is the widget instance.
 */

// If this file is called directly, abort.
if (!defined('ABSPATH')) {
    exit;
}

$this->start_controls_section(
    'content_section',
    [
        'label' => __('Cart Settings', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
    ]
);

$this->add_control(
    'show_empty_message',
    [
        'label' => __('Show Empty Cart Message', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Show', 'ggm-commerce'),
        'label_off' => __('Hide', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => 'yes',
        'description' => __('Display a message when the cart is empty.', 'ggm-commerce'),
    ]
);

$this->add_control(
    'empty_message',
    [
        'label' => __('Empty Cart Message', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::TEXTAREA,
        'default' => __('Your cart is empty.', 'ggm-commerce'),
        'condition' => [
            'show_empty_message' => 'yes',
        ],
        'description' => __('Message to display when cart is empty.', 'ggm-commerce'),
    ]
);

$this->add_control(
    'show_continue_shopping',
    [
        'label' => __('Show Continue Shopping Button', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Show', 'ggm-commerce'),
        'label_off' => __('Hide', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => 'yes',
        'description' => __('Show a button to continue shopping.', 'ggm-commerce'),
    ]
);

$this->add_control(
    'continue_shopping_text',
    [
        'label' => __('Continue Shopping Text', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => __('Continue Shopping', 'ggm-commerce'),
        'condition' => [
            'show_continue_shopping' => 'yes',
        ],
        'description' => __('Text for the continue shopping button.', 'ggm-commerce'),
    ]
);

$this->add_control(
    'continue_shopping_url',
    [
        'label' => __('Continue Shopping URL', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::URL,
        'placeholder' => __('https://your-shop-page.com', 'ggm-commerce'),
        'condition' => [
            'show_continue_shopping' => 'yes',
        ],
        'default' => [
            'url' => home_url('/shop'),
        ],
        'description' => __('URL for the continue shopping button. Leave empty to use default shop page.', 'ggm-commerce'),
    ]
);

$this->add_control(
    'checkout_url',
    [
        'label' => __('Checkout URL', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::URL,
        'placeholder' => __('https://your-site.com/checkout', 'ggm-commerce'),
        'default' => [
            'url' => home_url('/checkout'),
        ],
        'description' => __('URL for the checkout page. Leave empty to use default checkout page.', 'ggm-commerce'),
    ]
);

$this->add_control(
    'quantity_controls_style',
    [
        'label' => __('Quantity Controls Style', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'both',
        'options' => [
            'both' => __('Input Controls & Buttons', 'ggm-commerce'),
            'input_only' => __('Input Controls Only', 'ggm-commerce'),
        ],
        'description' => __('Choose how quantity controls are displayed.', 'ggm-commerce'),
    ]
);

$this->add_control(
    'show_product_images',
    [
        'label' => __('Show Product Images', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Show', 'ggm-commerce'),
        'label_off' => __('Hide', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => 'yes',
        'description' => __('Display product images in the cart table.', 'ggm-commerce'),
    ]
);

$this->add_control(
    'link_product_name',
    [
        'label' => __('Link Product Name', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Yes', 'ggm-commerce'),
        'label_off' => __('No', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => 'yes',
        'description' => __('Link product name to the product page.', 'ggm-commerce'),
    ]
);

$this->add_control(
    'enable_ajax_updates',
    [
        'label' => __('Enable AJAX Updates', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Yes', 'ggm-commerce'),
        'label_off' => __('No', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => 'yes',
        'description' => __('Update cart without page reload when quantities change.', 'ggm-commerce'),
    ]
);

$this->end_controls_section();
