2016-04-25 75 views
1

我是woocommerce的新用户,想知道sql查询以获取特定订单ID的订单商品详情。在woocommerce中订购商品详情

喜欢,项目名称,qunatity,价格,行税,行总数,折扣(如果有的话)。

感谢 AJ

+1

谷歌搜索'woocommerce实现这一目标sql通过ID获取订单似乎得到有用的结果 –

+0

我已经尝试过,但几乎所有人都返回订单详细信息,但不是订单项目的详细信息 –

回答

0

Woocommerce提供了一个很好的API集,几乎所有的目的,如果你喜欢非SQL方法,这里是你如何通过使用WC的API

$order = new WC_Order($order_id); 
/* get_items() retrives all the line items belong to that order 
* you can also examine get_items() function for the actuall sql query used. 
*/ 
foreach ($order->get_items() as $item) { 

    $product_id = (int) apply_filters('woocommerce_add_to_cart_product_id', $item['product_id']); 
    $quantity  = (int) $item['qty']; 
    $variation_id = (int) $item['variation_id']; 
    $variations = array(); 
    $cart_item_data = apply_filters('woocommerce_order_again_cart_item_data', array(), $item, $order); 

    // using $product_id you can anything related to that product (line item product) 
} 
+0

谢谢萨克的答复。 但是,即时寻找smae的SQL查询。 –

相关问题