Home Forums WoodMart support forum Out of stock remove add to cart on variable products

Out of stock remove add to cart on variable products

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #217742

    solarca
    Participant

    Hi,

    Not sure if this can be achieved but on simple products when the product is out of stock the add to cart button is not shown on the website. Just wondering if this can be done on variable products as well? Obviously more complicated as you would only want the button removed on the variation that was out of stock and leave it there for the variations that are in stock on the same product.

    Look forward to your reply. Thanks.

    #217826

    Hello,

    A variable product would have Add to cart as this button relates to the whole product, not to a certain variation.

    This is Woocommerce functionality and our theme does not influence that.

    Best Regards

    #218079

    solarca
    Participant

    Ok, no problem. Thank you for your reply.

    #218088

    Priit
    Participant

    Heyy!
    Use this snippet…add it to your funtctions or use wordpress Snippets plugin

    Grey-out Out of Stock Variations – That what it does 😉

    add_filter( 'woocommerce_variation_is_active', 'bbloomer_grey_out_variations_out_of_stock', 10, 2 );
     
    function bbloomer_grey_out_variations_out_of_stock( $is_active, $variation ) {
        if ( ! $variation->is_in_stock() ) return false;
        return $is_active;
    }

    Thank me later 😉

    #218090

    solarca
    Participant

    Hi Priit,

    Doesn’t seem to do anything for me, must be something else conflicting.

    Not sure it is quite what I want to achieve anyway as I have a back in stock notification that I would still like to show. Just wanting to hide the add to cart button.

    Thanks for trying.

Viewing 5 posts - 1 through 5 (of 5 total)