<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}
if ( ! class_exists( 'Draly_Dropshipping_Starter_Pluggable_WooCommerce' ) ) {
	class Draly_Dropshipping_Starter_Pluggable_WooCommerce {
		/**
		 * Variable to hold the initialization state.
		 *
		 * @var  boolean
		 */
		protected static $initialized = false;

		public static function initialize() {
			// Do nothing if pluggable functions already initialized.
			if ( self::$initialized ) {
				return;
			}
			add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );
			add_filter( 'woocommerce_show_page_title', '__return_false' );
			//BREADCRUMB
			remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
			add_action( 'draly_dropshipping_starter_woocommerce_breadcrumb', array(
				__CLASS__,
				'draly_dropshipping_starter_woocommerce_breadcrumb'
			), 20 );
			//MINI CART
			add_action( 'draly_dropshipping_starter_header_mini_cart', array(
				__CLASS__,
				'draly_dropshipping_starter_header_mini_cart'
			) );
			add_filter( 'woocommerce_add_to_cart_fragments', array(
				__CLASS__,
				'draly_dropshipping_starter_cart_link_fragment'
			) );
			//WRAPPER CONTENT
			remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
			remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description', 10 );
			remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
			remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
			add_action( 'woocommerce_before_main_content', 'woocommerce_product_archive_description', 60 );
			add_action( 'woocommerce_before_main_content', array(
				__CLASS__,
				'draly_dropshipping_starter_before_main_content'
			), 10 );
			add_action( 'woocommerce_before_main_content', array(
				__CLASS__,
				'draly_dropshipping_starter_before_loop_content'
			), 50 );
			add_action( 'woocommerce_after_main_content', array(
				__CLASS__,
				'draly_dropshipping_starter_after_loop_content'
			), 50 );
			add_action( 'woocommerce_sidebar', array( __CLASS__, 'draly_dropshipping_starter_sidebar' ), 10 );
			add_action( 'woocommerce_sidebar', array(
				__CLASS__,
				'draly_dropshipping_starter_after_main_content'
			), 100 );
			add_action( 'woocommerce_before_shop_loop', array(
				__CLASS__,
				'draly_dropshipping_starter_before_shop_loop'
			), 50 );
			add_action( 'woocommerce_after_shop_loop', array(
				__CLASS__,
				'draly_dropshipping_starter_after_shop_loop'
			), 10 );
			//SHOP SINGLE
			add_action( 'woocommerce_before_single_product_summary', array(
				__CLASS__,
				'draly_dropshipping_starter_before_main_content_left'
			), 5 );
			add_action( 'woocommerce_before_single_product_summary', array(
				__CLASS__,
				'draly_dropshipping_starter_after_main_content_left'
			), 50 );
			add_action( 'woocommerce_after_single_product_summary', array(
				__CLASS__,
				'draly_dropshipping_starter_after_single_product_summary_1'
			), 5 );
			add_action( 'woocommerce_after_single_product_summary', array(
				__CLASS__,
				'draly_dropshipping_starter_after_single_product_summary_2'
			), 10 );
			add_action( 'woocommerce_after_add_to_cart_button', array(
				__CLASS__,
				'draly_dropshipping_starter_single_product_share_button'
			), 11 );
			add_filter( 'woocommerce_single_product_image_thumbnail_html', array(
				__CLASS__,
				'draly_dropshipping_starter_single_product_image_thumbnail_html'
			), 10, 2 );
			add_action( 'woocommerce_single_product_summary', array(
				__CLASS__,
				'draly_dropshipping_starter_show_stock_after_price'
			), 10 );
			add_action( 'woocommerce_after_add_to_cart_button', array(
				__CLASS__,
				'draly_dropshipping_starter_buy_now_button'
			), 1 );
			add_filter( 'woocommerce_add_to_cart_redirect', array(
				__CLASS__,
				'draly_dropshipping_starter_buy_now_redirect'
			), 99 );
			add_action( 'wp_loaded', array( __CLASS__, 'draly_dropshipping_starter_add_to_cart_action' ), 100 );
			add_action( 'woocommerce_single_product_summary', array(
				__CLASS__,
				'draly_dropshipping_starter_we_accept'
			), 35 );
			//SHOP CONTROL
			add_action( 'init', array( __CLASS__, 'draly_dropshipping_starter_product_per_page_request' ) );
			add_action( 'init', array( __CLASS__, 'draly_dropshipping_starter_product_display_mode_request' ) );
			add_action( 'draly_dropshipping_starter_control_before_content', array(
				__CLASS__,
				'draly_dropshipping_starter_shop_display_mode_tmp'
			), 5 );
			add_action( 'draly_dropshipping_starter_control_before_content', array(
				__CLASS__,
				'draly_dropshipping_starter_product_per_page_tmp'
			), 10 );
			add_action( 'draly_dropshipping_starter_control_before_content', array(
				__CLASS__,
				'draly_dropshipping_starter_shop_filter_button'
			), 11 );
			add_action( 'draly_dropshipping_starter_control_before_content', 'woocommerce_result_count', 15 );
			add_action( 'draly_dropshipping_starter_control_before_content', 'woocommerce_catalog_ordering', 20 );
			add_action( 'draly_dropshipping_starter_control_after_content', array(
				__CLASS__,
				'draly_dropshipping_starter_custom_pagination'
			), 10 );
			//CUSTOM SHOP CONTROL
			remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
			remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
			remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
			add_action( 'woocommerce_before_shop_loop', array(
				__CLASS__,
				'draly_dropshipping_starter_before_shop_control'
			), 20 );
			add_action( 'woocommerce_after_shop_loop', array(
				__CLASS__,
				'draly_dropshipping_starter_after_shop_control'
			), 50 );
			//CUSTOM PRODUCT POST PER PAGE
			add_filter( 'loop_shop_per_page', array( __CLASS__, 'draly_dropshipping_starter_loop_shop_per_page' ), 20 );
			//CUSTOM PRODUCT NAME
			remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
			add_action( 'woocommerce_shop_loop_item_title', array(
				__CLASS__,
				'draly_dropshipping_starter_template_loop_product_title'
			), 30 );
			//PRODUCT THUMBNAIL
			remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
			add_action( 'woocommerce_before_shop_loop_item_title', array(
				__CLASS__,
				'draly_dropshipping_starter_template_loop_product_thumbnail'
			), 10 );
			//REMOVE "woocommerce_template_loop_product_link_open"
			remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
			remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 );
			//CUSTOM FLASH
			add_action( 'draly_dropshipping_starter_group_flash_content', 'woocommerce_show_product_loop_sale_flash', 5 );
			add_action( 'draly_dropshipping_starter_group_flash_content', array(
				__CLASS__,
				'draly_dropshipping_starter_custom_new_flash'
			), 10 );
			add_filter( 'woocommerce_sale_flash', array( __CLASS__, 'draly_dropshipping_starter_custom_sale_flash' ) );
			remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
			remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
			add_action( 'woocommerce_before_shop_loop_item_title', array(
				__CLASS__,
				'draly_dropshipping_starter_group_flash'
			), 10 );
			add_action( 'woocommerce_single_product_summary', array(
				__CLASS__,
				'draly_dropshipping_starter_group_flash'
			), 1 );
			//RELATED UPSELL CROSSSELL
			remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
			add_action( 'woocommerce_sidebar', array( __CLASS__, 'draly_dropshipping_starter_related_products' ), 50 );
			add_action( 'draly_dropshipping_starter_before_related_single_product', array(
				__CLASS__,
				'draly_dropshipping_starter_related_title_product'
			) );
			remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
			add_action( 'woocommerce_sidebar', array( __CLASS__, 'draly_dropshipping_starter_upsell_display' ), 50 );
			remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
			add_action( 'woocommerce_after_cart', array(
				__CLASS__,
				'draly_dropshipping_starter_cross_sell_products'
			) );
			//CHECKOUT
			remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
			remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
			add_action( 'woocommerce_before_checkout_form', array(
				__CLASS__,
				'draly_dropshipping_starter_checkout_login_open'
			), 1 );
			add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 5 );
			add_action( 'woocommerce_before_checkout_form', array(
				__CLASS__,
				'draly_dropshipping_starter_checkout_login_close'
			), 6 );
			add_action( 'woocommerce_before_checkout_form', array(
				__CLASS__,
				'draly_dropshipping_starter_checkout_coupon_open'
			), 7 );
			add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
			add_action( 'woocommerce_before_checkout_form', array(
				__CLASS__,
				'draly_dropshipping_starter_checkout_coupon_close'
			), 11 );
			add_action( 'woocommerce_checkout_before_order_review_heading', array(
				__CLASS__,
				'draly_dropshipping_starter_checkout_before_order_review_heading'
			), 5 );
			add_action( 'woocommerce_checkout_after_order_review', array(
				__CLASS__,
				'draly_dropshipping_starter_checkout_after_order_review'
			), 5 );
			//REVERSE PRICE
			add_filter( 'woocommerce_get_price_html', array(
				__CLASS__,
				'draly_dropshipping_starter_reverse_price_html'
			), 100, 2 );
			//RATTING
			add_filter( 'woocommerce_product_get_rating_html', array(
				__CLASS__,
				'draly_dropshipping_starter_get_star_rating_html'
			), 10, 3 );
			//CUSTOM PRODUCT CATEGORY
			add_action( 'draly_dropshipping_starter_template_loop_product_category', array(
				__CLASS__,
				'draly_dropshipping_starter_template_loop_product_category'
			), 5 );
			//TAB AJAX
			add_action( 'wp_ajax_draly_dropshipping_starter_ajax_tabs', array(
				__CLASS__,
				'draly_dropshipping_starter_ajax_tabs'
			) );
			add_action( 'wp_ajax_nopriv_draly_dropshipping_starter_ajax_tabs', array(
				__CLASS__,
				'draly_dropshipping_starter_ajax_tabs'
			) );
			// State that initialization completed.
			self::$initialized = true;
		}

		//BREADCRUMB
		public static function draly_dropshipping_starter_woocommerce_breadcrumb() {
			$args = array(
				'delimiter' => '<span class="breadcrumb-sep"></span>',
			);
			woocommerce_breadcrumb( $args );
		}

		//HOOK MINI CART
		public static function draly_dropshipping_starter_header_mini_cart() {
			$minicart_class   = array( 'block-minicart block-woo draly-dropdown' );
			$minicart_class[] = 'minicart-dropdown';
			?>
            <div class="<?php echo esc_attr( implode( ' ', $minicart_class ) ); ?>">
                <div class="shopcart-dropdown block-cart-link"
                     data-draly="<?php echo ( ! is_cart() && ! is_checkout() ) ? esc_attr( 'draly-dropdown' ) : '' ?>">
                    <a class="block-link link-dropdown" href="<?php echo wc_get_cart_url(); ?>">
                    <span class="block-icon">
                        <svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
                            <path d="M28.2921 7.51071C28.0753 9.81062 27.5215 12.0662 26.6486 14.205C26.3946 14.8222 25.9905 15.3661 25.4729 15.7875C24.9554 16.2088 24.3408 16.4943 23.685 16.6179C22.3136 16.8857 20.2328 17.1536 17.4107 17.1536C15.7359 17.161 14.0623 17.0594 12.4007 16.8493C10.035 16.545 8.3657 14.61 7.98642 12.255L6.87213 5.37H26.25C27.4328 5.37 28.4036 6.33214 28.2921 7.51071Z"
                                  stroke="currentColor" stroke-width="1.5" stroke-linecap="round"
                                  stroke-linejoin="round"/>
                            <path d="M25.1785 22.5128H13.29C12.2723 22.5127 11.2878 22.1504 10.5128 21.4909C9.73781 20.8313 9.22281 19.9174 9.05997 18.9128L7.0114 6.29141C6.84857 5.28682 6.33357 4.37297 5.55855 3.71338C4.78354 3.05379 3.7991 2.69153 2.7814 2.69141H1.60712M10.9371 27.3086C11.2605 27.3222 11.5834 27.2703 11.8862 27.156C12.1891 27.0417 12.4657 26.8672 12.6993 26.6432C12.933 26.4192 13.119 26.1502 13.246 25.8525C13.373 25.5548 13.4385 25.2344 13.4385 24.9107C13.4385 24.587 13.373 24.2666 13.246 23.9689C13.119 23.6711 12.933 23.4022 12.6993 23.1782C12.4657 22.9541 12.1891 22.7797 11.8862 22.6654C11.5834 22.551 11.2605 22.4992 10.9371 22.5128C10.3187 22.539 9.73431 22.803 9.30598 23.2499C8.87765 23.6967 8.63851 24.2917 8.63851 24.9107C8.63851 25.5297 8.87765 26.1247 9.30598 26.5715C9.73431 27.0183 10.3187 27.2824 10.9371 27.3086Z"
                                  stroke="currentColor" stroke-width="1.5" stroke-linecap="round"
                                  stroke-linejoin="round"/>
                            <path d="M25.1785 27.3085C25.502 27.3222 25.8248 27.2703 26.1277 27.156C26.4305 27.0416 26.7071 26.8672 26.9408 26.6432C27.1744 26.4192 27.3604 26.1502 27.4874 25.8525C27.6145 25.5548 27.6799 25.2344 27.6799 24.9107C27.6799 24.587 27.6145 24.2666 27.4874 23.9689C27.3604 23.6711 27.1744 23.4022 26.9408 23.1781C26.7071 22.9541 26.4305 22.7797 26.1277 22.6654C25.8248 22.551 25.502 22.4991 25.1785 22.5128C24.5601 22.539 23.9757 22.803 23.5474 23.2499C23.1191 23.6967 22.8799 24.2917 22.8799 24.9107C22.8799 25.5296 23.1191 26.1247 23.5474 26.5715C23.9757 27.0183 24.5601 27.2824 25.1785 27.3085Z"
                                  stroke="currentColor" stroke-width="1.5" stroke-linecap="round"
                                  stroke-linejoin="round"/>
                        </svg>
                        <span class="count"><?php echo WC()->cart->get_cart_contents_count(); ?></span>
                    </span>
                        <span class="block-text">
                        <span><?php echo esc_html__( 'My Cart', 'draly-dropshipping-starter' ); ?></span>
                        <strong class="total"><?php echo WC()->cart->get_cart_subtotal(); ?></strong>
                    </span>
                    </a>
                </div>
				<?php
				the_widget( 'WC_Widget_Cart', array(), array(
					'title'        => apply_filters( 'draly_dropshipping_starter_mini_cart_title', esc_html__( 'Your Cart', 'draly-dropshipping-starter' ) ),
					'before_title' => '<h2 class="widgettitle">',
					'after_title'  => '<span data-draly="draly-dropdown"><a href="' . wc_get_cart_url() . '" class="close-minicart"><svg width="29" height="29" viewBox="0 0 29 29" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7.07104 21.2132L21.2132 7.07109" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M7.07104 7.07108L21.2132 21.2132" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg></a></span></h2>',
				) );
				?>
            </div>
			<?php
		}

		public static function draly_dropshipping_starter_cart_link_fragment( $fragments ) {
			ob_start();
			$count    = WC()->cart->get_cart_contents_count();
			$subtotal = WC()->cart->get_cart_subtotal();

			$fragments['.block-cart-link .count'] = '<span class="count">' . esc_html( $count ) . '</span>';
			$fragments['.block-cart-link .total'] = '<strong class="total">' . wp_kses_post( $subtotal ) . '</strong>';

			return $fragments;
		}

		//WRAPPER CONTENT
		public static function draly_dropshipping_starter_product_per_page_request() {
			if ( isset( $_POST['perpage_action_form'] ) ) {
				wp_safe_redirect(
					add_query_arg(
						array(
							'product_per_page' => $_POST['product_per_page_filter'],
						), $_POST['perpage_action_form']
					)
				);
				exit();
			}
		}

		public static function draly_dropshipping_starter_product_display_mode_request() {
			if ( isset( $_POST['display_mode_action'] ) ) {
				wp_safe_redirect(
					add_query_arg(
						array(
							'shop_display_mode' => $_POST['display_mode_value'],
						), $_POST['display_mode_action']
					)
				);
				exit();
			}
		}

		public static function draly_dropshipping_starter_before_main_content() {
			$shop_filter_layout     = Draly_Dropshipping_Starter_Helper::get_option( 'shop_filter_layout', 'default' );
			$sidebar_layout         = Draly_Dropshipping_Starter_Helper::get_option( 'shop_sidebar_layout', 'left' );
			$sidebar_isset          = wp_get_sidebars_widgets();
			$sidebar_id             = 'widget-shop';
			$main_container_classes = array( 'main-container' );
			if ( is_product() ) {
				$sidebar_layout = Draly_Dropshipping_Starter_Helper::get_option( 'product_sidebar_layout', 'left' );
				$sidebar_id     = 'widget-product';
			} else {
				$main_container_classes[] = 'shop-page draly-dropdown';
				$main_container_classes[] = $shop_filter_layout;
				if ( $shop_filter_layout != 'default' ) {
					$sidebar_layout = 'full';
				}
			}
			if ( empty( $sidebar_isset[ $sidebar_id ] ) ) {
				$sidebar_layout = 'full';
			}
			if ( $sidebar_layout == 'full' ) {
				$main_container_classes[] = 'no-sidebar';
			} else {
				$main_container_classes[] = $sidebar_layout . '-sidebar';
			}
			$main_container_classes = apply_filters( 'draly_dropshipping_starter_class_before_main_content_product', $main_container_classes, $sidebar_layout );
			echo '<div id="content" class="' . esc_attr( implode( ' ', $main_container_classes ) ) . '">';
			echo '<div class="container">';
			echo '<div class="row">';
		}

		public static function draly_dropshipping_starter_before_loop_content() {
			$shop_filter_layout = Draly_Dropshipping_Starter_Helper::get_option( 'shop_filter_layout', 'default' );
			$sidebar_layout     = Draly_Dropshipping_Starter_Helper::get_option( 'shop_sidebar_layout', 'left' );
			$sidebar_isset      = wp_get_sidebars_widgets();
			$sidebar_id         = 'widget-shop';
			if ( is_product() ) {
				$sidebar_layout = Draly_Dropshipping_Starter_Helper::get_option( 'product_sidebar_layout', 'left' );
				$sidebar_id     = 'widget-product';
			} else {
				if ( $shop_filter_layout != 'default' ) {
					$sidebar_layout = 'full';
				}
			}
			if ( empty( $sidebar_isset[ $sidebar_id ] ) ) {
				$sidebar_layout = 'full';
			}
			$main_content_classes = array( 'main-content', 'col-12' );
			if ( $sidebar_layout != 'full' ) {
				$main_content_classes[] = 'col-xl-9 col-lg-8 has-sidebar';
			}
			$main_content_classes = apply_filters( 'draly_dropshipping_starter_class_archive_content', $main_content_classes, $sidebar_layout );
			echo '<div class="' . esc_attr( implode( ' ', $main_content_classes ) ) . '">';
		}

		public static function draly_dropshipping_starter_after_loop_content() {
			echo '</div>';
		}

		public static function draly_dropshipping_starter_sidebar() {
			$shop_filter_layout = Draly_Dropshipping_Starter_Helper::get_option( 'shop_filter_layout', 'default' );
			$sidebar_layout     = Draly_Dropshipping_Starter_Helper::get_option( 'shop_sidebar_layout', 'left' );
			$sidebar_isset      = wp_get_sidebars_widgets();
			$sidebar_id         = 'widget-shop';
			if ( is_product() ) {
				$sidebar_layout = Draly_Dropshipping_Starter_Helper::get_option( 'product_sidebar_layout', 'left' );
				$sidebar_id     = 'widget-product';
			} else {
				if ( $shop_filter_layout != 'default' ) {
					$sidebar_layout = 'full';
				}
			}
			if ( empty( $sidebar_isset[ $sidebar_id ] ) ) {
				$sidebar_layout = 'full';
			}
			$sidebar_classes = array( 'sidebar', 'col-xl-3', 'col-lg-4', 'col-12' );
			$sidebar_classes = apply_filters( 'draly_dropshipping_starter_class_sidebar_content_product', $sidebar_classes, $sidebar_layout, $sidebar_id );
			if ( $sidebar_layout != "full" ): ?>
                <div class="<?php echo esc_attr( implode( ' ', $sidebar_classes ) ); ?>">
					<?php if ( is_active_sidebar( $sidebar_id ) ) : ?>
                        <div id="widget-area" class="widget-area shop-sidebar">
							<?php dynamic_sidebar( $sidebar_id ); ?>
                        </div>
					<?php endif; ?>
                </div>
			<?php endif;
		}

		public static function draly_dropshipping_starter_after_main_content() {
			echo '</div></div></div>';
		}

		public static function draly_dropshipping_starter_before_shop_loop() {
			$draly_dropshipping_starter_products_wrap_classes   = array( 'draly-products-wrap' );
			$draly_dropshipping_starter_products_wrap_classes[] = Draly_Dropshipping_Starter_Helper::get_option( 'shop_style', 'grid' );
			echo '<div class="' . esc_attr( implode( ' ', $draly_dropshipping_starter_products_wrap_classes ) ) . '">';
		}

		public static function draly_dropshipping_starter_after_shop_loop() {
			echo '</div>';
		}

		//SHOP SINGLE
		public static function draly_dropshipping_starter_before_main_content_left() {
			global $product;
			$classes        = 'no-gallery ';
			$attachment_ids = $product->get_gallery_image_ids();
			if ( $attachment_ids && has_post_thumbnail() ) {
				$classes = 'has-gallery ';
			}
			$product_style = get_post_meta( $product->get_id(), 'product_style', true );
			if ( isset( $product_style ) && $product_style != 'global' ) {
				$classes .= $product_style;
			} else {
				$classes .= Draly_Dropshipping_Starter_Helper::get_option( 'product_style', 'horizontal_thumbnail' );
			}
			echo '<div class="main-contain-summary"><div class="contain-left ' . esc_attr( $classes ) . '"><div class="single-left">';
		}

		public static function draly_dropshipping_starter_after_main_content_left() {
			echo '</div>';
		}

		public static function draly_dropshipping_starter_after_single_product_summary_1() {
			echo '</div>';
		}

		public static function draly_dropshipping_starter_after_single_product_summary_2() {
			echo '</div>';
		}

		public static function draly_dropshipping_starter_single_product_share_button() {
			$enable_product_shares = Draly_Dropshipping_Starter_Helper::get_option( 'enable_product_shares' );
			if ( ! empty( $enable_product_shares ) ) {
				?>
                <div class="product-share-button draly-dropdown">
                    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" data-draly="draly-dropdown">
						<?php echo apply_filters( 'draly_dropshipping_starter_product_share_icon', '<svg width="14" height="16" viewBox="0 0 14 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><g><path d="M11.1546 9.86015C10.7634 9.85948 10.3763 9.94664 10.018 10.1161C9.65963 10.2855 9.3378 10.5336 9.0729 10.8444L5.59649 8.74489C5.65284 8.50127 5.6814 8.25111 5.68154 8C5.68249 7.7455 5.65392 7.49187 5.59649 7.24504L9.06577 5.15556C9.53557 5.70218 10.1739 6.04481 10.8611 6.11914C11.5482 6.19346 12.2368 5.99437 12.7976 5.55923C13.3584 5.12409 13.753 4.48283 13.9071 3.75581C14.0612 3.0288 13.9643 2.26603 13.6346 1.61069C13.305 0.95534 12.7652 0.452485 12.1166 0.196512C11.468 -0.0594613 10.7552 -0.05095 10.1119 0.220448C9.46874 0.491846 8.93936 1.00747 8.62318 1.67052C8.30701 2.33358 8.22578 3.09848 8.39474 3.82163L4.92821 5.91408C4.66367 5.60154 4.3415 5.35225 3.98243 5.18222C3.62335 5.01219 3.23531 4.9252 2.84324 4.92682C2.37053 4.92628 1.90517 5.05307 1.48925 5.2957C1.07334 5.53834 0.720021 5.88917 0.461266 6.31643C0.202511 6.74369 0.046492 7.2339 0.007331 7.74269C-0.03183 8.25148 0.047103 8.76278 0.236986 9.23032C0.426868 9.69787 0.721706 10.1069 1.09481 10.4204C1.46792 10.7338 1.90752 10.9419 2.37382 11.0257C2.84012 11.1094 3.3184 11.0663 3.76537 10.9001C4.21235 10.734 4.6139 10.4501 4.93369 10.0741L8.40461 12.1695C8.34538 12.4173 8.31534 12.6721 8.31518 12.928C8.31518 13.5354 8.48198 14.1291 8.79449 14.6341C9.10699 15.1391 9.55115 15.5326 10.0708 15.7649C10.5904 15.9971 11.1621 16.0577 11.7137 15.939C12.2652 15.8202 12.7717 15.5275 13.1691 15.0977C13.5665 14.668 13.837 14.1206 13.9463 13.5248C14.0556 12.929 13.9989 12.3116 13.7832 11.7506C13.5676 11.1897 13.2027 10.7104 12.7348 10.3735C12.2669 10.0365 11.7169 9.85708 11.1546 9.85778V9.86015ZM11.1546 4.63052C10.8692 4.63064 10.5903 4.53935 10.353 4.36821C10.1157 4.19707 9.93071 3.95376 9.82146 3.66906C9.71222 3.38436 9.68361 3.07107 9.73925 2.76881C9.79489 2.46654 9.93228 2.18889 10.134 1.97098C10.3358 1.75306 10.5929 1.60467 10.8727 1.54458C11.1526 1.48448 11.4427 1.51538 11.7063 1.63337C11.9699 1.75136 12.1952 1.95114 12.3536 2.20743C12.5121 2.46372 12.5966 2.76501 12.5965 3.07319C12.5961 3.48607 12.444 3.88192 12.1737 4.17387C11.9034 4.46583 11.5369 4.63005 11.1546 4.63052ZM11.1546 11.3695C11.4399 11.3696 11.7187 11.4611 11.9559 11.6324C12.193 11.8037 12.3778 12.047 12.4869 12.3318C12.596 12.6165 12.6244 12.9297 12.5687 13.2319C12.5129 13.5341 12.3754 13.8117 12.1736 14.0294C11.9718 14.2472 11.7147 14.3955 11.4349 14.4555C11.1551 14.5155 10.865 14.4845 10.6015 14.3665C10.338 14.2485 10.1128 14.0487 9.95435 13.7925C9.79594 13.5362 9.71145 13.2349 9.71156 12.9268C9.71199 12.5137 9.8642 12.1177 10.1348 11.8257C10.4053 11.5337 10.7721 11.3696 11.1546 11.3695ZM2.84544 9.55437C2.55998 9.55449 2.28091 9.46313 2.04355 9.29185C1.8062 9.12058 1.62123 8.8771 1.51207 8.59223C1.4029 8.30736 1.37445 7.99391 1.43031 7.69157C1.48618 7.38922 1.62384 7.11158 1.82588 6.89378C2.02792 6.67598 2.28525 6.52783 2.5653 6.46807C2.84534 6.40831 3.1355 6.43963 3.39905 6.55808C3.6626 6.67652 3.88769 6.87676 4.04582 7.13344C4.20395 7.39012 4.28801 7.6917 4.28735 8C4.28619 8.41238 4.13382 8.80746 3.86358 9.09877C3.59334 9.39009 3.22725 9.55391 2.84544 9.55437Z" fill="currentColor"/></g><defs><clipPath><rect width="14" height="16" fill="white"/></clipPath></defs></svg>' ); ?>
                        <span class="social-label"><?php echo esc_html__( 'Share:', 'draly-dropshipping-starter' ) ?></span>
                    </a>
					<?php get_template_part( 'template-parts/share', 'button' ); ?>
                </div>
			<?php }
		}

		public static function draly_dropshipping_starter_single_product_image_thumbnail_html( $html, $post_thumbnail_id ) {
			global $product;

			if ( $post_thumbnail_id ) {
				if ( empty( wp_get_attachment_url( $post_thumbnail_id ) ) ) {
					$post_thumbnail_id = get_option( 'woocommerce_placeholder_image', 0 );
				}
				$html = wc_get_gallery_image_html( $post_thumbnail_id, true );
			} else {
				$wrapper_classname = $product->is_type( 'variable' ) && ! empty( $product->get_available_variations( 'image' ) )
					? 'woocommerce-product-gallery__image woocommerce-product-gallery__image--placeholder'
					: 'woocommerce-product-gallery__image--placeholder';

				$html = sprintf( '<div class="%s">', esc_attr( $wrapper_classname ) );
				$html .= sprintf(
					'<img src="%s" alt="%s" class="wp-post-image" />',
					esc_url( wc_placeholder_img_src( 'woocommerce_single' ) ),
					esc_html__( 'Awaiting product image', 'draly-dropshipping-starter' )
				);
				$html .= '</div>';
			}

			return $html;
		}

		public static function draly_dropshipping_starter_show_stock_after_price() {
			global $product;
			if ( $product->is_type( 'simple' ) ) {
				echo wp_kses_post( wc_get_stock_html( $product ) );
			}
		}

		public static function draly_dropshipping_starter_buy_now_button() {
			if ( ! is_singular( 'product' ) ) {
				return;
			}
			echo '<button type="submit" name="buy_now" value="' . esc_attr( get_the_ID() ) . '" class="product-buy-now button">' . esc_html__( 'Buy Now', 'draly-dropshipping-starter' ) . '</button>';
		}

		public static function draly_dropshipping_starter_buy_now_redirect( $url ) {
			if ( ! isset( $_REQUEST['buy_now'] ) ) {
				return $url;
			}
			$url = wc_get_checkout_url();

			return $url;
		}

		public static function draly_dropshipping_starter_add_to_cart_action() {
			if ( empty( $_REQUEST['buy_now'] ) ) {
				return;
			}

			if ( isset( $_REQUEST['variation_id'] ) ) {
				if ( empty( $_REQUEST['variation_id'] ) ) { //phpcs:ignore
					return;
				}
			}

			if ( isset( $_REQUEST['quantity'] ) ) {
				if ( is_array( $_REQUEST['quantity'] ) ) { //phpcs:ignore
					$quantity_arr = array_map( 'sanitize_text_field', $_REQUEST['quantity'] ); //phpcs:ignore
					foreach ( $quantity_arr as $quantity ) {
						if ( ! $quantity ) {
							return;
						}
					}
				}
			}

			if ( ! isset( $_REQUEST['add-to-cart'] ) || sanitize_text_field( wp_unslash( $_REQUEST['add-to-cart'] ) ) !== sanitize_text_field( wp_unslash( $_REQUEST['buy_now'] ) ) ) { //phpcs:ignore
				$_REQUEST['add-to-cart'] = sanitize_text_field( wp_unslash( $_REQUEST['buy_now'] ) ); //phpcs:ignore
			}

			WC_Form_Handler::add_to_cart_action();
		}

		public static function draly_dropshipping_starter_we_accept() {
			$we_accept_title     = Draly_Dropshipping_Starter_Helper::get_option( 'we_accept_title' );
			$we_accept_image     = Draly_Dropshipping_Starter_Helper::get_option( 'we_accept_image' );
			$we_accept_image_url = ! empty( $we_accept_image['url'] ) ? $we_accept_image['url'] : '';
			$we_accept_image_alt = ! empty( $we_accept_image['alt'] ) ? $we_accept_image['alt'] : get_bloginfo( 'name' );
			if ( ! empty( $we_accept_title ) && ! empty( $we_accept_image_url ) ) { ?>
                <div class="draly-we-accept">
                    <span class="we-accept-title"><?php echo esc_html( $we_accept_title ) ?></span>
                    <img alt="<?php esc_attr( $we_accept_image_alt ) ?>"
                         src="<?php echo esc_url( $we_accept_image_url ); ?>"/>
                </div>
			<?php }
		}

		//SHOP CONTROL
		public static function draly_dropshipping_starter_shop_filter_button() {
			$shop_filter_layout = Draly_Dropshipping_Starter_Helper::get_option( 'shop_filter_layout', 'default' );
			$sidebar_layout     = Draly_Dropshipping_Starter_Helper::get_option( 'shop_sidebar_layout', 'left' );
			$sidebar_isset      = wp_get_sidebars_widgets();
			$sidebar_id         = 'widget-shop';
			?>
            <div class="draly-filter-button-wrap" data-draly="draly-dropdown">
                <a class="draly-filter-button" href="#">
                    <svg width="19" height="19" viewBox="0 0 19 19" fill="none" xmlns="http://www.w3.org/2000/svg">
                        <path d="M16.8226 9.50002H7.04155M3.58909 9.50002H2.17676M3.58909 9.50002C3.58909 9.0423 3.77092 8.60332 4.09458 8.27967C4.41823 7.95601 4.85721 7.77418 5.31492 7.77418C5.77264 7.77418 6.21162 7.95601 6.53527 8.27967C6.85893 8.60332 7.04076 9.0423 7.04076 9.50002C7.04076 9.95773 6.85893 10.3967 6.53527 10.7204C6.21162 11.044 5.77264 11.2258 5.31492 11.2258C4.85721 11.2258 4.41823 11.044 4.09458 10.7204C3.77092 10.3967 3.58909 9.95773 3.58909 9.50002ZM16.8226 14.7306H12.2721M12.2721 14.7306C12.2721 15.1884 12.0898 15.6279 11.7661 15.9516C11.4424 16.2753 11.0033 16.4572 10.5455 16.4572C10.0877 16.4572 9.64877 16.2746 9.32512 15.9509C9.00146 15.6272 8.81963 15.1883 8.81963 14.7306M12.2721 14.7306C12.2721 14.2727 12.0898 13.8341 11.7661 13.5103C11.4424 13.1866 11.0033 13.0047 10.5455 13.0047C10.0877 13.0047 9.64877 13.1866 9.32512 13.5102C9.00146 13.8339 8.81963 14.2728 8.81963 14.7306M8.81963 14.7306H2.17676M16.8226 4.26947H14.3645M10.912 4.26947H2.17676M10.912 4.26947C10.912 3.81175 11.0938 3.37278 11.4175 3.04912C11.7411 2.72547 12.1801 2.54364 12.6378 2.54364C12.8645 2.54364 13.0889 2.58828 13.2983 2.67501C13.5077 2.76174 13.6979 2.88887 13.8582 3.04912C14.0184 3.20938 14.1456 3.39964 14.2323 3.60903C14.319 3.81841 14.3637 4.04283 14.3637 4.26947C14.3637 4.49611 14.319 4.72053 14.2323 4.92992C14.1456 5.13931 14.0184 5.32956 13.8582 5.48982C13.6979 5.65008 13.5077 5.7772 13.2983 5.86394C13.0889 5.95067 12.8645 5.99531 12.6378 5.99531C12.1801 5.99531 11.7411 5.81348 11.4175 5.48982C11.0938 5.16617 10.912 4.72719 10.912 4.26947Z"
                              stroke="currentColor" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round"/>
                    </svg>
                </a>
            </div>
			<?php
			if ( $shop_filter_layout == 'default' || $sidebar_layout == 'full' || empty( $sidebar_isset[ $sidebar_id ] ) ) {
				return;
			}
			?>
			<?php if ( is_active_sidebar( $sidebar_id ) ) : ?>
                <div class="shop-sidebar-filter">
					<?php dynamic_sidebar( $sidebar_id ); ?>
                </div>
			<?php endif; ?>
			<?php
		}

		public static function draly_dropshipping_starter_shop_display_mode_tmp() {
			global $wp;
			if ( '' === get_option( 'permalink_structure' ) ) {
				$form_action = remove_query_arg( array(
					'page',
					'paged',
					'product-page'
				), add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) );
			} else {
				$form_action = preg_replace( '%\/page/[0-9]+%', '', home_url( trailingslashit( $wp->request ) ) );
			}
			$shop_display_mode = Draly_Dropshipping_Starter_Helper::get_option( 'shop_style', 'grid' );
			?>
            <div class="grid-view-mode">
                <form method="get" action="<?php echo esc_url( $form_action ); ?>">
                    <button type="submit" value="grid" name="shop_style"
                            class="modes-mode mode-grid display-mode <?php if ( $shop_display_mode == 'grid' ): ?>active<?php endif; ?>">
                    <span class="button-inner">
                        <svg width="19" height="19" viewBox="0 0 19 19" fill="currentColor"
                             xmlns="http://www.w3.org/2000/svg"><g><path
                                        d="M6.55699 8.58371H1.91431C1.40673 8.58329 0.920065 8.37879 0.561153 8.01511C0.202242 7.65144 0.000421051 7.15831 0 6.644L0 1.93971C0.000421051 1.4254 0.202242 0.932274 0.561153 0.5686C0.920065 0.204926 1.40673 0.000426639 1.91431 0L6.55699 0C7.06457 0.000426639 7.55123 0.204926 7.91014 0.5686C8.26906 0.932274 8.47088 1.4254 8.4713 1.93971V6.644C8.47088 7.15831 8.26906 7.65144 7.91014 8.01511C7.55123 8.37879 7.06457 8.58329 6.55699 8.58371ZM1.91431 1.61106C1.82829 1.61106 1.74579 1.64568 1.68496 1.70732C1.62413 1.76895 1.58996 1.85255 1.58996 1.93971V6.644C1.58996 6.73116 1.62413 6.81476 1.68496 6.87639C1.74579 6.93803 1.82829 6.97265 1.91431 6.97265H6.55699C6.64301 6.97265 6.72551 6.93803 6.78634 6.87639C6.84717 6.81476 6.88134 6.73116 6.88134 6.644V1.93971C6.88134 1.85255 6.84717 1.76895 6.78634 1.70732C6.72551 1.64568 6.64301 1.61106 6.55699 1.61106H1.91431Z"
                                        fill="currentColor"/><path
                                        d="M6.55699 19H1.91431C1.40673 18.9996 0.920065 18.7951 0.561153 18.4314C0.202242 18.0677 0.000421051 17.5746 0 17.0603L0 12.356C0.000631105 11.8418 0.202519 11.3488 0.561385 10.9851C0.920251 10.6215 1.4068 10.4169 1.91431 10.4163H6.55699C7.0645 10.4169 7.55105 10.6215 7.90991 10.9851C8.26878 11.3488 8.47067 11.8418 8.4713 12.356V17.0603C8.47088 17.5746 8.26906 18.0677 7.91014 18.4314C7.55123 18.7951 7.06457 18.9996 6.55699 19ZM1.91431 12.0273C1.87172 12.0273 1.82954 12.0358 1.79019 12.0524C1.75083 12.0689 1.71508 12.0931 1.68496 12.1236C1.65484 12.1541 1.63095 12.1904 1.61465 12.2302C1.59835 12.2701 1.58996 12.3128 1.58996 12.356V17.0603C1.58996 17.1475 1.62413 17.2311 1.68496 17.2927C1.74579 17.3543 1.82829 17.3889 1.91431 17.3889H6.55699C6.64301 17.3889 6.72551 17.3543 6.78634 17.2927C6.84717 17.2311 6.88134 17.1475 6.88134 17.0603V12.356C6.88134 12.2688 6.84717 12.1852 6.78634 12.1236C6.72551 12.062 6.64301 12.0273 6.55699 12.0273H1.91431Z"
                                        fill="currentColor"/><path
                                        d="M17.0853 8.58371H12.4426C11.9351 8.58329 11.4484 8.37879 11.0895 8.01511C10.7306 7.65144 10.5287 7.15831 10.5283 6.644V1.93971C10.5287 1.4254 10.7306 0.932274 11.0895 0.5686C11.4484 0.204926 11.9351 0.000426639 12.4426 0L17.0853 0C17.5929 0.000426639 18.0796 0.204926 18.4385 0.5686C18.7974 0.932274 18.9992 1.4254 18.9996 1.93971V6.644C18.9992 7.15831 18.7974 7.65144 18.4385 8.01511C18.0796 8.37879 17.5929 8.58329 17.0853 8.58371ZM12.4426 1.61106C12.4 1.61106 12.3579 1.61956 12.3185 1.63607C12.2792 1.65259 12.2434 1.6768 12.2133 1.70732C12.1832 1.73784 12.1593 1.77407 12.143 1.81394C12.1267 1.85382 12.1183 1.89655 12.1183 1.93971V6.644C12.1183 6.68716 12.1267 6.7299 12.143 6.76977C12.1593 6.80965 12.1832 6.84588 12.2133 6.87639C12.2434 6.90691 12.2792 6.93112 12.3185 6.94764C12.3579 6.96415 12.4 6.97265 12.4426 6.97265H17.0853C17.1713 6.97265 17.2538 6.93803 17.3147 6.87639C17.3755 6.81476 17.4097 6.73116 17.4097 6.644V1.93971C17.4097 1.85255 17.3755 1.76895 17.3147 1.70732C17.2538 1.64568 17.1713 1.61106 17.0853 1.61106H12.4426Z"
                                        fill="currentColor"/><path
                                        d="M17.0853 19H12.4426C11.9351 18.9996 11.4484 18.7951 11.0895 18.4314C10.7306 18.0677 10.5287 17.5746 10.5283 17.0603V12.356C10.529 11.8418 10.7308 11.3488 11.0897 10.9851C11.4486 10.6215 11.9351 10.4169 12.4426 10.4163H17.0853C17.5928 10.4169 18.0794 10.6215 18.4382 10.9851C18.7971 11.3488 18.999 11.8418 18.9996 12.356V17.0603C18.9992 17.5746 18.7974 18.0677 18.4385 18.4314C18.0796 18.7951 17.5929 18.9996 17.0853 19ZM12.4426 12.0273C12.4 12.0273 12.3579 12.0358 12.3185 12.0524C12.2792 12.0689 12.2434 12.0931 12.2133 12.1236C12.1832 12.1541 12.1593 12.1904 12.143 12.2302C12.1267 12.2701 12.1183 12.3128 12.1183 12.356V17.0603C12.1183 17.1475 12.1525 17.2311 12.2133 17.2927C12.2741 17.3543 12.3566 17.3889 12.4426 17.3889H17.0853C17.1713 17.3889 17.2538 17.3543 17.3147 17.2927C17.3755 17.2311 17.4097 17.1475 17.4097 17.0603V12.356C17.4097 12.3128 17.4013 12.2701 17.385 12.2302C17.3687 12.1904 17.3448 12.1541 17.3147 12.1236C17.2845 12.0931 17.2488 12.0689 17.2094 12.0524C17.1701 12.0358 17.1279 12.0273 17.0853 12.0273H12.4426Z"
                                        fill="currentColor"/></g><defs><clipPath><rect width="19" height="19"
                                                                                       fill="white"/></clipPath></defs></svg>
                    </span>
                    </button>
                    <button type="submit" value="list" name="shop_style"
                            class="modes-mode mode-list display-mode <?php if ( $shop_display_mode == 'list' ): ?>active<?php endif; ?>">
                    <span class="button-inner">
                        <svg width="19" height="17" viewBox="0 0 19 17" fill="currentColor"
                             xmlns="http://www.w3.org/2000/svg"><g><path
                                        d="M18.0877 15.2184H5.09169C4.588 15.2184 4.17969 15.6172 4.17969 16.1092C4.17969 16.6012 4.588 17 5.09169 17H18.0877C18.5914 17 18.9997 16.6012 18.9997 16.1092C18.9997 15.6172 18.5914 15.2184 18.0877 15.2184Z"
                                        fill="currentColor"/><path
                                        d="M18.0877 7.27512H5.09169C4.588 7.27512 4.17969 7.67395 4.17969 8.16595C4.17969 8.65794 4.588 9.05678 5.09169 9.05678H18.0877C18.5914 9.05678 18.9997 8.65794 18.9997 8.16595C18.9997 7.67395 18.5914 7.27512 18.0877 7.27512Z"
                                        fill="currentColor"/><path
                                        d="M18.0877 0H5.09169C4.588 0 4.17969 0.398838 4.17969 0.89083C4.17969 1.38282 4.588 1.78166 5.09169 1.78166H18.0877C18.5914 1.78166 18.9997 1.38282 18.9997 0.89083C18.9997 0.398838 18.5914 0 18.0877 0Z"
                                        fill="currentColor"/><path
                                        d="M1.748 0H0.912C0.408316 0 0 0.398838 0 0.89083C0 1.38282 0.408316 1.78166 0.912 1.78166H1.748C2.25168 1.78166 2.66 1.38282 2.66 0.89083C2.66 0.398838 2.25168 0 1.748 0Z"
                                        fill="currentColor"/><path
                                        d="M1.748 7.27512H0.912C0.408316 7.27512 0 7.67395 0 8.16595C0 8.65794 0.408316 9.05678 0.912 9.05678H1.748C2.25168 9.05678 2.66 8.65794 2.66 8.16595C2.66 7.67395 2.25168 7.27512 1.748 7.27512Z"
                                        fill="currentColor"/><path
                                        d="M1.748 15.2184H0.912C0.408316 15.2184 0 15.6172 0 16.1092C0 16.6012 0.408316 17 0.912 17H1.748C2.25168 17 2.66 16.6012 2.66 16.1092C2.66 15.6172 2.25168 15.2184 1.748 15.2184Z"
                                        fill="currentColor"/></g><defs><clipPath><rect width="19" height="17"
                                                                                       fill="white"/></clipPath></defs></svg>
                    </span>
                    </button>
					<?php wc_query_string_form_fields( null, array(
						'shop_style',
						'submit',
						'paged',
						'product-page'
					) ); ?>
                </form>
            </div>
			<?php
		}

		public static function draly_dropshipping_starter_product_per_page_tmp() {
			$perpage                 = Draly_Dropshipping_Starter_Helper::get_option( 'product_per_page', '12' );
			$parts                   = parse_url( home_url() );
			$current_url             = "{$parts['scheme']}://{$parts['host']}" . add_query_arg( null, null );
			$product_per_page_option = array( 4, 8, 12, 16, 24 );
			$product_per_page_option = apply_filters( 'draly_dropshipping_starter_product_per_page_option', $product_per_page_option );
			?>
            <form class="per-page-form" method="POST" action="#">
                <label>
                    <span class="per-page-title"><?php echo esc_html__( 'Show:', 'draly-dropshipping-starter' ); ?></span>
                    <select name="product_per_page_filter" class="option-perpage" onchange="this.form.submit();">
                        <option value="<?php echo esc_attr( $perpage ); ?>" <?php echo esc_attr( 'selected' ); ?>>
							<?php echo esc_html( zeroise( $perpage, 2 ) ); ?>
                        </option>
						<?php foreach ( $product_per_page_option as $value ) : ?>
                            <option value="<?php echo esc_attr( $value ); ?>">
								<?php echo esc_html( zeroise( $value, 2 ) ); ?>
                            </option>
						<?php endforeach; ?>
                    </select>
                </label>
                <label>
                    <input type="hidden" name="perpage_action_form" value="<?php echo esc_attr( $current_url ); ?>">
                </label>
            </form>
			<?php
		}

		public static function draly_dropshipping_starter_custom_pagination() {
			global $wp_query;
			if ( $wp_query->max_num_pages > 1 ) { ?>
                <nav class="woocommerce-pagination">
					<?php
					echo wp_kses_post( paginate_links( apply_filters( 'woocommerce_pagination_args', array(
						'base'      => esc_url_raw( str_replace( 999999999, '%#%', remove_query_arg( 'add-to-cart', get_pagenum_link( 999999999, false ) ) ) ),
						'format'    => '',
						'add_args'  => false,
						'current'   => max( 1, get_query_var( 'paged' ) ),
						'total'     => $wp_query->max_num_pages,
						'prev_text' => '<span class="fa fa-angle-left"></span>',
						'next_text' => '<span class="fa fa-angle-right"></span>',
						'type'      => 'plain',
						'end_size'  => 3,
						'mid_size'  => 3,
					) ) ) );
					?>
                </nav>
				<?php
			}
		}

		//CUSTOM SHOP CONTROL
		public static function draly_dropshipping_starter_before_shop_control() {
			?>
            <div class="shop-control shop-before-control"><?php do_action( 'draly_dropshipping_starter_control_before_content' ); ?></div>
			<?php
		}

		public static function draly_dropshipping_starter_after_shop_control() {
			?>
            <div class="shop-control shop-after-control"><?php do_action( 'draly_dropshipping_starter_control_after_content' ); ?></div>
			<?php
		}

		//CUSTOM PRODUCT POST PER PAGE
		public static function draly_dropshipping_starter_loop_shop_per_page() {
			return Draly_Dropshipping_Starter_Helper::get_option( 'product_per_page', '12' );
		}

		//CUSTOM PRODUCT NAME
		public static function draly_dropshipping_starter_template_loop_product_title() {
			$title_class = array( 'product-name product_title' );
			?>
            <h3 class="<?php echo esc_attr( implode( ' ', $title_class ) ); ?>">
                <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
            </h3>
			<?php
		}

		//PRODUCT THUMBNAIL
		public static function draly_dropshipping_starter_template_loop_product_thumbnail() {
			global $product;
			// GET SIZE IMAGE SETTING
			$width  = 320;
			$height = 320;
			$crop   = true;
			$size   = wc_get_image_size( 'shop_catalog' );
			if ( $size ) {
				$width  = $size['width'];
				$height = $size['height'];
				if ( ! $size['crop'] ) {
					$crop = false;
				}
			}
			$data_src                = '';
			$attachment_ids          = $product->get_gallery_image_ids();
			$gallery_class_img       = $class_img = array();
			$thumb_gallery_class_img = $thumb_class_img = array( 'thumb-link' );
			$width                   = apply_filters( 'draly_dropshipping_starter_shop_product_thumb_width', $width );
			$height                  = apply_filters( 'draly_dropshipping_starter_shop_product_thumb_height', $height );
			$image_thumb             = Draly_Dropshipping_Starter_Helper::resize_image( get_post_thumbnail_id( $product->get_id() ), $width, $height, $crop );
			if ( ! empty( $image_thumb ) ) {
				$image_url = $image_thumb['url'];
				if ( $attachment_ids && has_post_thumbnail() ) {
					$gallery_class_img[]       = 'wp-post-image';
					$thumb_gallery_class_img[] = 'woocommerce-product-gallery__image';
				} else {
					$class_img[]       = 'wp-post-image';
					$thumb_class_img[] = 'woocommerce-product-gallery__image';
				}
				$image = '<img class="' . esc_attr( implode( ' ', $class_img ) ) . '"
                 src="' . esc_attr( $image_url ) . '" ' . esc_attr( $data_src ) . ' ' . image_hwstring( $width, $height ) . ' 
                 alt="' . esc_attr( get_the_title() ) . '">';
			} else {
				$image = '<img src="' . esc_url( wc_placeholder_img_src( 'woocommerce_single' ) ) . '" alt="' . esc_attr__( 'placeholder', 'draly-dropshipping-starter' ) . '">';
			}
			?>
            <a class="<?php echo esc_attr( implode( ' ', $thumb_class_img ) ); ?>" href="<?php the_permalink(); ?>"
               tabindex="-1">
				<?php echo wp_kses_post( $image ) ?>
            </a>
			<?php
		}

		//CUSTOM FLASH
		public static function draly_dropshipping_starter_custom_new_flash() {
			global $post, $product;
			if ( $product->is_in_stock() ) {
				$postdate      = get_the_time( 'Y-m-d' );
				$postdatestamp = strtotime( $postdate );
				$newness       = Draly_Dropshipping_Starter_Helper::get_option( 'product_newness', 7 );
				if ( ( time() - ( 60 * 60 * 24 * $newness ) ) < $postdatestamp ) :
					echo apply_filters( 'woocommerce_new_flash', '<span class="onnew"><span class="text">' . esc_html__( 'New', 'draly-dropshipping-starter' ) . '</span></span>', $post, $product );
				endif;
			}
		}

		public static function draly_dropshipping_starter_custom_sale_flash() {
			global $product;
			$percent = '';
			if ( $product->is_on_sale() && $product->is_in_stock() ) {
				if ( $product->is_type( 'variable' ) ) {
					$available_variations = $product->get_available_variations();
					$maximumper           = 0;
					$minimumper           = 0;
					$percentage           = 0;
					for ( $i = 0; $i < count( $available_variations ); ++ $i ) {
						$variation_id      = $available_variations[ $i ]['variation_id'];
						$variable_product1 = new WC_Product_Variation( $variation_id );
						$regular_price     = $variable_product1->get_regular_price();
						$sales_price       = $variable_product1->get_sale_price();
						if ( $regular_price > 0 && $sales_price > 0 ) {
							$percentage = round( ( ( ( $regular_price - $sales_price ) / $regular_price ) * 100 ), 0 );
						}
						if ( $minimumper == 0 ) {
							$minimumper = $percentage;
						}
						if ( $percentage > $maximumper ) {
							$maximumper = $percentage;
						}
						if ( $percentage < $minimumper ) {
							$minimumper = $percentage;
						}
					}
					if ( $minimumper == $maximumper ) {
						$percent .= $minimumper . '%';
					} else {
						$percent .= '(' . $minimumper . '-' . $maximumper . ')%';
					}
				} else {
					if ( $product->get_regular_price() > 0 && $product->get_sale_price() > 0 ) {
						$percentage = round( ( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 ), 0 );
						$percent    .= $percentage . '%';
					}
				}
			}
			if ( $percent != '' ) {
				return '<span class="onsale"><span class="number">' . wp_kses_post( $percent ) . '&nbsp;' . esc_html__( 'Off', 'draly-dropshipping-starter' ) . '</span></span>';
			}

			return '';
		}

		public static function draly_dropshipping_starter_group_flash() {
			?>
            <div class="flash">
				<?php do_action( 'draly_dropshipping_starter_group_flash_content' ); ?>
            </div>
			<?php
		}

		public static function draly_dropshipping_starter_related_title_product( $prefix ) {
			if ( $prefix == 'woo_crosssell' ) {
				$default_text = esc_html__( 'Cross Sell Products', 'draly-dropshipping-starter' );
			} elseif ( $prefix == 'woo_related' ) {
				$default_text = esc_html__( 'You Might Also Like', 'draly-dropshipping-starter' );
			} else {
				$default_text = esc_html__( 'Upsell Products', 'draly-dropshipping-starter' );
			}
			$title = Draly_Dropshipping_Starter_Helper::get_option( $prefix . '_products_title', $default_text );
			?>
            <div class="block-title">
                <h2 class="product-grid-title">
                    <span><?php echo esc_html( $title ); ?></span>
                </h2>
            </div>
			<?php
		}

		public static function draly_dropshipping_starter_carousel_products( $prefix, $data_args ) {
			$enable_product = Draly_Dropshipping_Starter_Helper::get_option( 'enable_' . $prefix, 'enable' );
			if ( $enable_product == 'disable' || empty( $data_args ) ) {
				return;
			}
			$shop_product_style = Draly_Dropshipping_Starter_Helper::get_option( 'shop_product_style', 'style-01' );
			$list_class         = array( 'draly-products' );
			$list_class[]       = $shop_product_style;
			$item_class         = array( 'product-item' );
			$item_class[]       = $shop_product_style;
			$woo_ls_items       = Draly_Dropshipping_Starter_Helper::get_option( $prefix . '_bg_items', 5 );
			$woo_lg_items       = Draly_Dropshipping_Starter_Helper::get_option( $prefix . '_lg_items', 3 );
			$woo_md_items       = Draly_Dropshipping_Starter_Helper::get_option( $prefix . '_md_items', 3 );
			$woo_sm_items       = Draly_Dropshipping_Starter_Helper::get_option( $prefix . '_sm_items', 2 );
			$woo_xs_items       = Draly_Dropshipping_Starter_Helper::get_option( $prefix . '_xs_items', 2 );
			$woo_ts_items       = Draly_Dropshipping_Starter_Helper::get_option( $prefix . '_ts_items', 2 );
			$atts               = array(
				'owl_navigation'      => 'false',
				'owl_dots'            => 'true',
				'owl_loop'            => 'false',
				'owl_slide_margin'    => '30',
				'owl_lg_slide_margin' => '30',
				'owl_md_slide_margin' => '20',
				'owl_sm_slide_margin' => '20',
				'owl_xs_slide_margin' => '10',
				'owl_ts_slide_margin' => '10',
				'owl_ts_items'        => $woo_ts_items,
				'owl_xs_items'        => $woo_xs_items,
				'owl_sm_items'        => $woo_sm_items,
				'owl_md_items'        => $woo_md_items,
				'owl_lg_items'        => $woo_lg_items,
				'owl_ls_items'        => $woo_ls_items,
			);
			$owl_settings       = Draly_Dropshipping_Starter_Helper::carousel_data_attributes( 'owl_', $atts );
			if ( $data_args ) : ?>
                <div class="col-12 <?php echo esc_attr( $prefix ); ?>-product">
                    <div class="<?php echo esc_attr( implode( ' ', $list_class ) ); ?>">
						<?php do_action( 'draly_dropshipping_starter_before_related_single_product', $prefix ); ?>
                        <div class="owl-slick owl-products" <?php echo esc_attr( $owl_settings ); ?>>
							<?php foreach ( $data_args as $value ) : ?>
                                <div <?php post_class( $item_class ) ?>>
									<?php
									$post_object = get_post( $value->get_id() );
									setup_postdata( $GLOBALS['post'] =& $post_object );
									wc_get_template_part( 'product-styles/content-product', $shop_product_style );
									?>
                                </div>
							<?php endforeach; ?>
                        </div>
                    </div>
                </div>
			<?php endif;
			wp_reset_postdata();
		}

		public static function draly_dropshipping_starter_related_products() {
			global $product;
			$related_products = array();
			if ( $product ) {
				$defaults = array(
					'posts_per_page' => 6,
					'columns'        => 6,
					'orderby'        => 'rand',
					'order'          => 'desc',
				);

				$args                        = wp_parse_args( $defaults );
				$args['related_products']    = array_filter( array_map( 'wc_get_product', wc_get_related_products( $product->get_id(), $args['posts_per_page'], $product->get_upsell_ids() ) ), 'wc_products_array_filter_visible' );
				$args['related_products']    = wc_products_array_orderby( $args['related_products'], $args['orderby'], $args['order'] );
				$woocommerce_loop['name']    = 'related';
				$woocommerce_loop['columns'] = apply_filters( 'woocommerce_related_products_columns', $args['columns'] );
				$related_products            = $args['related_products'];
			}

			if ( ! is_product() ) {
				$related_products = array();
			}
			self::draly_dropshipping_starter_carousel_products( 'woo_related', $related_products );
		}

		public static function draly_dropshipping_starter_upsell_display( $orderby = 'rand', $order = 'desc', $limit = '-1', $columns = 4 ) {
			global $product;
			$upsells = array();
			if ( $product ) {
				$args = array(
					'posts_per_page' => 4,
					'orderby'        => 'rand',
					'columns'        => 4,
				);

				$woocommerce_loop['name']    = 'up-sells';
				$woocommerce_loop['columns'] = apply_filters( 'woocommerce_upsells_columns', isset( $args['columns'] ) ? $args['columns'] : $columns );
				$orderby                     = apply_filters( 'woocommerce_upsells_orderby', isset( $args['orderby'] ) ? $args['orderby'] : $orderby );
				$limit                       = apply_filters( 'woocommerce_upsells_total', isset( $args['posts_per_page'] ) ? $args['posts_per_page'] : $limit );
				// Get visible upsells then sort them at random, then limit result set.
				$upsells = wc_products_array_orderby( array_filter( array_map( 'wc_get_product', $product->get_upsell_ids() ), 'wc_products_array_filter_visible' ), $orderby, $order );
				$upsells = $limit > 0 ? array_slice( $upsells, 0, $limit ) : $upsells;
			}

			if ( ! is_product() ) {
				$upsells = array();
			}
			self::draly_dropshipping_starter_carousel_products( 'woo_upsell', $upsells );
		}

		public static function draly_dropshipping_starter_cross_sell_products( $limit = 2, $columns = 2, $orderby = 'rand', $order = 'desc' ) {
			if ( is_checkout() ) {
				return;
			}
			$cross_sells                 = array_filter( array_map( 'wc_get_product', WC()->cart->get_cross_sells() ), 'wc_products_array_filter_visible' );
			$woocommerce_loop['name']    = 'cross-sells';
			$woocommerce_loop['columns'] = apply_filters( 'woocommerce_cross_sells_columns', $columns );
			// Handle orderby and limit results.
			$orderby     = apply_filters( 'woocommerce_cross_sells_orderby', $orderby );
			$cross_sells = wc_products_array_orderby( $cross_sells, $orderby, $order );
			$limit       = apply_filters( 'woocommerce_cross_sells_total', $limit );
			$cross_sells = $limit > 0 ? array_slice( $cross_sells, 0, $limit ) : $cross_sells;
			self::draly_dropshipping_starter_carousel_products( 'woo_crosssell', $cross_sells );
		}

		//CHECKOUT
		public static function draly_dropshipping_starter_checkout_login_open() {
			if ( ! is_user_logged_in() && get_option( 'woocommerce_enable_signup_and_login_from_checkout' ) === 'yes' ) {
				echo '<div class="checkout-before-top"><div class="draly-checkout-login">';
			}
		}

		public static function draly_dropshipping_starter_checkout_login_close() {
			if ( ! is_user_logged_in() && get_option( 'woocommerce_enable_signup_and_login_from_checkout' ) === 'yes' ) {
				echo '</div>';
			}
		}

		public static function draly_dropshipping_starter_checkout_coupon_open() {
			echo '<div class="draly-checkout-coupon">';
		}

		public static function draly_dropshipping_starter_checkout_coupon_close() {
			echo '</div>';
			if ( ! is_user_logged_in() ) {
				echo '</div>';
			}
		}

		public static function draly_dropshipping_starter_checkout_before_order_review_heading() {
			echo '<div class="draly-order-review">';
		}

		public static function draly_dropshipping_starter_checkout_after_order_review() {
			echo '</div>';
		}

		//GALLERY PRODUCT
		public static function draly_dropshipping_starter_gallery_product_thumbnail() {
			global $product;
			// GET SIZE IMAGE SETTING
			$width  = 320;
			$height = 320;
			$crop   = true;
			$size   = wc_get_image_size( 'shop_catalog' );
			if ( $size ) {
				$width  = $size['width'];
				$height = $size['height'];
				if ( ! $size['crop'] ) {
					$crop = false;
				}
			}
			$html           = '';
			$html_thumb     = '';
			$attachment_ids = $product->get_gallery_image_ids();
			$width          = apply_filters( 'draly_dropshipping_starter_shop_product_thumb_width', $width );
			$height         = apply_filters( 'draly_dropshipping_starter_shop_product_thumb_height', $height );
			/* primary image */
			$image_thumb       = Draly_Dropshipping_Starter_Helper::resize_image( get_post_thumbnail_id( $product->get_id() ), $width, $height, $crop );
			$thumbnail_primary = Draly_Dropshipping_Starter_Helper::resize_image( get_post_thumbnail_id( $product->get_id() ), 108, 108, $crop );
			if ( ! empty( $image_thumb ) ) {
				$html       .= '<figure>' . $image_thumb['img'] . '</figure>';
				$html_thumb .= '<figure>' . $thumbnail_primary['img'] . '</figure>';
			} else {
				$html       .= '<figure class="product-gallery-image"><img src="' . esc_url( wc_placeholder_img_src( 'woocommerce_single' ) ) . '" alt="' . esc_attr__( 'placeholder', 'draly-dropshipping-starter' ) . '"></figure>';
				$html_thumb .= '<figure><img src="' . esc_url( wc_placeholder_img_src( 'woocommerce_single' ) ) . '" alt="' . esc_attr__( 'placeholder', 'draly-dropshipping-starter' ) . '"></figure>';
			}
			/* thumbnail image */
			if ( $attachment_ids && has_post_thumbnail() ) {
				foreach ( $attachment_ids as $attachment_id ) {
					$gallery_thumb   = Draly_Dropshipping_Starter_Helper::resize_image( $attachment_id, $width, $height, $crop );
					$thumbnail_image = Draly_Dropshipping_Starter_Helper::resize_image( $attachment_id, 108, 108, $crop );
					if ( ! empty( $gallery_thumb ) ) {
						$html       .= '<figure class="product-gallery-image">' . $gallery_thumb['img'] . '</figure>';
						$html_thumb .= '<figure>' . $thumbnail_image['img'] . '</figure>';
					} else {
						$html       .= '<figure class="product-gallery-image"><img src="' . esc_url( wc_placeholder_img_src( 'woocommerce_single' ) ) . '" alt="' . esc_attr__( 'placeholder', 'draly-dropshipping-starter' ) . '"></figure>';
						$html_thumb .= '<figure><img src="' . esc_url( wc_placeholder_img_src( 'woocommerce_single' ) ) . '" alt="' . esc_attr__( 'placeholder', 'draly-dropshipping-starter' ) . '"></figure>';
					}
				}
			}
			?>
            <div class="product-gallery">
                <div class="product-gallery-slick">
					<?php echo wp_kses_post( $html ); ?>
                </div>
                <div class="gallery-dots">
					<?php echo wp_kses_post( $html_thumb ); ?>
                </div>
            </div>
			<?php
		}

		//REVERSE PRICE
		public static function draly_dropshipping_starter_reverse_price_html( $price, $product ) {
			if ( $product->is_on_sale() && ! $product->is_type( 'grouped' ) ) {
				$regular_price = wc_price( $product->get_regular_price() );
				$sale_price    = wc_price( $product->get_sale_price() );

				if ( $product->is_type( 'variable' ) ) {
					$regular_price = wc_price( $product->get_variation_regular_price( 'min' ) );
					$sale_price    = wc_price( $product->get_variation_sale_price( 'min' ) );
				}
				$price = '<ins>' . wp_kses_post( $sale_price ) . '</ins> <del>' . wp_kses_post( $regular_price ) . '</del>';
			}

			return $price;
		}

		//RATTING
		public static function draly_dropshipping_starter_get_star_rating_html( $html, $rating ) {
			global $product;
			if ( $product && method_exists( $product, 'get_review_count' ) ) {
				$star_rating_classes   = array( 'rating-wrapper' );
				$star_rating_classes[] = Draly_Dropshipping_Starter_Helper::get_option( 'star_rating_style', 'style-02' );
				$review_count          = $product->get_review_count();
				$review_count          = zeroise( $review_count, 1 );
				if ( $review_count > 0 ) {
					return '<div class="' . esc_attr( implode( ' ', $star_rating_classes ) ) . '">' . wp_kses_post( $html ) . '<span class="total-star-rating">' . wp_kses_post( $rating ) . '&nbsp;' . esc_html__( 'Star Rating', 'draly-dropshipping-starter' ) . '</span><span class="total-review-wrapper">' . sprintf( _n( '%s Review', '%s Reviews', esc_html( $review_count ), 'draly-dropshipping-starter' ), esc_html( $review_count ) ) . '</span></div>';
				}
			}

			return '';
		}

		//CUSTOM PRODUCT CATEGORY
		public static function draly_dropshipping_starter_template_loop_product_category() {
			global $product;
			$terms = get_the_terms( $product->get_id(), 'product_cat' );
			if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
				$first_category = $terms[0];
				$category_link  = get_term_link( $first_category );
				echo '<span class="product-first-category"><a href="' . esc_url( $category_link ) . '">' . esc_html( $first_category->name ) . '</a></span>';
			}
		}

		//GET PRODUCT
		public static function draly_dropshipping_starter_get_products( $atts, $args = array(), $ignore_sticky_posts = 1 ) {
			extract( $atts );
			$target            = isset( $target ) ? $target : 'recent-product';
			$meta_query        = WC()->query->get_meta_query();
			$tax_query         = WC()->query->get_tax_query();
			$args['post_type'] = 'product';
			if ( isset( $atts['taxonomy'] ) and $atts['taxonomy'] ) {
				$tax_query[] = array(
					'taxonomy' => 'product_cat',
					'terms'    => is_array( $atts['taxonomy'] ) ? array_map( 'sanitize_title', $atts['taxonomy'] ) : array_map( 'sanitize_title', explode( ',', $atts['taxonomy'] ) ),
					'field'    => 'slug',
					'operator' => 'IN',
				);
			}
			$args['post_status']         = 'publish';
			$args['ignore_sticky_posts'] = $ignore_sticky_posts;
			$args['suppress_filter']     = true;
			if ( isset( $atts['per_page'] ) && $atts['per_page'] ) {
				$args['posts_per_page'] = $atts['per_page'];
			}
			$ordering_args = WC()->query->get_catalog_ordering_args();
			$orderby       = isset( $atts['orderby'] ) ? $atts['orderby'] : $ordering_args['orderby'];
			$order         = isset( $atts['order'] ) ? $atts['order'] : $ordering_args['order'];
			$meta_key      = isset( $atts['meta_key'] ) ? $atts['meta_key'] : $ordering_args['meta_key'];
			switch ( $target ):
				case 'best-selling' :
					$args['meta_key'] = 'total_sales';
					$args['orderby']  = 'meta_value_num';
					$args['order']    = $order;
					break;
				case 'top-rated' :
					$args['meta_key'] = '_wc_average_rating';
					$args['orderby']  = 'meta_value_num';
					$args['order']    = $order;
					break;
				case 'product-category' :
					$args['orderby']  = $orderby;
					$args['order']    = $order;
					$args['meta_key'] = $meta_key;
					break;
				case 'products' :
					$args['posts_per_page'] = - 1;
					if ( ! empty( $ids ) ) {
						$args['post__in'] = array_map( 'trim', explode( ',', $ids ) );
						$args['orderby']  = 'post__in';
					}
					if ( ! empty( $skus ) ) {
						$meta_query[] = array(
							'key'     => '_sku',
							'value'   => array_map( 'trim', explode( ',', $skus ) ),
							'compare' => 'IN',
						);
					}
					break;
				case 'featured_products' :
					$tax_query[] = array(
						'taxonomy' => 'product_visibility',
						'field'    => 'name',
						'terms'    => 'featured',
						'operator' => 'IN',
					);
					break;
				case 'on_new' :
					$newness            = Draly_Dropshipping_Starter_Helper::get_option( 'product_newness', 7 );    // Newness in days as defined by option
					$args['date_query'] = array(
						array(
							'after'     => '' . $newness . ' days ago',
							'inclusive' => true,
						),
					);
					if ( $orderby == '_sale_price' ) {
						$orderby = 'date';
						$order   = 'DESC';
					}
					$args['orderby'] = $orderby;
					$args['order']   = $order;
					break;
				case 'on_sale' :
					$product_ids_on_sale = wc_get_product_ids_on_sale();
					$args['post__in']    = array_merge( array( 0 ), $product_ids_on_sale );
					if ( $orderby == '_sale_price' ) {
						$orderby = 'date';
						$order   = 'DESC';
					}
					$args['orderby'] = $orderby;
					$args['order']   = $order;
					break;
				default :
					$args['orderby'] = $orderby;
					$args['order']   = $order;
					if ( isset( $ordering_args['meta_key'] ) ) {
						$args['meta_key'] = $ordering_args['meta_key'];
					}
					WC()->query->remove_ordering_args();
					break;
			endswitch;
			$args['meta_query'] = $meta_query;
			$args['tax_query']  = $tax_query;

			return $products = new WP_Query( apply_filters( 'woocommerce_shortcode_products_query', $args, $atts ) );
		}

		//TAB AJAX
		public static function draly_dropshipping_starter_ajax_tabs() {
			$response        = array(
				'html'    => '',
				'success' => 'no',
			);
			$data_general    = isset( $_POST['data_general'] ) ? $_POST['data_general'] : '';
			$data_slick      = isset( $_POST['data_slick'] ) ? stripslashes( $_POST['data_slick'] ) : '';
			$data_responsive = isset( $_POST['data_responsive'] ) ? stripslashes( $_POST['data_responsive'] ) : '';
			$data_section    = isset( $_POST['data_section'] ) ? $_POST['data_section'] : '';
			if ( $data_general['product_image_size'] ) {
				if ( $data_general['product_image_size'] == 'custom' ) {
					$thumb_width  = $data_general['product_custom_thumb_width'];
					$thumb_height = $data_general['product_custom_thumb_height'];
				} else {
					$product_image_size = explode( "x", $data_general['product_image_size'] );
					$thumb_width        = $product_image_size[0];
					$thumb_height       = $product_image_size[1];
				}
				if ( $thumb_width > 0 ) {
					add_filter( 'draly_dropshipping_starter_shop_product_thumb_width', function () use ( $thumb_width ) {
						return $thumb_width;
					} );
				}
				if ( $thumb_height > 0 ) {
					add_filter( 'draly_dropshipping_starter_shop_product_thumb_height', function () use ( $thumb_height ) {
						return $thumb_height;
					} );
				}
			}
			$item_class   = array( 'product-item' );
			$item_class[] = $data_general['style'];
			$list_class   = array();
			if ( $data_general['layout'] == 'grid' ) {
				$list_class[] = 'product-list-grid row';
				$item_class[] = $data_general['boostrap_rows_space'];
				$item_class[] = 'col-' . $data_general['boostrap_items'];
				$item_class[] = 'col-sm-' . $data_general['boostrap_sm_items'];
				$item_class[] = 'col-md-' . $data_general['boostrap_md_items'];
				$item_class[] = 'col-lg-' . $data_general['boostrap_lg_items'];
				$item_class[] = 'col-xl-' . $data_general['boostrap_xl_items'];
				$item_class[] = 'col-xxl-' . $data_general['boostrap_xxl_items'];
			}
			if ( $data_general['layout'] == 'carousel' ) {
				$list_class[] = 'product-list-owl owl-slick';
				$item_class[] = $data_general['owl_rows_space'];
			}
			$products = self::draly_dropshipping_starter_get_products( $data_section );
			$id_loop  = array();
			$html     = '';
			if ( $products->have_posts() ):
				$html .= '<div class="' . esc_attr( implode( ' ', $list_class ) ) . '" data-slick="' . esc_attr( $data_slick ) . '" data-responsive="' . esc_attr( $data_responsive ) . '">';
				while ( $products->have_posts() ) : $products->the_post();
					$id_loop[] = get_the_ID();
					ob_start(); ?>
                    <div <?php post_class( array_merge( $item_class, array( $data_section['target'] ) ) ); ?>>
						<?php wc_get_template_part( 'product-styles/content-product', $data_general['style'] ); ?>
                    </div>
					<?php
					$html .= ob_get_clean();
				endwhile;
				$html .= '</div>';
			else:
				$html .= '<p><strong>' . esc_html__( 'No Product', 'draly-dropshipping-starter' ) . '</strong></p>';
			endif;
			$response['html']    = $html;
			$response['success'] = 'ok';
			wp_send_json( $response );
			die();
		}

	}
}
