I'm trying to hide only one of the two variations of a product in WooCommerce for visitors that are not logged in. The ID of the variation is 139. I don't know how to add the ID (or slug) to this piece of code.
<?php // Hide WooCommerce variations for non-logged-in users
function my_theme_hide_price_not_authorized() {
if ( !is_user_logged_in() ) {
// Hide variations
add_filter( 'woocommerce_variation_is_active', 'my_theme_disable_variation', 10 , 2 );
}
}
add_action('init', 'my_theme_hide_price_not_authorized');
// Hide product variations
function my_theme_disable_variation() {
return false;
}
Can someone help me out?