I have a price update on all products to sync the shop prices with a web service XML. This is the part that updates the price. It's run with a server cronjob every hour. The problem is that, although I can see the prices updated, in wp-admin edit product pages, in the admin product list, and in the front end it still shows the old prices.
$product = new WC_Product( $pid );
update_post_meta($pid, '_regular_price', $set_price);
update_post_meta($pid, '_price', $set_price);
$product->set_regular_price($set_price);
$product->set_price($set_price);
$product->save();
What am I doing wrong here?
Just an update something i just notice, for example on products that have the the sale_price set, on the admin edit page its all ok but on admin list product page and frontend the sale price shows the regular_price.
After more digging it seems that the issue maybe related to the save instruction. All the fields are populated correctly with the changes, so if i go to edit product page and add a change, i.e. add a 0 in regular price and then save it assumes the changes made.
Is there a way that i can see the query executed by wordpress/woocomerce when pressing the save button on a edit product page?