如何使用电子邮件或电话号码获取woocommerce订单号?

时间:2015-09-22 06:12:45

标签: php wordpress woocommerce

目前我正在使用

$order = new WC_Order($order_id); 

(使用网络表单)获取与order id相关的客户详细信息。我只是希望能够使用客户的结算电子邮件或数据库中的结算电话来获取billingshipping地址等客户详细信息。先感谢您。 :)

4 个答案:

答案 0 :(得分:1)

为什么不使用:

$order = new WC_Order($order_id);
$address    = $order->get_shipping_address();
$address    = $order->get_billing_address();
$order->billing_phone;
$order->billing_email;

答案 1 :(得分:0)

不,不是真的,如果你开发模块,你可以使用:

add_action( 'woocommerce_thankyou', array('Wc_class', 'create_some_stuff'));


class Wc_class{

 public static function create_some_stuff($order_id){
 $order = new WC_Order($order_id);
 $address    = $order->get_shipping_address();
}

并且没有错误

答案 2 :(得分:0)

您可以尝试通过:

$customer_id = get_current_user_id();
print get_user_meta( $customer_id, 'billing_phone', true );
print get_user_meta( $customer_id, 'billing_email', true );
老实说,没有经过测试

答案 3 :(得分:0)

My solution for getting order id associated with particular email or phone number was as follows. 
global $wpdb; 
$postemail = $_POST["email"]; 
$bil_id = $wpdb->get_results( 
$wpdb->prepare( 
'SELECT post_id FROM wp_postmeta 
WHERE meta_key = "_billing_email" AND meta_value = %s',$postemail)); 

echo $bil_id[0]->post_id;

To get the order id associated with billing phone replace "_billing_email" with "_billing_phone", meta_value = %s with meta_value = %d