duanbeng1923 2014-06-24 12:14
浏览 393

如何在woocommerce中获取所有订单详细信息,包括付款客户产品和运输详细信息

I am using the woo-commerce plugin can any one tell me the query which will give me the all the details of order as well as use details.

With one query i required all the the data

for example i required the order_id,YOUR CUSTOMER NUMBER,PURCHASE ORDER NUMBER,TYPE of order(DROP SHIP),shipping address details like name,address,state,country,zip,phone number, now product name,product qty

all this details with all users i required.can anyone help me?

  • 写回答

1条回答 默认 最新

  • douzhaiya3968 2014-08-05 14:43
    关注

    This is from a custom plugin that I wrote to process payments to a merchant account Woocommerce doesn't have online. This is a function that grabs all of the order data and then places it into an array for use. Shipping wasn't needed so I left it blank, but you can get it the same way as I did for the billing info. So I hope it helps:

        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; 
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100