WooCommerce prices location in DB

All the data like different prices of a product custom post type are store (for each product) in postmeta table.

To find the post id of all products you have to use this query on posts table:

SELECT *  FROM 'posts' WHERE 'post_type' = 'product'

For each product id (post_id), you can retrieve all related data with this query on postmeta table:

SELECT * FROM 'postmeta' WHERE 'post_id' = nnnn

(nnnn is the number id (post_id) of a product)

You will get the list of all product properties metakey and metavalues.
For related price meta_key(s) you have, for example:
_regular_price
_sale_price
_price
– …

To get a particular value of a product meta_key, you can use the wordpress function:

get_post_meta($post_id, '$meta_key');

Leave a Comment