I’m looking for the location of a product’s prices according to the option which the user selects in the product price. For example, this WooCommerce shop has a select which prices change according to the user selection.
I want to know where are prices for different options stored in DB.
Thanks
4 s
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');