<?php
/**
 * Recently Viewed Widget - Content Controls
 *
 * @package GGM_Commerce
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// $this is the GGM_Commerce_Widget_Recently_Viewed instance.

// Content Section.
$this->start_controls_section(
	'section_content',
	array(
		'label' => __( 'Content', 'ggm-commerce' ),
		'tab'   => \Elementor\Controls_Manager::TAB_CONTENT,
	)
);

$this->add_control(
	'title',
	array(
		'label'   => __( 'Section Title', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::TEXT,
		'default' => __( 'Recently Viewed', 'ggm-commerce' ),
	)
);

$this->add_control(
	'show_title',
	array(
		'label'        => __( 'Show Title', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'default'      => 'yes',
		'label_on'     => __( 'Show', 'ggm-commerce' ),
		'label_off'    => __( 'Hide', 'ggm-commerce' ),
		'return_value' => 'yes',
	)
);

$this->add_control(
	'max_products',
	array(
		'label'   => __( 'Max Products', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::NUMBER,
		'min'     => 1,
		'max'     => 12,
		'default' => 4,
	)
);

$this->add_responsive_control(
	'columns',
	array(
		'label'          => __( 'Columns', 'ggm-commerce' ),
		'type'           => \Elementor\Controls_Manager::SELECT,
		'default'        => '4',
		'tablet_default' => '3',
		'mobile_default' => '2',
		'options'        => array(
			'1' => '1',
			'2' => '2',
			'3' => '3',
			'4' => '4',
			'5' => '5',
			'6' => '6',
		),
		'selectors'      => array(
			'{{WRAPPER}} .ggmc-recently-viewed-grid' => 'grid-template-columns: repeat({{VALUE}}, 1fr);',
		),
	)
);

$this->add_control(
	'show_image',
	array(
		'label'        => __( 'Show Image', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'default'      => 'yes',
		'label_on'     => __( 'Show', 'ggm-commerce' ),
		'label_off'    => __( 'Hide', 'ggm-commerce' ),
		'return_value' => 'yes',
	)
);

$this->add_control(
	'show_price',
	array(
		'label'        => __( 'Show Price', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'default'      => 'yes',
		'label_on'     => __( 'Show', 'ggm-commerce' ),
		'label_off'    => __( 'Hide', 'ggm-commerce' ),
		'return_value' => 'yes',
	)
);

$this->add_control(
	'exclude_current',
	array(
		'label'        => __( 'Exclude Current Product', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'default'      => 'yes',
		'label_on'     => __( 'Yes', 'ggm-commerce' ),
		'label_off'    => __( 'No', 'ggm-commerce' ),
		'return_value' => 'yes',
		'description'  => __( 'Exclude the currently viewed product from the list.', 'ggm-commerce' ),
	)
);

$this->add_control(
	'show_add_to_cart',
	array(
		'label'        => __( 'Show Add to Cart', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'default'      => 'yes',
		'label_on'     => __( 'Show', 'ggm-commerce' ),
		'label_off'    => __( 'Hide', 'ggm-commerce' ),
		'return_value' => 'yes',
	)
);

$this->add_control(
	'add_to_cart_text',
	array(
		'label'     => __( 'Button Text', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::TEXT,
		'default'   => __( 'Add to Cart', 'ggm-commerce' ),
		'condition' => array(
			'show_add_to_cart' => 'yes',
		),
	)
);

$this->add_control(
	'empty_message',
	array(
		'label'   => __( 'Empty Message', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::TEXT,
		'default' => __( 'No recently viewed products.', 'ggm-commerce' ),
	)
);

$this->end_controls_section();
