• Resolved webinize

    (@webinize)


    Hi all,
    Hope you are all well during this period!

    Im creating a page to list order details based on data pulled from SQL…

    While I have no problem creating the code for now, I am having difficulty locating the order quantity of any order ID.

    I searched in wp_postmeta and wp_posts tables but to no avail.

    Can anyone please advise?

Viewing 4 replies - 1 through 4 (of 4 total)
  • wp_posts, post_type = shop_order to find the order number
    wp_woocommerce_order_items to find the order_item_ids for that order number
    wp_woocommerce_order_itemsmeta to find the quantity for each order_item_id where meta_key = _qty

    Thread Starter webinize

    (@webinize)

    @lorro thank you for your reply!

    Perhaps it is due to the new database update by woocommerce as of 4.0, but I am unable to find table wp_woocommerce_order_itemsmeta that corresponds to wp_posts WHERE post_type=’shop_order’

    Could it be due to the new database update? Or is there an issue with my phpMyAdmin where my database tables are not showing properly?

    Cheers!

    No it won’t. Its a multi-step process, 1. get the order id. 2 get the ids of the order items for that order from the order_items table. 3 get the quantities of those order items from the order_itemsmeta table.

    This mechanism hasn’t changed recently.

    Thread Starter webinize

    (@webinize)

    @lorro

    I realized a really silly mistake which I think beginners like me tend to overlook.

    I missed the pagination in phpMyAdmin, therefore I thought that some of my tables are missing when I could have went to the next page and find the tables you mentioned above.

    I managed to establish the link between the tables and I will proceed to run my SQL Query accordingly.

    Thank you so much my friend. God bless and take care

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘How to find order quantity in SQL database’ is closed to new replies.