最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

sql - Woocommerce change the price of products in the database

programmeradmin2浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

So 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'
发布评论

评论列表(0)

  1. 暂无评论