table: wp_woocommerce_order_itemmeta
key: _qty
Hi @lorro, Thanks for the reply.
In this table order id is stored in “order_item_id”. And I got only 3 rows with the order id which includes following meta_key(column) “_woocs_order_rate”, “_woocs_order_base_currency”,
“_woocs_order_currency_changed_mannualy”. But out of three the key “_qty” is not available in front of order id. It is available but not in front of order id value. But instead it is available on random position unlike other 3 values. How will I identified which “_qty” value is of which order
if it will not showed up in front of order id value?
In this table order id is stored in “order_item_id”. Nope, I think you’re missing a step. The way the data is structured is that an order is in the post table. An order can have one or several order items. The order items are stored in wp_woocommerce_order_items. This table has an order_id which links back to the posts table. This table also has an order_item_id number which links to relevant additional data, including _qty, in wp_woocommerce_order_itemmeta.
So, the code will look something like this (sorry not tested)
$order = new WC_Order( $order_id );
$items = $order->get_items();
foreach( $items as $item ) {
$item_id = $item->get_id();
$quantity = wc_get_order_item_meta( $item_id, '_qty', true );
I don’t recognise the meta_keys you mention – it looks like they are coming from another plugin.