تابع ووکامرسی wc_restock_refunded_items موجود کردن محصول پس از استرداد آن

تابع ووکامرسی wc_restock_refunded_items – موجود کردن محصول پس از استرداد آن
Syntax – سینتکس
wc_restock_refunded_items( (WC_Order) $order, (array) $refunded_line_items );
Parameters – پارامتر ها (2)
- 1- $order (WC_Order)
- 2- $refunded_line_items (array)
Usage – نحوه استفاده
if ( !function_exists( 'wc_restock_refunded_items' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-order-functions.php';
}
// The order.
$order = null;
// The refunded line items.
$refunded_line_items = array();
// NOTICE! Understand what this does before running.
$result = wc_restock_refunded_items($order, $refunded_line_items);
Defined – محل تعریف
/includes/wc-order-functions.php
function wc_restock_refunded_items( $order, $refunded_line_items ) {
$line_items = $order->get_items();
foreach ( $line_items as $item_id => $item ) {
if ( ! isset( $refunded_line_items[ $item_id ], $refunded_line_items[ $item_id ]['qty'] ) ) {
continue;
}
$product = $item->get_product();
if ( $product && $product->managing_stock() ) {
$old_stock = $product->get_stock_quantity();
$new_stock = wc_update_product_stock( $product, $refunded_line_items[ $item_id ]['qty'], 'increase' );
$order->add_order_note( sprintf( __( 'Item #%1$s stock increased from %2$s to %3$s.', woocommerce ), $product->get_id(), $old_stock, $new_stock ) );
do_action( 'woocommerce_restock_refunded_item', $product->get_id(), $old_stock, $new_stock, $order, $product );
}
}
}
versions – نسخه ها
از نسخه : 3.0.0
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر