تابع ووکامرسی wc_recount_after_stock_change شمارش مجدد موجودی محصول

تابع ووکامرسی wc_recount_after_stock_change – شمارش مجدد موجودی محصول پس از تغییر موجودی
Syntax – سینتکس
wc_recount_after_stock_change( (int) $product_id );
Parameters – پارامتر ها (1)
- 1- $product_id (int)
Usage – نحوه استفاده
if ( !function_exists( 'wc_recount_after_stock_change' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-term-functions.php';
}
// The product id.
$product_id = -1;
// NOTICE! Understand what this does before running.
$result = wc_recount_after_stock_change($product_id);
Defined – محل تعریف
/includes/wc-term-functions.php
function wc_recount_after_stock_change( $product_id ) {
if ( 'yes' !== get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
return;
}
$product_terms = get_the_terms( $product_id, 'product_cat' );
if ( $product_terms ) {
$product_cats = array();
foreach ( $product_terms as $term ) {
$product_cats[ $term->term_id ] = $term->parent;
}
_wc_term_recount( $product_cats, get_taxonomy( 'product_cat' ), false, false );
}
$product_terms = get_the_terms( $product_id, 'product_tag' );
if ( $product_terms ) {
$product_tags = array();
foreach ( $product_terms as $term ) {
$product_tags[ $term->term_id ] = $term->parent;
}
_wc_term_recount( $product_tags, get_taxonomy( 'product_tag' ), false, false );
}
}
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر