In Woocommerce, I would like to apply custom price for a specific product.
This is my actual code:
add_action('woocommerce_get_price','change_price_regular_member', 10, 2);
function change_price_regular_member($price, $productd){
return '1000';
}
Any help on this is appreciated.
The hook woocommerce_get_price
is outdated and deprecated in Woocommerce 3 (and it was a filter hook but NOT an action hook). It has been replaced by woocommerce_product_get_price
.
So instead try this (where you will define your targeted Product ID in this hooked function):
add_filter( 'woocommerce_product_get_price','change_price_regular_member', 10, 2 );
function change_price_regular_member( $price, $product ){
// HERE below define your product ID
$targeted_product_id = 37;
if( $product->get_id() == $targeted_product_id )
$price = '1000';
return $price;
}
This code goes on function.php file of your active child theme (or theme). Tested and works.