I’d like to get current variation data inside the raw_woocommerce_price hook.
function filter_raw_woocommerce_price( $price_1 ) {
global $product;
// Some custom code to change price by variation factor
$variation_id = product->Something_I_Need_To_Know_To_Get_Current_Variation();
// bla bla bla
$factor = PutSomeCustomCalculationHere($variation_id);
$price_1 = $price_1 * $factor;
return $price_1;
};
add_filter( 'raw_woocommerce_price', 'filter_raw_woocommerce_price', 10, 1 );
How can I achieve that?
Thank you
use this code, if the product is ok type use your custom logic like this:
‘raw_woocommerce_price’ was not the hook that I need.
Using instead these hooks was the way to go.
Why? Because these hooks have the product’s instance as the second parameter. There, it got all information I need to got further.