Closed kaspar-allenbach closed 8 years ago
Hey @Seppentoni! Sure, the Snipcart product definition links support data-item-max-quantity
, so you could add a Number field in Craft and use it to generate the markup for the add to cart button.
If your Craft field is called maxQuantity
, then, your template's buy button for an entry might look something like this...
<a href="#"
class="btn snipcart-add-item"
data-item-id="{{ entry.id }}"
data-item-name="{{ entry.title }}"
data-item-price="{{ entry.price }}"
data-item-weight="{{ entry.weight }}"
data-item-url="{{ entry.url }}"
data-item-quantity="1"
{% if entry.maxQuantity %}data-item-max-quantity="{{ entry.maxQuantity }}" {% endif %}
>
...note that second to last line where we're checking for maxQuantity
and passing it on to Snipcart. Super easy!
Yeah, but does snipcart take this number into account automatically? So when I enter '30'. After 30 selling snipcart closes this item down?
The Snipcart folks wrote a post on this topic, and this Craft plugin could easily be tailored for automated inventory deduction in your setup. This is exactly what Anna Brown did on her project for Sackwear.
Hi.
I'm just fiddling around with snipcart on craft. I just stumbled over your plugin. Is it somehow possible to define a max quantity in craft and then pass it along to snipcart?