【发布时间】:2020-01-17 21:45:00
【问题描述】:
购买产品后,在此用户元中添加此产品订单 ID。我可以使用此wc_customer_bought_product() 检查产品购买状态。现在我需要使用 UserID 和产品 ID 获取此产品订单 ID。我怎样才能做到这一点?我的最终目标是在获得订单 ID 后,我将通过此功能删除订单 wp_delete_post()
$bronze = wc_customer_bought_product($current_user->user_email, $current_user->ID, 246014);
function get_customerorderid(){
global $post;
$order_id = $post->ID;
// Get an instance of the WC_Order object
$order = wc_get_order($order_id);
// Get the user ID from WC_Order methods
$user_id = $order->get_user_id(); // or $order->get_customer_id();
return $user_id;
}
get_customerorderid();
wp_delete_post(246014,true);
【问题讨论】:
标签: php sql wordpress woocommerce orders