wc_update_new_customer_past_orders دریافت و بروزرسانی سفارش با ایمیل کاربر

تابع ووکامرسی wc_update_new_customer_past_orders – دریافت و بروزرسانی سفارش بر اساس ایمیل کاربر
Syntax – سینتکس
(int) wc_update_new_customer_past_orders( (int) $customer_id );
Parameters – پارامتر ها (1)
- 1- $customer_id (int)
Usage – نحوه استفاده
if ( !function_exists( 'wc_update_new_customer_past_orders' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-user-functions.php';
}
// The customer id.
$customer_id = -1;
// NOTICE! Understand what this does before running.
$result = wc_update_new_customer_past_orders($customer_id);
Defined – محل تعریف
/includes/wc-user-functions.php
function wc_update_new_customer_past_orders( $customer_id ) {
$linked = 0;
$complete = 0;
$customer = get_user_by( 'id', absint( $customer_id ) );
$customer_orders = wc_get_orders( array(
'limit' => -1,
'customer' => array( array( 0, $customer->user_email ) ),
'return' => 'ids',
) );
if ( ! empty( $customer_orders ) ) {
foreach ( $customer_orders as $order_id ) {
update_post_meta( $order_id, '_customer_user', $customer->ID );
do_action( 'woocommerce_update_new_customer_past_order', $order_id, $customer );
if ( get_post_status( $order_id ) === 'wc-completed' ) {
$complete++;
}
$linked++;
}
}
if ( $complete ) {
update_user_meta( $customer_id, 'paying_customer', 1 );
update_user_meta( $customer_id, '_order_count', '' );
update_user_meta( $customer_id, '_money_spent', '' );
}
return $linked;
}
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر