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

if ( ! function_exists( 'nevo_customizer_product_cart_config' ) ) {
	function nevo_customizer_product_cart_config($configs = array()) {
		$section  = 'product_cart';
		$name     = 'product_cart';
		$selector = '.product-content';
		$config   = array(
			array(
				'name'  => $section,
				'type'  => 'section',
				'panel' => 'woocommerce',
				'priority' => 300,
				'title' => __( 'Cart page', 'nevo' ),
			),
			
			array(
				'name'    => $name . '_layout',
				'type'    => 'image_select',
				'priority' => 45,
				'default' => 'cart-1',
				'section' => $section,
				'title'   => __( 'Layout', 'nevo' ),
				'choices' => array(
					'cart-1' => array(
						'img' => esc_url( get_template_directory_uri() ) . '/assets/images/woocommerce/cart-1.jpg',
					),
					'cart-2' => array(
						'img' => esc_url( get_template_directory_uri() ) . '/assets/images/woocommerce/cart-2.jpg',
					),
				),
			),
			
			array(
				'name'       => $name . '_checkout_button',
				'type'       => 'modal',
				'priority'   => 50,
				'section'    => $section,
				'selector'   => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout',
				'css_format' => 'styling',
				'title'      => __( 'Proceed to Checkout Button Style', 'nevo' ),
				'fields'     => array(
					'tabs'           => array(
						'default' => __( 'Normal', 'nevo' ),
						'hover'   => __( 'Hover', 'nevo' ),
					),
					'default_fields' => array(
						array(
							'name'       => $name . '_color',
							'type'       => 'color',
							'device_settings' => false,
							'label'      => __( 'Color', 'nevo' ),
							'selector'   => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a',
							'css_format' => 'color: {{value}}; text-decoration-color: {{value}};',
						),
						array(
							'name'       => $name . '_bg_color',
							'type'       => 'color',
							'device_settings' => false,
							'label'      => __( 'Background Color', 'nevo' ),
							'selector'   => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a',
							'css_format' => 'background-color: {{value}};',
						),
						
						array(
							'name'            => $name . '_padding',
							'type'            => 'css_ruler',
							'device_settings' => false,
							'selector'   	  => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a',
							'css_format'      => array(
								'top'    => 'padding-top: {{value}};',
								'right'  => 'padding-right: {{value}};',
								'bottom' => 'padding-bottom: {{value}};',
								'left'   => 'padding-left: {{value}};',
							),
							'label'           => __( 'Padding', 'nevo' ),
						),
						
						array(
							'name'  => $name . '_border_heading',
							'type'  => 'heading',
							'label' => __( 'Border', 'nevo' ),
						),

						array(
							'name'       => $name . '_border_style',
							'type'       => 'select',
							'class'      => 'clear',
							'selector'   => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a',
							'label'      => __( 'Border Style', 'nevo' ),
							'default'    => '',
							'choices'    => array(
								''       => __( 'Default', 'nevo' ),
								'none'   => __( 'None', 'nevo' ),
								'solid'  => __( 'Solid', 'nevo' ),
								'dotted' => __( 'Dotted', 'nevo' ),
								'dashed' => __( 'Dashed', 'nevo' ),
								'double' => __( 'Double', 'nevo' ),
								'ridge'  => __( 'Ridge', 'nevo' ),
								'inset'  => __( 'Inset', 'nevo' ),
								'outset' => __( 'Outset', 'nevo' ),
							),
							'css_format' => 'border-style: {{value}};',
						),

						array(
							'name'       => $name . '_border_width',
							'type'       => 'css_ruler',
							'label'      => __( 'Border Width', 'nevo' ),
							'selector'   => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a',
							'required'   => array(
								array( $name . '_border_style', '!=', 'none' ),
								array( $name . '_border_style', '!=', '' ),
							),
							'css_format' => array(
								'top'    => 'border-top-width: {{value}};',
								'right'  => 'border-right-width: {{value}};',
								'bottom' => 'border-bottom-width: {{value}};',
								'left'   => 'border-left-width: {{value}};',
							),
						),
						array(
							'name'       => $name . '_border_color',
							'type'       => 'color',
							'label'      => __( 'Border Color', 'nevo' ),
							'selector'   => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a',
							'required'   => array(
								array( $name . '_border_style', '!=', 'none' ),
								array( $name . '_border_style', '!=', '' ),
							),
							'css_format' => 'border-color: {{value}};',
						),

						array(
							'name'       => $name . '_border_radius',
							'type'       => 'css_ruler',
							'label'      => __( 'Border Radius', 'nevo' ),
							'selector'   => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a',
							'css_format' => array(
								'top'    => 'border-top-left-radius: {{value}};',
								'right'  => 'border-top-right-radius: {{value}};',
								'bottom' => 'border-bottom-right-radius: {{value}};',
								'left'   => 'border-bottom-left-radius: {{value}};',
							),
						),
					),
					'hover_fields'   => array(
						array(
							'name'       => $name . '_color',
							'type'       => 'color',
							'device_settings' => false,
							'label'      => __( 'Color', 'nevo' ),
							'selector'   => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a:hover',
							'css_format' => 'color: {{value}}; text-decoration-color: {{value}};',
						),
						array(
							'name'       => $name . '_bg_color',
							'type'       => 'color',
							'device_settings' => false,
							'label'      => __( 'Background Color', 'nevo' ),
							'selector'   => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a:hover',
							'css_format' => 'background-color: {{value}};',
						),
						
						array(
							'name'  => $name . '_border_heading',
							'type'  => 'heading',
							'label' => __( 'Border', 'nevo' ),
						),

						array(
							'name'       => $name . '_border_style',
							'type'       => 'select',
							'class'      => 'clear',
							'selector'   => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a:hover',
							'label'      => __( 'Border Style', 'nevo' ),
							'default'    => '',
							'choices'    => array(
								''       => __( 'Default', 'nevo' ),
								'none'   => __( 'None', 'nevo' ),
								'solid'  => __( 'Solid', 'nevo' ),
								'dotted' => __( 'Dotted', 'nevo' ),
								'dashed' => __( 'Dashed', 'nevo' ),
								'double' => __( 'Double', 'nevo' ),
								'ridge'  => __( 'Ridge', 'nevo' ),
								'inset'  => __( 'Inset', 'nevo' ),
								'outset' => __( 'Outset', 'nevo' ),
							),
							'css_format' => 'border-style: {{value}};',
						),

						array(
							'name'       => $name . '_border_width',
							'type'       => 'css_ruler',
							'label'      => __( 'Border Width', 'nevo' ),
							'selector'   => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a:hover',
							'required'   => array(
								array( $name . '_border_style', '!=', 'none' ),
								array( $name . '_border_style', '!=', '' ),
							),
							'css_format' => array(
								'top'    => 'border-top-width: {{value}};',
								'right'  => 'border-right-width: {{value}};',
								'bottom' => 'border-bottom-width: {{value}};',
								'left'   => 'border-left-width: {{value}};',
							),
						),
						array(
							'name'       => $name . '_border_color',
							'type'       => 'color',
							'label'      => __( 'Border Color', 'nevo' ),
							'selector'   => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a:hover',
							'required'   => array(
								array( $name . '_border_style', '!=', 'none' ),
								array( $name . '_border_style', '!=', '' ),
							),
							'css_format' => 'border-color: {{value}};',
						),

						array(
							'name'       => $name . '_border_radius',
							'type'       => 'css_ruler',
							'label'      => __( 'Border Radius', 'nevo' ),
							'selector'   => '.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a:hover',
							'css_format' => array(
								'top'    => 'border-top-left-radius: {{value}};',
								'right'  => 'border-top-right-radius: {{value}};',
								'bottom' => 'border-bottom-right-radius: {{value}};',
								'left'   => 'border-bottom-left-radius: {{value}};',
							),
						),
					),
				),
			),
			
			array(
				'name'       => $name . '_update_cart',
				'type'       => 'modal',
				'priority'   => 55,
				'section'    => $section,
				'title'      => __( 'Update Cart Button Style', 'nevo' ),
				'selector'   => '.woocommerce-cart .button [name="update_cart"]',
				'css_format' => 'styling',
				'fields'     => array(
					'tabs'          => array(
						'normal' => __( 'Normal', 'nevo' ),
						'hover'  => __( 'Hover', 'nevo' ),
					),
					'normal_fields' => array(
						array(
							'name'       => 'update_cart_color',
							'type'       => 'color',
							'label'      => __( 'Color', 'nevo' ),
							//'default'    => '#ffffff',
							'selector'   => '.woocommerce-cart .button[name="update_cart"]',
							'css_format' => 'color: {{value}}; text-decoration-color: {{value}};',
						),
						array(
							'name'       => 'update_cart_bg_color',
							'type'       => 'color',
							'label'      => __( 'Background Color', 'nevo' ),
							//'default'    => '#909090',
							'selector'   => '.woocommerce-cart .button[name="update_cart"]',
							'css_format' => 'background-color: {{value}};',
						),
					),
					'hover_fields' => array(
						array(
							'name'       => 'update_cart_hover_color',
							'type'       => 'color',
							'label'      => __( 'Color', 'nevo' ),
							//'default'    => '#ffffff',
							'selector'   => '.woocommerce-cart .button[name="update_cart"]:hover',
							'css_format' => 'color: {{value}}; text-decoration-color: {{value}};',
						),
						array(
							'name'       => 'update_cart_hover_bg_color',
							'type'       => 'color',
							'label'      => __( 'Background Color', 'nevo' ),
							//'default'    => '#909090',
							'selector'   => '.woocommerce-cart .button[name="update_cart"]:hover',
							'css_format' => 'background-color: {{value}};',
						),
					),
				),
			),
			
			array(
				'name'            => $name . '_cross_sell',
				'type'            => 'checkbox',
				'default'   	  => 1,
				'section'         => $section,
				'priority' 		  => 80,
				'checkbox_label'  => __( 'Show Cross-sell Product', 'nevo' ),
				'selector'        => $selector,
			),
			
			array(
				'name'            => $name . '_cross_sell_col',
				'type'            => 'select',
				'section'         => $section,
				'priority' 		  => 85,
				'default'         => 2,
				'device_settings' => false,
				'selector'        => $selector,
				'label'           => __( 'Cross-sell Columns', 'nevo' ),
				'choices'         => array(
					1 => 1,
					2 => 2,
					3 => 3,
					4 => 4,
					5 => 5,
					6 => 6,
				),
			),
			
		);

		return array_merge( $configs, $config );
	}
}
add_filter( 'nevo/customizer/config', 'nevo_customizer_product_cart_config', 300 );