Created
July 18, 2022 14:39
-
-
Save tuongpgjz/330ea2e9c7285850b6f72922ee1afbfc to your computer and use it in GitHub Desktop.
Update product price base on category
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- SalesGen.io | |
-- Change 'category name' by your category name | |
-- Reduce current price 5 | |
update `wp_postmeta` SET meta_value = meta_value - 5 WHERE meta_key IN ('_regular_price', '_price') AND meta_value <> '' AND post_id IN (SELECT object_id from wp_term_relationships WHERE term_taxonomy_id IN(SELECT term_taxonomy_id FROM `wp_term_taxonomy` WHERE taxonomy = 'product_cat' AND term_id IN (SELECT term_id FROM `wp_terms` WHERE name = 'category name'))); | |
-- Increase current price 5 | |
update `wp_postmeta` SET meta_value = meta_value + 5 WHERE meta_key IN ('_regular_price', '_price') AND meta_value <> '' AND post_id IN (SELECT object_id from wp_term_relationships WHERE term_taxonomy_id IN(SELECT term_taxonomy_id FROM `wp_term_taxonomy` WHERE taxonomy = 'product_cat' AND term_id IN (SELECT term_id FROM `wp_terms` WHERE name = 'category name'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment