تابع ووکامرسی wc_get_product_ids_on_sale دریافت لیست آیدی محصولات فروش ویژه

تابع ووکامرسی wc_get_product_ids_on_sale دریافت لیست آیدی محصولات فروش ویژه

تابع ووکامرسی wc_get_product_ids_on_sale – دریافت لیست آیدی محصولاتی که برای فروش ویژه در نظر گرفته شده اند .

Syntax – سینتکس

(array) wc_get_product_ids_on_sale(); 

Usage – نحوه استفاده

if ( !function_exists( 'wc_get_product_ids_on_sale' ) ) { 
    require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-product-functions.php'; 
} 
 
  
// NOTICE! Understand what this does before running. 
$result = wc_get_product_ids_on_sale(); 
    

Defined – محل تعریف

/includes/wc-product-functions.php

function wc_get_product_ids_on_sale() { 
    // Load from cache 
    $product_ids_on_sale = get_transient( 'wc_products_onsale' ); 
 
    // Valid cache found 
    if ( false !== $product_ids_on_sale ) { 
        return $product_ids_on_sale; 
    } 
 
    $data_store = WC_Data_Store::load( 'product' ); 
    $on_sale_products = $data_store->get_on_sale_products(); 
    $product_ids_on_sale = wp_parse_id_list( array_merge( wp_list_pluck( $on_sale_products, 'id' ), array_diff( wp_list_pluck( $on_sale_products, 'parent_id' ), array( 0 ) ) ) ); 
 
    set_transient( 'wc_products_onsale', $product_ids_on_sale, DAY_IN_SECONDS * 30 ); 
 
    return $product_ids_on_sale; 
} 

versions – نسخه ها

از نسخه : 2.0

نسخه فعلی : 3.0.6

دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2

ارسال نظر

جهت استفاده از کد حتما از تگ pre استفاده نمایید .

contact us