<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

/**
 * Frontpage WooCommerce Options.
 *
 * @package pawfect
 */

if ( ! class_exists( 'Pawfect_Options_WooCommerce' ) ) :

    class Pawfect_Options_WooCommerce extends pawfect_Customize_Base_Option {

        /**
         * Arguments for options.
         *
         * @return array
         */
        public function elements() {

            return array(

                'pawfect_main_woocommerce_heading'    => array(
                    'setting' => array(),
                    'control' => array(
                        'type'     => 'heading',
                        'priority' => 2,
                        'label'    => esc_html__( 'WooCommerce Options', 'pawfect' ),
                        'section'  => 'pawfect_theme_woocommerce',
                    ),
                ),

                 'pawfect_woocommerce_enabled'        => array(
                    'setting' => array(
                        'default'           => true,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                        'transport'         => 'postMessage',
                    ),
                    'control' => array(
                        'type'     => 'toggle',
                        'priority' => 1,
                        'label'    => esc_html__( 'Enable WooCommerce Section', 'pawfect' ),
                        'description' => esc_html__('Toggle ON to show this section', 'pawfect'),
                        'section'  => 'pawfect_theme_woocommerce',
                    ),
                ),

                 'pawfect_woocommerce_subtitle' => array(
                    'setting' => array(
                        'default' => esc_html__('Featured Products', 'pawfect'),
                        'transport' => 'postMessage',
                    ),
                    'control' => array(
                        'type' => 'text',
                        'priority' => 1,
                        'label' => esc_html__('Section Subtitle', 'pawfect'),
                        'section' => 'pawfect_theme_woocommerce',
                        'active_callback' => 'pawfect_woocommerce_enabled',
                    ),
                ),

                 'pawfect_woocommerce_title' => array(
                    'setting' => array(
                        'default' => esc_html__('Happy Customers!', 'pawfect'),
                        'transport' => 'postMessage',
                    ),
                    'control' => array(
                        'type' => 'text',
                        'priority' => 2,
                        'label' => esc_html__('Section Title', 'pawfect'),
                        'section' => 'pawfect_theme_woocommerce',
                        'active_callback' => 'pawfect_woocommerce_enabled',
                    ),
                ),

                 'pawfect_woocommerce_area_des' => array(
                    'setting' => array(
                        'default' => esc_html__('Happy Customers!', 'pawfect'),
                        'transport' => 'postMessage',
                    ),
                    'control' => array(
                        'type' => 'textarea',
                        'priority' => 3,
                        'label' => esc_html__('Section Description', 'pawfect'),
                        'section' => 'pawfect_theme_woocommerce',
                        'active_callback' => 'pawfect_woocommerce_enabled',
                    ),
                ),

               

                'pawfect_woocommerce_autoplay'        => array(
                    'setting' => array(
                        'default'           => true,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                    ),
                    'control' => array(
                        'type'            => 'toggle',
                        'priority'        => 15,
                        'label'           => esc_html__( 'WooCommerce Autoplay', 'pawfect' ),
                        'section'         => 'pawfect_theme_woocommerce',
                         'active_callback' => 'pawfect_woocommerce_enabled',
                    ),
                ),

                'pawfect_woocommerce_animation_speed' => array(
                    'setting' => array(
                        'default'           => '4000',
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_radio' ),
                    ),
                    'control' => array(
                        'type'            => 'select',
                        'priority'        => 20,
                        'is_default_type' => true,
                        'label'           => esc_html__( 'WooCommerce Animation Speed', 'pawfect' ),
                        'description'     => esc_html__( 'Note: Turn on Autoplay', 'pawfect' ),
                        'section'         => 'pawfect_theme_woocommerce',
                        'choices'         => array(
                            '2000' => esc_html__( '2.0', 'pawfect' ),
                            '3000' => esc_html__( '3.0', 'pawfect' ),
                            '4000' => esc_html__( '4.0', 'pawfect' ),
                            '5000' => esc_html__( '5.0', 'pawfect' ),
                            '6000' => esc_html__( '6.0', 'pawfect' ),
                        ),
                        'active_callback' => 'pawfect_woocommerce_enabled',
                    ),
                ),

                'pawfect_woocommerce_container_size'  => array(
                    'setting' => array(
                        'default'           => 'container',
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_radio' ),
                    ),
                    'control' => array(
                        'type'            => 'radio-switch',
                        'priority'        => 25,
                        'is_default_type' => true,
                        'label'           => esc_html__( 'WooCommerce Width', 'pawfect' ),
                        'section'         => 'pawfect_theme_woocommerce',
                        'choices'         => array(
                            'container'      => esc_html__( 'Container', 'pawfect' ),
                            'container-full' => esc_html__( 'Container Full', 'pawfect' ),
                        ),
                         'active_callback' => 'pawfect_woocommerce_enabled',
                    ),
                ),

                'pawfect_woocommerce_column_layout'   => array(
                    'setting' => array(
                        'default'           => 3,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_radio' ),
                    ),
                    'control' => array(
                        'type'            => 'simple-radio-image',
                        'priority'        => 30,
                        'label'           => esc_html__( 'Column Layout', 'pawfect' ),
                        'section'         => 'pawfect_theme_woocommerce',
                        'choices'         => array(
                            '2' => PAWFECT_THEME_URL . '/assets/images/icons/column-2.png',
                            '3' => PAWFECT_THEME_URL . '/assets/images/icons/column-3.png',
                            '4' => PAWFECT_THEME_URL . '/assets/images/icons/column-4.png',
                        ),
                        'active_callback' => 'pawfect_woocommerce_enabled',
                    ),
                ),

                'pawfect_woocommerce_card_style' => array(
                    'setting' => array(
                        'default'           => 'classic',
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_radio' ),
                    ),
                    'control' => array(
                        'type'            => 'radio-switch',
                        'priority'        => 35,
                        'label'           => esc_html__( 'Card Style', 'pawfect' ),
                        'description'     => esc_html__( 'Choose between classic and modern card styles', 'pawfect' ),
                        'section'         => 'pawfect_theme_woocommerce',
                        'choices'         => array(
                            'classic' => esc_html__( 'Classic', 'pawfect' ),
                            'modern'  => esc_html__( 'Modern (Shop by Category Style)', 'pawfect' ),
                        ),
                        'active_callback' => 'pawfect_woocommerce_enabled',
                    ),
                ),
            ); 
        }
    }

    new Pawfect_Options_WooCommerce();

endif;


/**
 * Check if WooCommerce is enabled
 */
function pawfect_woocommerce_enabled($control)
{
    // Following main slider pattern - return true when WooCommerce is enabled
    // This makes other WooCommerce settings visible when main toggle is ON
    return true === ( $control->manager->get_setting( 'pawfect_woocommerce_enabled' )->value() == true );
}



