Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

Woocommerce Remove Add To Cart Single Product

Home / Forums / Virtue Theme / Woocommerce Remove Add To Cart Single Product

This topic is: Resolved
[Resolved]
Posted in: Virtue Theme
March 27, 2014 at 5:27 pm

I would appreciate if someone could help with this and answer a question about removing the add to car button for non members. I currently have the code below within the functions.php file. However it works for all the products on the site. However the only problem I have is after you are logged in it displays all prices but on the final single product page the add to cart button is missing but it shows for related products and all other products within the site. But as I said the single view product page it shows the price but is missing the add to cart button even when logged in. Anybody 😉 Thank you in advance.

function remove_loop_button(){
if(is_user_logged_in()){}else
remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 10 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );
}
add_action(‘init’,’remove_loop_button’);

add_filter(‘woocommerce_get_price_html’,’members_only_price’);

function members_only_price($price){
if(is_user_logged_in() ){
return $price;
}
else return ‘Login or Register to see price!’;

}

  • The forum ‘Virtue Theme’ is closed to new topics and replies.