I'm trying to adjust the price of products in the database. I need to customize products that have custom taxonomy manufactory with id 270.
I can change a simple product with this code:
UPDATE wp_postmeta
LEFT JOIN wp_term_relationships ON wp_term_relationships.object_id = wp_postmeta.post_id
SET
wp_postmeta.meta_value = wp_postmeta.meta_value*1.05
WHERE
wp_postmeta.meta_key = "_regular_price"
AND wp_term_relationships.term_taxonomy_id = "270"
But it won't change prices for variable products ... Can anyone help me?
I'm trying to adjust the price of products in the database. I need to customize products that have custom taxonomy manufactory with id 270.
I can change a simple product with this code:
UPDATE wp_postmeta
LEFT JOIN wp_term_relationships ON wp_term_relationships.object_id = wp_postmeta.post_id
SET
wp_postmeta.meta_value = wp_postmeta.meta_value*1.05
WHERE
wp_postmeta.meta_key = "_regular_price"
AND wp_term_relationships.term_taxonomy_id = "270"
But it won't change prices for variable products ... Can anyone help me?
Share Improve this question asked Oct 30, 2019 at 12:28 uhercikuhercik 132 silver badges5 bronze badges1 Answer
Reset to default 0So after a few attempts, I managed to change the price for variable products. If someone needs to send my code:
UPDATE wp_postmeta
LEFT JOIN wp_posts ON wp_posts.id = wp_postmeta.post_id
LEFT JOIN wp_term_relationships ON wp_posts.post_parent = wp_term_relationships.object_id
SET
wp_postmeta.meta_value = wp_postmeta.meta_value*1.05
WHERE wp_posts.post_type = 'product_variation'
AND wp_postmeta.meta_key = '_regular_price'
AND wp_term_relationships.term_taxonomy_id = '2396'