• Resolved rish30990

    (@rish30990)


    I searched in wp_postmanta, wp_posts, wp_woocommerce_order_itemmeta and wp_woocommerce_order_items. I found almost every info related to placed order in those tables But I couldn’t found quantity of products which are being ordered.

    If user has selected 5 quantity in cart page of any product then where in DB I can check how much quantity user has selected. I can watch quantity from dashboard ->woocommerce -> orders. But from where in DB this info is use to store?

    • This topic was modified 6 years, 10 months ago by rish30990.
Viewing 3 replies - 1 through 3 (of 3 total)
  • table: wp_woocommerce_order_itemmeta
    key: _qty

    Thread Starter rish30990

    (@rish30990)

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Where order quantity stored in database?’ is closed to new replies.