array(
"title" => esc_html__('Shop', 'asia-garden'),
"desc" => wp_kses_data( __('Select parameters to display the shop pages', 'asia-garden') ),
"type" => "section"
),
'products_info_shop' => array(
"title" => esc_html__('Products list', 'asia-garden'),
"desc" => '',
"type" => "info",
),
'posts_per_page_shop' => array(
"title" => esc_html__('Products per page', 'asia-garden'),
"desc" => wp_kses_data( __('How many products should be displayed on the shop page. If empty - use global value from the menu Settings - Reading', 'asia-garden') ),
"std" => '',
"type" => "text"
),
'blog_columns_shop' => array(
"title" => esc_html__('Shop loop columns', 'asia-garden'),
"desc" => wp_kses_data( __('How many columns should be used in the shop loop (from 2 to 4)?', 'asia-garden') ),
"std" => 2,
"options" => asia_garden_get_list_range(2,4),
"type" => "select"
),
'shop_mode' => array(
"title" => esc_html__('Shop mode', 'asia-garden'),
"desc" => wp_kses_data( __('Select style for the products list', 'asia-garden') ),
"std" => 'thumbs',
"options" => array(
'thumbs'=> esc_html__('Thumbnails', 'asia-garden'),
'list' => esc_html__('List', 'asia-garden'),
),
"type" => "select"
),
'shop_hover' => array(
"title" => esc_html__('Hover style', 'asia-garden'),
"desc" => wp_kses_data( __('Hover style on the products in the shop archive', 'asia-garden') ),
"std" => 'none',
"options" => apply_filters('asia_garden_filter_shop_hover', array(
'none' => esc_html__('None', 'asia-garden'),
'dots' => esc_html__('Dots', 'asia-garden')
// 'shop' => esc_html__('Icons', 'asia-garden'),
// 'shop_buttons' => esc_html__('Buttons', 'asia-garden')
)),
"type" => "select"
),
'single_info_shop' => array(
"title" => esc_html__('Single product', 'asia-garden'),
"desc" => '',
"type" => "info",
),
'stretch_tabs_area' => array(
"title" => esc_html__('Stretch tabs area', 'asia-garden'),
"desc" => wp_kses_data( __('Stretch area with tabs on the single product to the screen width if the sidebar is hidden', 'asia-garden') ),
"std" => 1,
"type" => "checkbox"
),
'show_related_posts_shop' => array(
"title" => esc_html__('Show related products', 'asia-garden'),
"desc" => wp_kses_data( __("Show section 'Related products' on the single product page", 'asia-garden') ),
"std" => 1,
"type" => "checkbox"
),
'related_posts_shop' => array(
"title" => esc_html__('Related products', 'asia-garden'),
"desc" => wp_kses_data( __('How many related products should be displayed on the single product page?', 'asia-garden') ),
"dependency" => array(
'show_related_posts_shop' => array('1')
),
"std" => 3,
"options" => asia_garden_get_list_range(1,9),
"type" => "select"
),
'related_columns_shop' => array(
"title" => esc_html__('Related columns', 'asia-garden'),
"desc" => wp_kses_data( __('How many columns should be used to output related products on the single product page?', 'asia-garden') ),
"dependency" => array(
'show_related_posts_shop' => array('1')
),
"std" => 3,
"options" => asia_garden_get_list_range(1,4),
"type" => "select"
)
),
asia_garden_options_get_list_cpt_options('shop')
));
}
}
}
// Theme init priorities:
// 9 - register other filters (for installer, etc.)
if (!function_exists('asia_garden_woocommerce_theme_setup9')) {
add_action( 'after_setup_theme', 'asia_garden_woocommerce_theme_setup9', 9 );
function asia_garden_woocommerce_theme_setup9() {
if (asia_garden_exists_woocommerce()) {
add_action( 'wp_enqueue_scripts', 'asia_garden_woocommerce_frontend_scripts', 1100 );
add_filter( 'asia_garden_filter_merge_styles', 'asia_garden_woocommerce_merge_styles' );
add_filter( 'asia_garden_filter_merge_scripts', 'asia_garden_woocommerce_merge_scripts');
add_filter( 'asia_garden_filter_get_post_info', 'asia_garden_woocommerce_get_post_info');
add_filter( 'asia_garden_filter_post_type_taxonomy', 'asia_garden_woocommerce_post_type_taxonomy', 10, 2 );
if (!is_admin()) {
add_filter( 'asia_garden_filter_detect_blog_mode', 'asia_garden_woocommerce_detect_blog_mode');
add_filter( 'asia_garden_filter_get_post_categories', 'asia_garden_woocommerce_get_post_categories');
add_filter( 'asia_garden_filter_allow_override_header_image', 'asia_garden_woocommerce_allow_override_header_image');
add_filter( 'asia_garden_filter_get_blog_title', 'asia_garden_woocommerce_get_blog_title');
add_action( 'asia_garden_action_before_post_meta', 'asia_garden_woocommerce_action_before_post_meta');
add_action( 'pre_get_posts', 'asia_garden_woocommerce_pre_get_posts');
add_filter( 'asia_garden_filter_localize_script', 'asia_garden_woocommerce_localize_script');
}
}
if (is_admin()) {
add_filter( 'asia_garden_filter_tgmpa_required_plugins', 'asia_garden_woocommerce_tgmpa_required_plugins' );
}
// Add wrappers and classes to the standard WooCommerce output
if (asia_garden_exists_woocommerce()) {
// Remove WOOC sidebar
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
// Remove link around product item
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);
// Remove add_to_cart button
//remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
// Remove link around product category
remove_action('woocommerce_before_subcategory', 'woocommerce_template_loop_category_link_open', 10);
remove_action('woocommerce_after_subcategory', 'woocommerce_template_loop_category_link_close', 10);
// Open main content wrapper -
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
add_action( 'woocommerce_before_main_content', 'asia_garden_woocommerce_wrapper_start', 10);
// Close main content wrapper -
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
add_action( 'woocommerce_after_main_content', 'asia_garden_woocommerce_wrapper_end', 10);
// Close header section
add_action( 'woocommerce_archive_description', 'asia_garden_woocommerce_archive_description', 15 );
// Add theme specific search form
add_filter( 'get_product_search_form', 'asia_garden_woocommerce_get_product_search_form' );
// Change text on 'Add to cart' button
add_filter( 'woocommerce_product_add_to_cart_text', 'asia_garden_woocommerce_add_to_cart_text' );
add_filter( 'woocommerce_product_single_add_to_cart_text','asia_garden_woocommerce_add_to_cart_text' );
// Add list mode buttons
add_action( 'woocommerce_before_shop_loop', 'asia_garden_woocommerce_before_shop_loop', 10 );
// Set columns number for the products loop
add_filter( 'loop_shop_columns', 'asia_garden_woocommerce_loop_shop_columns' );
add_filter( 'post_class', 'asia_garden_woocommerce_loop_shop_columns_class' );
add_filter( 'product_cat_class', 'asia_garden_woocommerce_loop_shop_columns_class', 10, 3 );
// Open product/category item wrapper
add_action( 'woocommerce_before_subcategory_title', 'asia_garden_woocommerce_item_wrapper_start', 9 );
add_action( 'woocommerce_before_shop_loop_item_title', 'asia_garden_woocommerce_item_wrapper_start', 9 );
// Close featured image wrapper and open title wrapper
add_action( 'woocommerce_before_subcategory_title', 'asia_garden_woocommerce_title_wrapper_start', 20 );
add_action( 'woocommerce_before_shop_loop_item_title', 'asia_garden_woocommerce_title_wrapper_start', 20 );
// Add tags before title
// add_action( 'woocommerce_before_shop_loop_item_title', 'asia_garden_woocommerce_title_tags', 30 );
// Wrap product title into link
add_action( 'the_title', 'asia_garden_woocommerce_the_title');
// Wrap category title into link
add_action( 'woocommerce_shop_loop_subcategory_title', 'asia_garden_woocommerce_shop_loop_subcategory_title', 9, 1);
// Close title wrapper and add description in the list mode
add_action( 'woocommerce_after_shop_loop_item_title', 'asia_garden_woocommerce_title_wrapper_end', 7);
add_action( 'woocommerce_after_subcategory_title', 'asia_garden_woocommerce_title_wrapper_end2', 10 );
// Close product/category item wrapper
add_action( 'woocommerce_after_subcategory', 'asia_garden_woocommerce_item_wrapper_end', 20 );
add_action( 'woocommerce_after_shop_loop_item', 'asia_garden_woocommerce_item_wrapper_end', 20 );
// Add product ID into product meta section (after categories and tags)
add_action( 'woocommerce_product_meta_end', 'asia_garden_woocommerce_show_product_id', 10);
// Set columns number for the product's thumbnails
add_filter( 'woocommerce_product_thumbnails_columns', 'asia_garden_woocommerce_product_thumbnails_columns' );
// Decorate price
// add_filter( 'woocommerce_get_price_html', 'asia_garden_woocommerce_get_price_html' );
// Detect current shop mode
if (!is_admin()) {
$shop_mode = asia_garden_get_value_gpc('asia_garden_shop_mode');
if (empty($shop_mode) && asia_garden_check_theme_option('shop_mode'))
$shop_mode = asia_garden_get_theme_option('shop_mode');
if (empty($shop_mode))
$shop_mode = 'thumbs';
asia_garden_storage_set('shop_mode', $shop_mode);
}
}
}
}
// Theme init priorities:
// Action 'wp'
// 1 - detect override mode. Attention! Only after this step you can use overriden options (separate values for the shop, courses, etc.)
if (!function_exists('asia_garden_woocommerce_theme_setup_wp')) {
add_action( 'wp', 'asia_garden_woocommerce_theme_setup_wp' );
function asia_garden_woocommerce_theme_setup_wp() {
if (asia_garden_exists_woocommerce()) {
// Set columns number for the related products
if ((int) asia_garden_get_theme_option('show_related_posts') == 0 || (int) asia_garden_get_theme_option('related_posts') == 0) {
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
} else {
add_filter( 'woocommerce_output_related_products_args', 'asia_garden_woocommerce_output_related_products_args' );
add_filter( 'woocommerce_related_products_columns', 'asia_garden_woocommerce_related_products_columns' );
}
}
}
}
// Filter to add in the required plugins list
if ( !function_exists( 'asia_garden_woocommerce_tgmpa_required_plugins' ) ) {
//Handler of the add_filter('asia_garden_filter_tgmpa_required_plugins', 'asia_garden_woocommerce_tgmpa_required_plugins');
function asia_garden_woocommerce_tgmpa_required_plugins($list=array()) {
if (asia_garden_storage_isset('required_plugins', 'woocommerce')) {
$list[] = array(
'name' => asia_garden_storage_get_array('required_plugins', 'woocommerce'),
'slug' => 'woocommerce',
'required' => false
);
}
return $list;
}
}
// Check if WooCommerce installed and activated
if ( !function_exists( 'asia_garden_exists_woocommerce' ) ) {
function asia_garden_exists_woocommerce() {
return class_exists('Woocommerce');
//return function_exists('is_woocommerce');
}
}
// Return true, if current page is any woocommerce page
if ( !function_exists( 'asia_garden_is_woocommerce_page' ) ) {
function asia_garden_is_woocommerce_page() {
$rez = false;
if (asia_garden_exists_woocommerce())
$rez = is_woocommerce() || is_shop() || is_product() || is_product_category() || is_product_tag() || is_product_taxonomy() || is_cart() || is_checkout() || is_account_page();
return $rez;
}
}
// Detect current blog mode
if ( !function_exists( 'asia_garden_woocommerce_detect_blog_mode' ) ) {
//Handler of the add_filter( 'asia_garden_filter_detect_blog_mode', 'asia_garden_woocommerce_detect_blog_mode' );
function asia_garden_woocommerce_detect_blog_mode($mode='') {
if (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy())
$mode = 'shop';
else if (is_product() || is_cart() || is_checkout() || is_account_page())
$mode = 'shop'; //'shop_single';
return $mode;
}
}
// Return current page title
if ( !function_exists( 'asia_garden_woocommerce_get_blog_title' ) ) {
//Handler of the add_filter( 'asia_garden_filter_get_blog_title', 'asia_garden_woocommerce_get_blog_title');
function asia_garden_woocommerce_get_blog_title($title='') {
if (!asia_garden_exists_trx_addons() && asia_garden_exists_woocommerce() && asia_garden_is_woocommerce_page() && is_shop()) {
$id = asia_garden_woocommerce_get_shop_page_id();
$title = $id ? get_the_title($id) : esc_html__('Shop', 'asia-garden');
}
return $title;
}
}
// Return taxonomy for current post type
if ( !function_exists( 'asia_garden_woocommerce_post_type_taxonomy' ) ) {
//Handler of the add_filter( 'asia_garden_filter_post_type_taxonomy', 'asia_garden_woocommerce_post_type_taxonomy', 10, 2 );
function asia_garden_woocommerce_post_type_taxonomy($tax='', $post_type='') {
if ($post_type == 'product')
$tax = 'product_cat';
return $tax;
}
}
// Return true if page title section is allowed
if ( !function_exists( 'asia_garden_woocommerce_allow_override_header_image' ) ) {
//Handler of the add_filter( 'asia_garden_filter_allow_override_header_image', 'asia_garden_woocommerce_allow_override_header_image' );
function asia_garden_woocommerce_allow_override_header_image($allow=true) {
return is_product() ? false : $allow;
}
}
// Return shop page ID
if ( !function_exists( 'asia_garden_woocommerce_get_shop_page_id' ) ) {
function asia_garden_woocommerce_get_shop_page_id() {
return get_option('woocommerce_shop_page_id');
}
}
// Return shop page link
if ( !function_exists( 'asia_garden_woocommerce_get_shop_page_link' ) ) {
function asia_garden_woocommerce_get_shop_page_link() {
$url = '';
$id = asia_garden_woocommerce_get_shop_page_id();
if ($id) $url = get_permalink($id);
return $url;
}
}
// Show categories of the current product
if ( !function_exists( 'asia_garden_woocommerce_get_post_categories' ) ) {
//Handler of the add_filter( 'asia_garden_filter_get_post_categories', 'asia_garden_woocommerce_get_post_categories');
function asia_garden_woocommerce_get_post_categories($cats='') {
if (get_post_type()=='product') {
$cats = asia_garden_get_post_terms(', ', get_the_ID(), 'product_cat');
}
return $cats;
}
}
// Add 'product' to the list of the supported post-types
if ( !function_exists( 'asia_garden_woocommerce_list_post_types' ) ) {
//Handler of the add_filter( 'asia_garden_filter_list_posts_types', 'asia_garden_woocommerce_list_post_types');
function asia_garden_woocommerce_list_post_types($list=array()) {
$list['product'] = esc_html__('Products', 'asia-garden');
return $list;
}
}
// Show price of the current product in the widgets and search results
if ( !function_exists( 'asia_garden_woocommerce_get_post_info' ) ) {
//Handler of the add_filter( 'asia_garden_filter_get_post_info', 'asia_garden_woocommerce_get_post_info');
function asia_garden_woocommerce_get_post_info($post_info='') {
if (get_post_type()=='product') {
global $product;
if ( $price_html = $product->get_price_html() ) {
$post_info = '
' . trim($price_html) . '
' . $post_info;
}
}
return $post_info;
}
}
// Show price of the current product in the search results streampage
if ( !function_exists( 'asia_garden_woocommerce_action_before_post_meta' ) ) {
//Handler of the add_action( 'asia_garden_action_before_post_meta', 'asia_garden_woocommerce_action_before_post_meta');
function asia_garden_woocommerce_action_before_post_meta() {
if (!is_single() && get_post_type()=='product') {
global $product;
if ( $price_html = $product->get_price_html() ) {
?> esc_html__('WooCommerce Widgets', 'asia-garden'),
'description' => esc_html__('Widgets to be shown on the WooCommerce pages', 'asia-garden')
);
return $list;
}
}
// Decorate WooCommerce output: Loop
//------------------------------------------------------------------------
// Add query vars to set products per page
if (!function_exists('asia_garden_woocommerce_pre_get_posts')) {
//Handler of the add_action( 'pre_get_posts', 'asia_garden_woocommerce_pre_get_posts' );
function asia_garden_woocommerce_pre_get_posts($query) {
if (!$query->is_main_query()) return;
if ($query->get('post_type') == 'product') {
$ppp = get_theme_mod('posts_per_page_shop', 0);
if ($ppp > 0)
$query->set('posts_per_page', $ppp);
}
}
}
// Before main content
if ( !function_exists( 'asia_garden_woocommerce_wrapper_start' ) ) {
//remove_action( 'woocommerce_before_main_content', 'asia_garden_woocommerce_wrapper_start', 10);
//Handler of the add_action('woocommerce_before_main_content', 'asia_garden_woocommerce_wrapper_start', 10);
function asia_garden_woocommerce_wrapper_start() {
if (is_product() || is_cart() || is_checkout() || is_account_page()) {
?>
slug, 'product_cat') : get_permalink()); ?>">
$cat));
}
do_action('asia_garden_action_woocommerce_item_featured_end');
?>
\\3', $price);
}
return $price;
}
}
// Decorate WooCommerce output: Single product
//------------------------------------------------------------------------
// Add WooCommerce specific vars into localize array
if (!function_exists('asia_garden_woocommerce_localize_script')) {
//Handler of the add_filter( 'asia_garden_filter_localize_script','asia_garden_woocommerce_localize_script' );
function asia_garden_woocommerce_localize_script($arr) {
$arr['stretch_tabs_area'] = !asia_garden_sidebar_present() ? asia_garden_get_theme_option('stretch_tabs_area') : 0;
return $arr;
}
}
// Add Product ID for the single product
if ( !function_exists( 'asia_garden_woocommerce_show_product_id' ) ) {
//Handler of the add_action( 'woocommerce_product_meta_end', 'asia_garden_woocommerce_show_product_id', 10);
function asia_garden_woocommerce_show_product_id() {
$authors = wp_get_post_terms(get_the_ID(), 'pa_product_author');
if (is_array($authors) && count($authors)>0) {
echo ''.esc_html__('Author: ', 'asia-garden');
$delim = '';
foreach ($authors as $author) {
echo esc_html($delim) . '' . esc_html($author->name) . '';
$delim = ', ';
}
echo '';
}
echo ''.esc_html__('Product ID: ', 'asia-garden') . '' . get_the_ID() . '';
}
}
// Number columns for the product's thumbnails
if ( !function_exists( 'asia_garden_woocommerce_product_thumbnails_columns' ) ) {
//Handler of the add_filter( 'woocommerce_product_thumbnails_columns', 'asia_garden_woocommerce_product_thumbnails_columns' );
function asia_garden_woocommerce_product_thumbnails_columns($cols) {
return 4;
}
}
// Set products number for the related products
if ( !function_exists( 'asia_garden_woocommerce_output_related_products_args' ) ) {
//Handler of the add_filter( 'woocommerce_output_related_products_args', 'asia_garden_woocommerce_output_related_products_args' );
function asia_garden_woocommerce_output_related_products_args($args) {
$args['posts_per_page'] = (int) asia_garden_get_theme_option('show_related_posts')
? max(0, min(9, asia_garden_get_theme_option('related_posts')))
: 0;
$args['columns'] = max(1, min(4, asia_garden_get_theme_option('related_columns')));
return $args;
}
}
// Set columns number for the related products
if ( !function_exists( 'asia_garden_woocommerce_related_products_columns' ) ) {
//Handler of the add_filter('woocommerce_related_products_columns', 'asia_garden_woocommerce_related_products_columns' );
function asia_garden_woocommerce_related_products_columns($columns) {
$columns = max(1, min(4, asia_garden_get_theme_option('related_columns')));
return $columns;
}
}
// Decorate WooCommerce output: Widgets
//------------------------------------------------------------------------
// Search form
if ( !function_exists( 'asia_garden_woocommerce_get_product_search_form' ) ) {
//Handler of the add_filter( 'get_product_search_form', 'asia_garden_woocommerce_get_product_search_form' );
function asia_garden_woocommerce_get_product_search_form($form) {
return '
';
}
}
// Add plugin-specific colors and fonts to the custom CSS
if (asia_garden_exists_woocommerce()) { require_once ASIA_GARDEN_THEME_DIR . 'plugins/woocommerce/woocommerce.styles.php'; }
?>