Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › How to remove add to cart buttons for users not logged in
Tagged: Hide Price Users
- This topic has 0 replies, 1 voice, and was last updated 4 years, 4 months ago by Invoke.
Viewing 0 reply threads
- AuthorPosts
- January 3, 2020 at 1:56 pm #100707InvokeParticipant
Hello i’m trying to remove the add to cart button for users that are not logged in in the website. Ussualy i use something like this
add_action( 'init', 'hide_price_add_cart_not_logged_in' ); function hide_price_add_cart_not_logged_in() { if ( ! is_user_logged_in() ) { remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_template_loop_add_to_cart', 10 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); add_action( 'woocommerce_single_product_summary', 'print_login_to_see', 31 ); add_action( 'woocommerce_after_shop_loop_item', 'print_login_to_see', 11 ); } } function print_login_to_see() { echo '<a class="re_track_btn woo_loop_btn btn_offer_block" href="' . get_permalink(wc_get_page_id('myaccount')) . '">' . __('See price', 'rehub') . '</a>'; }
But i notice that you already remove the woocommerce_single_product_summary actions
Note:
i’m using the comparison price view for the product page from the rehub theme (Revendor Child theme).
- AuthorPosts
Viewing 0 reply threads
- You must be logged in to reply to this topic.