Hello i am updating the product meta data on the hook woocommerce_update_product.
The reason is i want to calculate some custom fields.
But i have the problem that the update of the meta data triggers the hook itself again. So it does never stop.
function change_unit_price($product_id)
{
//test get data
$_product = wc_get_product($product_id);
$_regular_price = $_product->get_regular_price();
$_sale_price = $_product->get_sale_price();
$_meta_data = $_product->get_meta_data();
// test set value
$_product->update_meta_data('_unit_price_regular', "898");
$_product->save();
}
add_action('woocommerce_update_product', 'change_unit_price', 99, 1);
Does someone has a solution for this or is there a workflow i don’t know yet? This is my first try with wordpress plugins.