Академический Документы
Профессиональный Документы
Культура Документы
yanknudtskov / woocommerce-update-prices.sql
Last active 16 days ago
Queries for updating all prices including variations in WooCommerceIn this instance all prices are
subtracted 20% (0.8)#woocommerce #mysql
woocommerce-update-prices.sql
Thanks for sharing, you just saved me quite a bit of time which in turn has saved my
client hoooourrrrrsss of manual updating! :)
You also have to delete price caching. Otherwise you won't see any changes.
1 of 5 7/19/20, 11:23 PM
Queries for updating all prices including variati... https://gist.github.com/yanknudtskov/9e725d5...
Great, this is very helpful. Is there any way to update a price only if the price is lower
than 100$? Is it:
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE meta_key =
'_sale_price' AND meta_value <= '100'
?
Great, this is very helpful. Is there any way to update a price only if the price is
lower than 100$? Is it:
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE meta_key =
'_sale_price' AND meta_value <= '100'
?
1. Use 100 instead of '100'. You should compare numbers not strings.
Also add a condition to avoid warnings.
Also you might want to update only lower than 100 not equal.
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE meta_key =
'_sale_price' AND meta_value != '' AND meta_value < 100
Great, this is very helpful. Is there any way to update a price only if the
price is lower than 100$? Is it:
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE
meta_key = '_sale_price' AND meta_value <= '100'
?
1. Use 100 instead of '100'. You should compare numbers not strings.
Also add a condition to avoid warnings.
Also you might want to update only lower than 100 not equal.
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE
2 of 5 7/19/20, 11:23 PM
Queries for updating all prices including variati... https://gist.github.com/yanknudtskov/9e725d5...
Hello. Is there any way to update the current _sale_price increasing it's value 35%?
Hello. Is there any way to update the current _sale_price increasing it's value
35%?
You also have to delete price caching. Otherwise you won't see any changes.
Thanks :-)
3 of 5 7/19/20, 11:23 PM
Queries for updating all prices including variati... https://gist.github.com/yanknudtskov/9e725d5...
You could probably do something like this to get all products in a category,
SELECT ID as post
INNER JOIN wp_term_relationships rs ON rs.object_id = post.ID
WHERE post_type = "post" //post type post for my example
AND post_status = "publish"
AND rs.term_taxonomy_id = 1 //term_taxanomy_id is 1 for my example
You could probably do something like this to get all products in a category,
SELECT ID as post
INNER JOIN wp_term_relationships rs ON rs.object_id = post.ID
WHERE post_type = "post" //post type post for my example
AND post_status = "publish"
AND rs.term_taxonomy_id = 1 //term_taxanomy_id is 1 for my example
4 of 5 7/19/20, 11:23 PM
Queries for updating all prices including variati... https://gist.github.com/yanknudtskov/9e725d5...
Hope it helps.
5 of 5 7/19/20, 11:23 PM