Php 未注册客户的电子商务隐藏定价

Php 未注册客户的电子商务隐藏定价,php,wordpress,woocommerce,hide,hidden-field,Php,Wordpress,Woocommerce,Hide,Hidden Field,我正试图建立我的woocommerce商店,向注销的用户隐藏价格。我有两个不同的代码,每一个都只是我想要的一部分 此代码隐藏了价格,但当他们单击变体时,仍会显示“添加到购物车”按钮,并且他们可以在购物车中看到价格: add_filter('woocommerce_get_price_html','members_only_price'); function members_only_price($price){ if(is_user_logged_in() ){ return $price; }

我正试图建立我的woocommerce商店,向注销的用户隐藏价格。我有两个不同的代码,每一个都只是我想要的一部分

此代码隐藏了价格,但当他们单击变体时,仍会显示“添加到购物车”按钮,并且他们可以在购物车中看到价格:

add_filter('woocommerce_get_price_html','members_only_price');
function members_only_price($price){
if(is_user_logged_in() ){
return $price;
}
else return '<a href="' .get_permalink(woocommerce_get_page_id('myaccount')).         
'">Login</a> or <a href="'.site_url('/wp-login.php?   
action=register&redirect_to=' .         
get_permalink()).'">Register</a> to see price!';
}
这是指向产品页面的链接:

我的PHP编码技能是新手。。。我一直在尝试在这里和那里添加位,但它不起作用


非常感谢您的帮助

我最近也有同样的问题,我得到了一个有效的答案,看一看!
add_filter('woocommerce_get_price_html','members_only_price');
function members_only_price($price){
if(is_user_logged_in() ){
return $price;
}
else .remove_action( 'woocommerce_after_shop_loop_item',   
'woocommerce_template_loop_add_to_cart' ).remove_action( 
'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 
).remove_action( 'woocommerce_single_product_summary', 
'woocommerce_template_single_add_to_cart', 30 ).remove_action( 
'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 
10 );
}