hiding Add to cart until logged in
-
I’m using Woocommerce 2.4.6 & WordPress 4.2.4
I’m using Avada ThemeI’ve installed Woocommerce Thumbnail Input Quantities allowing users to select quantities without going to Single Product page.
I’m using this code below to Hide Prices until user has logged in
// Hide prices
add_action(‘after_setup_theme’,’activate_filter’) ;function activate_filter(){
add_filter(‘woocommerce_get_price_html’, ‘show_price_logged’);
}function show_price_logged($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 );
return ‘‘ . __(‘Login to see prices’, ‘theme_name’) . ‘‘;
}
}Found here https://businessbloomer.com/woocommerce-hide-price-add-cart-logged-users/
I have tow Public pages Sale Products & Featured products (these are simply created using short code)
problem is on these 2 public pages
Qty, Add to Cart Button and Details Button still Show (although the price is hidden !!)How can I hide these for NON logged in users i.e. public – So only when user is logged in these items are shown… perhaps adapting the above code ?
- The topic ‘hiding Add to cart until logged in’ is closed to new replies.