Okay
  Public Ticket #1664402
Hide Add to Cart btn for custom user
Closed

Comments

  • mnasra started the conversation

    Hi,

    this code is not working to hide the add to cart button:

    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');

    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );

    which code do i need? I want to hide the button for specific groups.

    Best regards

    Mario


  • [deleted] replied

    Hi Mario,

    You can activate Catalog Mode (Theme Options > Shop Settings > Catalog Mode) in your site and that will hide the Add to Cart button.

    Does that work for you?

    Have a great day!

  • mnasra replied

    Are you serious?

    I waited 3 days, for this senseless answer. If you can't help me why are you replying and don't giving the ticket to someone else. This is not the first time this happened. I think you seriously don't read the tickets or are not interested in supporting your customers.

    AGAIN:

    I need to hide the add_to_cart_button with code. The standard code doesn't work on your theme.

    What i wrote before:

    remove_action'woocommerce_after_shop_loop_item''woocommerce_template_loop_add_to_cart');

    remove_action'woocommerce_single_product_summary''woocommerce_template_single_add_to_cart'30 );

    Above code is not hiding add_to_cart_button.

    which code do i need? 

    I want to hide the button for specific groups.<------------------------

    Best regards

    Mario


  • [deleted] replied

    Hi Mario,

    Sorry for the confusion. We read all the tickets and we try to reply in the best method possible. I was thinking that you just wanted to hide the "Add to Cart" button from your theme and make your shop to appear as Catalog shop.

    I will assign this ticket to another team member and you should receive a response very soon.

    Thanks!

  • [deleted] replied

    Hi Mario,

    If you want to hide the add to cart link for Loop items (catalog), use this code:

    function remove_add_to_cart_button_actions() {
        remove_action( 'oxygen_woocommerce_after_loop_item_title', 'woocommerce_template_loop_add_to_cart', 40 );
        remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
    }
    add_action( 'woocommerce_init', 'remove_add_to_cart_button_actions', 1000 );
    
    Please note that the checking for "customer" is not done, I guess you know how to handle this better, for example:

    $user = wp_get_current_user();
    if ( in_array( 'author', (array) $user->roles ) ) {
        //The user has the "author" role
    }
    
    I hope this helps you.

  • mnasra replied

    Thx Arlind it worked!

  • mnasra replied

    Can you only tell me where i can change the circle "+" add to cart button. I want to change it to text

  • [deleted] replied

    Hi mnasra,

    Glad to hear that.

    As for your last question:

    The option is not available in our theme but to do that please add the code below to your Custom CSS area:

    .glyphicon-plus-sign:before {
        content: "Add to cart" !important;
        font-size: 13px !important;
        font-family: "Roboto Condensed",Helvetica,Arial,sans-serif !important;
    }

    Will set this ticket as solved from here.

    Have a great day!