I modified a function to create custom prices for some of my members i.e. the normal price is $1 but if you\'re a bronze member it\'s $2, a silver member $3, etc.
The pr
With your code you are just changing the displayed variation price range. So you will need a bit more for this:
// Simple, grouped and external products
add_filter('woocommerce_product_get_price', 'custom_price', 90, 2 );
add_filter('woocommerce_product_get_regular_price', 'custom_price', 90, 2 );
// Product variations (of a variable product)
add_filter('woocommerce_product_variation_get_regular_price', 'custom_price', 99, 2 );
add_filter('woocommerce_product_variation_get_price', 'custom_price', 90, 2 );
// Variable product price ramge
add_filter('woocommerce_variation_prices_price', 'custom_variation_price', 90, 3 );
add_filter('woocommerce_variation_prices_regular_price', 'custom_variation_price', 90, 3 );
function custom_price( $price, $product ) {
// Only logged in users
if ( ! is_user_logged_in() ) return $price;
// HERE the defined plan ID
$plan_id = 1628;
if ( wc_memberships_is_user_member( get_current_user_id(), $plan_id ) ) {
$price *= 2; // set price x 2
}
return $price;
}
function custom_variation_price( $price, $variation, $product ) {
// Only logged in users
if ( ! is_user_logged_in() ) return $price;
// HERE the defined plan ID
$plan_id = 1628;
if ( wc_memberships_is_user_member( get_current_user_id(), $plan_id ) ) {
$price *= 2; // set price x 2
}
return $price;
}
Code goes in function.php file of the active child theme (or active theme).
Tested and works on woocommerce 3+
Now custom prices in cart will be also reflected