woocommerce_products_will_display محصولات فروشگاه به درستی نمایش داده می شود
تابع ووکامرسی woocommerce_products_will_display – آیا محصولات به درستی نمایش داده می شود در فروشگاه ؟
Syntax – سینتکس
woocommerce_products_will_display();
Usage – نحوه استفاده
if ( !function_exists( 'woocommerce_products_will_display' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-template-functions.php'; } // NOTICE! Understand what this does before running. $result = woocommerce_products_will_display();
Defined – محل تعریف
/includes/wc-template-functions.php
function woocommerce_products_will_display() { global $wpdb; if ( is_shop() ) { return 'subcategories' !== get_option( 'woocommerce_shop_page_display' ) || is_search(); } if ( ! is_product_taxonomy() ) { return false; } if ( is_search() || is_filtered() || is_paged() ) { return true; } $term = get_queried_object(); if ( is_product_category() ) { switch ( get_woocommerce_term_meta( $term->term_id, 'display_type', true ) ) { case 'subcategories' : // Nothing - we want to continue to see if there are products/subcats break; case 'products' : case 'both' : return true; break; default : // Default - no setting if ( get_option( 'woocommerce_category_archive_display' ) != 'subcategories' ) { return true; } break; } } // Begin subcategory logic if ( empty( $term->term_id ) || empty( $term->taxonomy ) ) { return true; } $transient_name = 'wc_products_will_display_' . $term->term_id . '_' . WC_Cache_Helper::get_transient_version( 'product_query' ); if ( false === ( $products_will_display = get_transient( $transient_name ) ) ) { $has_children = $wpdb->get_col( $wpdb->prepare( "SELECT term_id FROM {$wpdb->term_taxonomy} WHERE parent = %d AND taxonomy = %s", $term->term_id, $term->taxonomy ) ); if ( $has_children ) { // Check terms have products inside - parents first. If products are found inside, subcats will be shown instead of products so we can return false. if ( sizeof( get_objects_in_term( $has_children, $term->taxonomy ) ) > 0 ) { $products_will_display = false; } else { // If we get here, the parents were empty so we're forced to check children foreach ( $has_children as $term_id ) { $children = get_term_children( $term_id, $term->taxonomy ); if ( sizeof( get_objects_in_term( $children, $term->taxonomy ) ) > 0 ) { $products_will_display = false; break; } } } } else { $products_will_display = true; } } set_transient( $transient_name, $products_will_display, DAY_IN_SECONDS * 30 ); return $products_will_display; }
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر