我需要以编程方式更新可变产品及其所有变体的销售价格。
我需要添加什么样的元字段?
我正在尝试更新主要产品,例如:
update_post_meta($post_id, '_regular_price', '100');
update_post_meta($post_id, '_price', '50');
update_post_meta($post_id, '_sale_price', '50');
然后我更新每一个变体
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
![enter image description here](https://i.stack.imgur.com/Exs9d.jpg)
然而后端(产品列表)和前端给我旧的价格
![enter image description here](https://i.stack.imgur.com/X3Y1I.jpg)