Hi,
I need to have variants of a product to have the same quantity.
I’m selling tickets for an event, with some variants (with obviously different prices) like Ticket only; Ticket + Open Bar; Ticket + parking and so on…
The point is: there’s not a particular quantity for any variants, but just a number of total tickets that we can sell. We have 100 seats, and I don’t care if I sell 90 standard tickets and 10 with open bar or the contrary, I just need to be sure that I don’t overbook my 100 seats.
Any way to do it?
Hi @BogusLab
If all the variant quantites added equals 100 this code below should work ( added to the product page). You will also need to
set the inventory policy to continue and to track the inventory. We will also be able to help you
implement this at outfoss.com
{% assign totalTickets = 0 %}
{% for variant in product.variants %}
{% if variant.inventory_quantity > 0 %}
{% assign totalTickets = totalTickets | plus: variant.inventory_quantity %}
{% else %}
{% assign num = variant.inventory_quantity | abs %}
{% assign totalTickets = totalTickets | minus: num %}
{% endif %}
{% endfor %}
{% if totalTickets == 0 %}
{% assign disableAddToCart = true %}
{% else %}
{% assign disableAddToCart = false %}
{% endif %}