2014-06-24 64 views
2

我使用woo-commerce插件可以任何人告訴我的查詢,這將給我所有的細節的順序以及使用細節。如何獲得所有訂單的詳細信息,包括付款custmer產品和運費的詳細信息在woocommerce

使用一個查詢我所需要的所有數據

例如我所需要的ORDER_ID,客戶編號,採購訂單號,訂單類型(DROP SHIP),送貨地址的詳細信息,如姓名,地址,國家,國家,郵編,電話號碼, 現在的產品名稱,產品數量

所有這些細節與我需要的所有用戶。任何人都可以幫我嗎?

回答

7

這是我寫的一個自定義插件,用於處理對商家帳戶的支付Woocommerce沒有在線。這是一個抓取所有訂單數據並將其放入數組以供使用的功能。航運不需要,所以我把它留空,但你可以像我爲結算信息那樣得到它。所以我希望它有幫助:

function get_itransact_args($order) 
    { 
     global $woocommerce; 
     $order_id = $order->id; 
     $billing_first_name = get_post_meta($order_id,'_billing_first_name',true); 
     $billing_last_name = get_post_meta($order_id,'_billing_last_name',true); 
     $billing_company = get_post_meta($order_id,'_billing_company',true); 
     $billing_address = get_post_meta($order_id,'_billing_address_1',true); 
     $billing_address2 = get_post_meta($order_id,'_billing_address_2',true); 
     $billing_city = get_post_meta($order_id,'_billing_city',true); 
     $billing_postcode = get_post_meta($order_id,'_billing_postcode',true); 
     $billing_country = get_post_meta($order_id,'_billing_country',true); 
     $billing_state = get_post_meta($order_id,'_billing_state',true); 
     $billing_email = get_post_meta($order_id,'_billing_email',true); 
     $billing_phone = get_post_meta($order_id,'_billing_phone',true); 
     $billing_paymethod = get_post_meta($order_id,'_payment_method',true); 


     $data = array();    
     $data['customerReference'] = $order_id.'-'.$order->order_key; 
     $data['description'] = "Payment for order id ".$order_id; 
     $data['email'] = $order->billing_email; 
     $data['INVNUM'] = $order_id; 
     $data['amount'] = number_format($order->get_total(), 2, '.', ''); 
     $data['gatewayurl'] = $this->gatewayurl; 
     $data['vendor_id'] = $this->vendorid; 
     $items = $order->get_items(); 
     foreach($items as $item) { 
      $item_id = $item['product_id']; 
      $product = new WC_Product($item_id); 
      $data["".$item_id ."-desc"] = $item['name']; 
      $data["".$item_id ."-cost"] = $product->price; 
      $data["".$item_id ."-qty"] = $item['qty']; 
     } 
     $shipping = $order->get_shipping(); 
     $data["0-desc"] = 'shipping'; 
     $data["0-cost"] = $shipping; 
     $data["0-qty"] = 1; 
     $data['ret_addr'] = add_query_arg('order', $order->id, add_query_arg('key', $order->order_key, get_permalink(woocommerce_get_page_id('pay')))); 
     $data['address'] = $billing_address. " " . $billing_address2; 
     $data['city'] = $billing_city; 
     $data['country'] = $billing_country; 
     $data['first_name'] = $billing_first_name; 
     $data['last_name'] = $billing_last_name; 
     $data['phone'] = $billing_phone; 
     $data['state'] = $billing_state; 
     $data['zip'] = $billing_postcode; 

     $data['saddr'] = ''; 
     $data['scity'] = ''; 
     $data['sctry'] = ''; 
     $data['sfname'] = ''; 
     $data['slname'] = ''; 
     $data['sstate'] = ''; 
     $data['szip'] = ''; 
     return $data; 
    } 
相關問題