Closed TheFunkyMonk closed 1 month ago
Thanks this is fixed for the next release. You can use this in your templates in the meantime:
{% if variant.inventoryTracked %}({{ variant.stock ? variant.stock ~ ' available' : 'out of stock'}}){% endif %}
5.0.7 is now out and fixes this issue. Thanks!
What happened?
Description
In the Commerce 5 example templates, I noticed most of our products were showing "out of stock" on the front end. If I'm understanding the stock setup correctly, having the "Inventory" toggle turned off for a variant is used to indicate unlimited/infinite stock (which also is what displays the ∞ in the table column).
Looking at the check in
products/_includes/grid.twig
, I see it's usingvariant.stock
as the check for whether a variant is in stock, but looking at the docs it seems variant.hasStock() is the correct way to check now (which functions as I'd expect in my template).Craft CMS version
5.1.4
Craft Commerce version
5.0.6
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response