تابع ووکامرسی wc_update_total_sales_counts بروزرسانی ( تغییر ) تعداد فروش محصول

تابع ووکامرسی wc_update_total_sales_counts بروزرسانی ( تغییر ) تعداد فروش محصول

تابع ووکامرسی wc_update_total_sales_counts – بروزرسانی ( تغییر ) تعداد فروش محصول

Syntax – سینتکس

wc_update_total_sales_counts( (int) $order_id ); 

Parameters – پارامتر ها (1)

  • 1- $order_id (int)

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

if ( !function_exists( 'wc_update_total_sales_counts' ) ) { 
    require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-order-functions.php'; 
} 
  
// The order id. 
$order_id = -1; 
  
// NOTICE! Understand what this does before running. 
$result = wc_update_total_sales_counts($order_id); 
    

Defined – محل تعریف

/includes/wc-order-functions.php

function wc_update_total_sales_counts( $order_id ) { 
    $order = wc_get_order( $order_id ); 
 
    if ( ! $order || $order->get_data_store()->get_recorded_sales( $order ) ) { 
        return; 
    } 
 
    if ( sizeof( $order->get_items() ) > 0 ) { 
        foreach ( $order->get_items() as $item ) { 
            if ( $product_id = $item->get_product_id() ) { 
                $data_store = WC_Data_Store::load( 'product' ); 
                $data_store->update_product_sales( $product_id, absint( $item['qty'] ), 'increase' ); 
            } 
        } 
    } 
 
    $order->get_data_store()->set_recorded_sales( $order, true ); 
 
    /** 
     * Called when sales for an order are recorded 
     * 
     * @param int $order_id order id 
     */ 
    do_action( 'woocommerce_recorded_sales', $order_id ); 
} 

versions – نسخه ها

از نسخه : 3.0.0

نسخه فعلی : 3.0.6

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

ارسال نظر

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

contact us