Hide add to cart / buy now buttons for specific products

This topic has 17 replies, 2 voices, and was last updated 4 months, 2 weeks ago ago by Luca Rossi

  • Avatar: HUSSTLE
    HUSSTLE
    Participant
    April 16, 2024 at 17:12

    is there CSS or PHP snippet that be shared to hide (remove) the add to cart and buy now buttons but keep the “Add To Quote” from specific product pages?

    Please, contact administrator
    for this information.
    16 Answers
    Avatar: HUSSTLE
    HUSSTLE
    Participant
    April 16, 2024 at 17:15

    update

    Please contact administrator
    for this information.
    Avatar: Justin
    Luca Rossi
    Support staff
    April 17, 2024 at 05:04

    Dear HUSSTLE,

    We hope this message finds you well.

    We would like to provide you with a solution to selectively hide the “Add to Cart” and “Buy Now” buttons for certain products on your website. Please implement the following custom CSS code to achieve the desired effect:

    
    .single-product.postid-2299 form.cart .woocommerce-variation-add-to-cart,
    .single-product.postid-2299 form.cart table.variations {
        display: none !important;
    }
    

    This code should be inserted into your site’s custom CSS section. If you require any further assistance or have additional questions, please do not hesitate to reach out.

    Warm regards,
    The 8Theme Team

    Avatar: HUSSTLE
    HUSSTLE
    Participant
    April 17, 2024 at 14:08

    update #2

    Please contact administrator
    for this information.
    Avatar: Justin
    Luca Rossi
    Support staff
    April 17, 2024 at 15:38

    Hi @HUSSTLE,

    In this case, pleaase delete the previous CSS code and add this custom CSS code instead:

    
    div#wc-stripe-payment-request-wrapper,
    .single-product.postid-2299 form.cart table.variations,
    .single-product.postid-2299 form.cart .woocommerce-variation-add-to-cart .single_add_to_cart_button {
        display: none !important;
    }
    

    https://prnt.sc/j–fWthDyEVb

    Let us know how it goes!

    Avatar: HUSSTLE
    HUSSTLE
    Participant
    April 17, 2024 at 16:06

    ability to remove add to cart and buy now, while keeping add to quote worked perfectly. THANKS!

    Avatar: Justin
    Luca Rossi
    Support staff
    April 18, 2024 at 04:47

    Dear @HUSSTLE,

    We are pleased to confirm our assistance.

    Best regards,
    The 8Theme Team

    Avatar: HUSSTLE
    HUSSTLE
    Participant
    July 29, 2024 at 14:42

    So – this code has worked perfectly for our situation, but I have another request. It is possible to “exclude” the BUY NOW and ADD TO CART from a variation option? Meaning an variation “child” of the parent item.

    Please contact administrator
    for this information.
    Avatar: Justin
    Luca Rossi
    Support staff
    July 29, 2024 at 15:46

    Hi @HUSSTLE,

    It could be done by the custom JS, please add the following code under functions.php file locates in your child theme:

    
    add_action('wp_footer', 'n2t_wp_footer');
    function n2t_wp_footer(){
    	if(is_product()){
    		?>
    		<script>
                jQuery( function($){
                    $(document).ready(function(){
                        $( '.single_variation_wrap' ).on( 'show_variation', function( event, variation ) {
                            if(variation.sku == "FG-8" || variation.sku == "FG-10" || variation.sku == "FG-12"){
                                $('.woocommerce-variation-add-to-cart').hide();
                            } else {
                                $('.woocommerce-variation-add-to-cart').show();
                            }
                        });
                    })
                });
    		</script>
    		<?php
    	}
    }
    

    Hope it helps!

    Avatar: HUSSTLE
    HUSSTLE
    Participant
    July 29, 2024 at 15:57

    I’ve added the CSS ..

    Please contact administrator
    for this information.
    Avatar: Justin
    Luca Rossi
    Support staff
    July 29, 2024 at 16:15

    Hi @HUSSTLE,

    Yes, you’re on the right way. Just need to explain this line:

    
    if(variation.sku == "FG-8" || variation.sku == "FG-10" || variation.sku == "FG-12"){
    

    So it could be:

    
    if(variation.sku == "FG-8" || variation.sku == "FG-10" || variation.sku == "FG-12" || variation.sku == "FG-14" || variation.sku == "FG-16"){
    

    The FG-8, FG-10, FG-12,… are the SKUs of your products.

    Best Regards,
    The 8Theme Team.

    Avatar: HUSSTLE
    HUSSTLE
    Participant
    July 29, 2024 at 16:20

    Luca – perfect …

    Please contact administrator
    for this information.
    Avatar: Justin
    Luca Rossi
    Support staff
    July 30, 2024 at 04:20

    Hi @HUSSTLE,

    Please update by yourself, we just give you the example of SKUs.

    Best regards,
    The 8Theme Team

    Avatar: HUSSTLE
    HUSSTLE
    Participant
    July 30, 2024 at 15:09

    Luca – the CSS has been applied but ….

    Please contact administrator
    for this information.
    Avatar: Justin
    Luca Rossi
    Support staff
    July 31, 2024 at 05:37

    Dear @HUSSTLE,

    We hope this message finds you well. We would like to inform you that the code provided is in PHP.

    Please ensure that you place it within the functions.php file located in your child theme, or alternatively, you can implement it using a code snippet plugin.

    Best regards,
    The 8Theme Team

    Avatar: HUSSTLE
    HUSSTLE
    Participant
    July 31, 2024 at 15:19

    My apologies; you are correct. WORKS PERFECTLY!

    Thanks!

    Avatar: Justin
    Luca Rossi
    Support staff
    July 31, 2024 at 15:28

    Glad we’re able to help you!

    Best regards,
    The 8Theme Team

  • Viewing 17 results - 1 through 17 (of 17 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.