I need to update the sale price programmatically, on variable product and all his variations.
What kind of meta field do I need to add?
I'm trying to update main product such as:
update_post_meta($post_id, '_regular_price', '100');
update_post_meta($post_id, '_price', '50');
update_post_meta($post_id, '_sale_price', '50');
and then I update every single variations
update_post_meta($variation_id, '_regular_price', '100');
update_post_meta($variation_id, '_price', '50');
update_post_meta($variation_id, '_sale_price', '50');
update_post_meta($variation_id, 'attribute_pa_taglia', $term_slug);
update_post_meta($variation_id, '_stock', $stock);
update_post_meta($variation_id, '_stock_status', 'instock');
update_post_meta($variation_id, '_manage_stock', 'yes');
Back end: product detail, everything ok
However backend (product list) and frontend get me old price
Additionally you should try to add/update in your parent product ID (the main product where variation are set) these:
Furthermore, I've find other solution that work same: