This topic has 17 replies, 2 voices, and was last updated 3 months, 2 weeks ago ago by Luca Rossi
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?
update
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
update #2
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;
}
Let us know how it goes!
ability to remove add to cart and buy now, while keeping add to quote worked perfectly. THANKS!
Dear @HUSSTLE,
We are pleased to confirm our assistance.
Best regards,
The 8Theme Team
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.
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!
I’ve added the CSS ..
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.
Luca – perfect …
Hi @HUSSTLE,
Please update by yourself, we just give you the example of SKUs.
Best regards,
The 8Theme Team
Luca – the CSS has been applied but ….
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
My apologies; you are correct. WORKS PERFECTLY!
Thanks!
Glad we’re able to help you!
Best regards,
The 8Theme Team
You must be logged in to reply to this topic.Log in/Sign up