Forum
Sold out variant
Is there a way to target a variant that has sold out in order to grey out the option in the select box/radio button? At the moment I have the main add to basket button removed when the main product has sold out, but no way of indicating an individual variant of that product is out of stock. At the moment it just wont add to the cart.
Good question. Are you using the select box display or templating it yourself?
I was using the select box as described in the documentation but found that the product wouldn't add to the cart with that, so have changed to the radio buttons as per the docs. They work fine and add to cart correctly.
I'm also finding that if a product stock level is set to 'In Stock' then it will not add to the cart, changing the stock level to 'Unlimited' and it adds to the cart fine.
What quantity of stock is set, regardless of status?
No quantity, just in stock...ah I guess it needs a quantity as well right!?
I can't work out the best way to display that to the end user...same as with the variants being out of stock. At the moment I have an if statement checking if the stock is set to "out of stock" but how to best combine that with the quantity being depleted?
Basically I need an OR between those two if statements but I dont think thats allowed :)
stock_level
is the one you want to test for. That's going to change dynamically as items are ordered.Thanks, any thoughts on the variants being out of stock? Also is it possible to remove the option of 'Unlimited' from the stock select box? Can't find where that is set and if unlimited is used it will still display out of stock.
If you're tracking stock on the variant (and not on the parent) then
stock_level
should be enough to tell if a variant is in stock or not.It's not possible at the moment to customise the stock level statuses.
Hi Drew, did you get anywhere with the original question? Still wandering how to display if a variant is out of stock and make the select option greyed out or similar so the user cannot try to add it to the cart.
Cheers!
It should be. Is it not?
No, if I set a variant to out of stock the radio button is still available to select...if you then add to cart it just jumps to the basket which is empty...so it is recognising the variant is out of stock but not displaying that to the user.
And you're setting it to be out of stock using the quantity field? (not the status)
Yes setting it in both fields
Ok, that shouldn't be the case.
Anything I can do to fix it at my end?
I don't think so, I'm going to look into it.