Add to cart is not hidden for the first product
-
Hi,
My website’s expected behavior is to hide add_to_cart button if the user isn’t logged in. However, the first product on the archive page still has the button. Here’s the code:add_action('after_setup_theme','activate_filter') ; function activate_filter(){ add_filter('woocommerce_get_price_html', 'bbloomer_show_price_logged'); } function bbloomer_show_price_logged(){ if(!is_user_logged_in() ){ 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 ); } }
website: https://www.viva-viva.ru
Please help! Also, is there a way not to open a cart sidebar when add_to_cart is clicked?
Thank you
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Add to cart is not hidden for the first product’ is closed to new replies.