Add to cart button showing in stock variable products in Woocommerce

So I have a strange thing going on with my Woocommerce store.

Right now, when one product (no options) is missing, the Quantity and Add to Cart buttons disappear - which is what I want. It just shows the label "Out of stock".

When I have a variable product (with two options) that has all the options in stock, it still shows the Quantity and Add to Cart buttons (grayed out).

How to hide the "Quantity + Add to Cart" button in ALL cases, whether it is a single product or a variable product when out of account?

Any help is greatly appreciated!

+3


source to share


2 answers


Here is a plugin to help you hide the add to cart button, especially for the product: Woocommerce Hide Add to Cart Button

It helps to hide the add to cart button,

Hide Add to Cart button from product single page.
Hide Add to Cart button from category page.
Hide Add to Cart button from homepage and all other pages.

      



Also you can hide it by adding the following function in functions.php

,

if (!function_exists('woocommerce_template_loop_add_to_cart')) {
    function woocommerce_template_loop_add_to_cart() {
        global $product;
        if ( ! $product->is_in_stock() || ! $product->is_purchasable() ) return;
        woocommerce_get_template('loop/add-to-cart.php');
    }
}

      

0


source


can you post a link to the site or developer site so we can take a look. Alternatively implement the following code.



.[class for for button if product is out of stock]{
display: none;
}

      

0


source







All Articles