I am using Woocommerce in my website and I should need to add 24% extra to all my products prices.
How this can be done in an easy way?
Using a database Query will be the best way my be. Any help is appreciated.
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:
DELETE
FROM `wp_options`
WHERE (`option_name` LIKE '_transient_wc_var_prices_%'
OR `option_name` LIKE '_transient_timeout_wc_var_prices_%')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With