تابع ووکامرسی wc_get_customer_last_order دریافت آخرین سفارشات مشتری
تابع ووکامرسی wc_get_customer_last_order – دریافت اطلاعات آخرین سفارشات مشتری
Syntax – سینتکس
(WC_Order) wc_get_customer_last_order( (int) $customer_id );
Parameters – پارامتر ها (1)
- 1- $customer_id (int)
Returns – مقادیر بازگشتی (WC_Order)
Order object if successful or false.
Usage – نحوه استفاده
if ( !function_exists( 'wc_get_customer_last_order' ) ) { 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_get_customer_last_order($customer_id);
Defined – محل تعریف
/includes/wc-user-functions.php
function wc_get_customer_last_order( $customer_id ) { global $wpdb; $customer_id = absint( $customer_id ); $id = $wpdb->get_var( "SELECT id FROM $wpdb->posts AS posts LEFT JOIN {$wpdb->postmeta} AS meta on posts.ID = meta.post_id WHERE meta.meta_key = '_customer_user' AND meta.meta_value = {$customer_id} AND posts.post_type = 'shop_order' AND posts.post_status IN ( '" . implode( "', '", array_keys( wc_get_order_statuses() ) ) . "' ) ORDER BY posts.ID DESC " ); return wc_get_order( $id ); }
versions – نسخه ها
از نسخه : 2.6.0
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر