Increase all Woocommerce products prices by a percentage [closed]
Updated on July 2018
You can run the following SQL query, that will update all your product prices adding an extra 24% (and rounding prices too):
UPDATE `wp_postmeta` SET `meta_value` = ROUND(`meta_value` * 1.24, 2) WHERE meta_key LIKE '%_price%' AND (meta_value > 0 or `meta_value` != '')AND `post_id` IN ( SELECT `ID` FROM `wp_posts` WHERE `post_type` = 'product' AND `post_status` = 'publish' AND `ID` = `post_id`);
This is tested and works.
Before running this SQL query do a database backup
You might need to delete products transient cache going to Settings ->
Status ->
Tools (tab) and in "WooCommerce transients" you will "clear transients";
Handle product variations too:
You just need to replace this line:
WHERE `post_type` = 'product'
By this line:
WHERE `post_type` IN ('product','product_variation')
Additionally you will also need to use:
DELETEFROM `wp_options`WHERE (`option_name` LIKE '_transient_wc_var_prices_%' OR `option_name` LIKE '_transient_timeout_wc_var_prices_%')