Reputation: 533
May I know that if there a way to get WooCommerce order ID by a value from billing detail? My main goal here is getting order status (order tracking) but I have done it with order ID. Which mean if customer provides order ID the website will show his/her order status. But somehow my client wanted to make it available to check with another unique value which his clients have to submit in billing detail.
I have been thinking how to get order status directly or get order ID and then status if I have that unique value billing detail. Thanks in advance.
Upvotes: 0
Views: 522
Reputation: 3572
Yes you can. But if it unique, of course.
global $wpdb;
$order_id=$wpdb->get_var("select post_id from $wpdb->postmeta where meta_key='_billing_address_1' and meta_value='".esc_sql($billing_address_here))."'";
//or
global $wpdb;
$order_id=$wpdb->get_var("select post_id from $wpdb->postmeta where meta_key='_billing_phone' and meta_value='".esc_sql($billing_phone_here)."'");
Upvotes: 1