I want to change the prices for variable products in woocommerce. I tried with below MySQL query to do it,
UPDATE wp_postmeta
SET meta_value = price_value
WHERE post_id = variation_id AND meta_key = '_sale_price';
but its updating only in backend(DB and admin area) not in front-end. Actually in front-end its not showing sale price also. As I'm not good at SQL, is there any code snippet or WooCommerce hook which allows me to change the price for a variable product?
Thanks.
ADDED If you want to merge all the above query into a single query you can use this one:
Also you have to delete WooCommerce product price caching which is stored in
wp_options
table under_transient_timeout_wc_var_prices_{{post_id}}
and_transient_wc_var_prices_{{post_id}}
inoption_name
All the above query is tested and worked for me.
Before running this query do take a database backup
Reference: Copy WooCommerce products Sale prices to regular prices and reset Sale prices
Hope this helps!