<?php
/**
 * Theme Customizer Controls
 *
 * @package somalite
 */


if ( ! function_exists( 'somalite_customizer_shop_register' ) ) :
function somalite_customizer_shop_register( $wp_customize ) {
     
    if(somalite_is_woocommerce_activated()) :
         //Shop Settings
        $wp_customize->add_section(
            'soma_shop_settings',
            array (
                'priority'      => 25,
                'capability'    => 'edit_theme_options',
                'theme_supports'=> '',
                'title'         => esc_html__( 'Shop Settings', 'somalite' )
            )
        );

        // Title label
        $wp_customize->add_setting( 
            'somalite_label_shop_settings', 
            array(
                  'sanitize_callback' => 'somalite_sanitize_title',
            ) 
        );

        $wp_customize->add_control( 
            new Somalite_Title_Info_Control( $wp_customize, 'somalite_label_shop_settings', 
            array(
                'label'       => esc_html__( 'Shop Settings', 'somalite' ),
                'section'     => 'soma_shop_settings',
                'type'        => 'somalite-title',
                'settings'    => 'somalite_label_shop_settings',
            ) 
        ));

        // Shop Name 
        $wp_customize->add_setting(
            'sm_shop_name',
            array(
                'type' => 'theme_mod',
                'default'           => esc_html__('SHOP','somalite'),
                'sanitize_callback' => 'somalite_sanitize_text_field',            
            )
        );

        $wp_customize->add_control(
            'sm_shop_name',
            array(
                'settings'      => 'sm_shop_name',
                'section'       => 'soma_shop_settings',
                'type'          => 'textbox',
                'label'         => esc_html__( 'Shop Name', 'somalite' ),
                'description'   => '',
            )
        );

        // Title label
        $wp_customize->add_setting( 
            'somalite_label_shop_menu_cart_settings', 
            array(
                  'sanitize_callback' => 'somalite_sanitize_title',
            ) 
        );

        $wp_customize->add_control( 
            new Somalite_Title_Info_Control( $wp_customize, 'somalite_label_shop_menu_cart_settings', 
            array(
                'label'       => esc_html__( 'Menu Cart Settings', 'somalite' ),
                'section'     => 'soma_shop_settings',
                'type'        => 'somalite-title',
                'settings'    => 'somalite_label_shop_menu_cart_settings',
            ) 
        ));

        // cart menu
        $wp_customize->add_setting(
            'sm_menu_cart',
            array(
                'type' => 'theme_mod',
                'default'           => false,
                'sanitize_callback' => 'somalite_sanitize_checkbox'
            )
        );

        $wp_customize->add_control( 
            new Somalite_Toggle_Control( $wp_customize, 'sm_menu_cart', 
            array(
                'section'     => 'soma_shop_settings',
                'type'        => 'somalite-toggle',
                'settings'    => 'sm_menu_cart',
                'label'         => esc_html__( 'Show Menu Cart:', 'somalite' ),
                'description'   => esc_html__( 'This will add a cart icon in primary menu of website', 'somalite' ),
            ) 
        ));

        // Title label
        $wp_customize->add_setting( 
            'somalite_label_shop_button_settings', 
            array(
                  'sanitize_callback' => 'somalite_sanitize_title',
            ) 
        );

        $wp_customize->add_control( 
            new Somalite_Title_Info_Control( $wp_customize, 'somalite_label_shop_button_settings', 
            array(
                'label'       => esc_html__( 'Add to Cart Button Settings', 'somalite' ),
                'section'     => 'soma_shop_settings',
                'type'        => 'somalite-title',
                'settings'    => 'somalite_label_shop_button_settings',
            ) 
        ));

        
        // Add to cart button styles
        $wp_customize->add_setting(
            'sm_addcart_styles',
            array(
                'type' => 'theme_mod',
                'default'           => 'center',
                'sanitize_callback' => 'somalite_sanitize_select'
            )
        );

        $wp_customize->add_control(
            'sm_addcart_styles',
            array(
                'settings'      => 'sm_addcart_styles',
                'section'       => 'soma_shop_settings',
                'type'          => 'radio',
                'label'         => esc_html__( 'Select Add to Cart Button Style:', 'somalite' ),
                'description'   => esc_html__('This will change the add to cart button position on every product item listing','somalite'),
                'choices' => array(
                                'left' => esc_html__('Left Align Button', 'somalite'),
                                'center' => esc_html__('Center Button', 'somalite'),                                
                                ),
            )
        );         
                   

    else:

    	$wp_customize->add_setting( 
	        'sm_label_shop_info_settings', 
	        array(
	            'sanitize_callback' => 'somalite_sanitize_title',
	        ) 
	    );

	    $wp_customize->add_control( 
	        new Somalite_Info_Control( $wp_customize, 'sm_label_shop_info_settings', 
	        array(
	            'label'       => esc_html__( "You need to install and activate the WooCommerce plugin to customize these settings", 'somalite' ),
	            'section'     => 'soma_shop_settings',
	            'type'        => 'somalite-info',
	            'settings'    => 'sm_label_shop_info_settings',
	        ) 
	    ));
    

    endif;
    

}
endif;

add_action( 'customize_register', 'somalite_customizer_shop_register' );