Hello Community! I’m trying to get my head around...
# general
k
Hello Community! I’m trying to get my head around why we allow creating line items with 0 as quantity and still can’t find an answer. I know we are currently setting line items quantity to 0 to remove items from the order but I can’t find any reason why allowing to add to cart with 0 quantity. Is anyone out there using this “feature”, and if yes can you help me understand how please? Please 👎 if you are not using it, were not aware of that, or now that you know, you think it’s not ideal. Thanks in advance!!
👎🏻 1
👎🏼 1
👎 9
j
This is going to be pretty out there, but we build customized cards out of multiple line items to represent add-ons. However, we allow cards to be both shipped and mailed. Some add-ons only apply to shipped cards, which we allow users to set to later update to 0 quantity from the cart, but they still keep the item because they have a separate mailed quantity. If you add 10 shipped cards with add-ons to the cart, you may decrease to 0 shipped cards (assuming there are still mailed ones), but we keep the add-ons there with 0 quantity so that if you switch back to having shipped cards again, we don't forget all the customizations you chose.
m
Best use case I can think of is for stores that want to support Buy Nothing Day.
😅 1
👍 1
k
@jon_wu thanks for the feedback. If I got it correctly, you are allowing users to set 0 quantity updating the line items in the cart but never creating it with 0 as quantity, is that correct? If that’s the case, I think that will still be totally possible if we deprecate this behavior.
j
@kennyadsl in our case, we also add cart items with 0 quantity if you start with 0 shipped, but have mailed cards too, so if you increase the quantity from the cart all the right add-ons will be there. However, this seems like a very specific use case, and one that perhaps isn't widely applicable. There may be better ways to represent add-ons or maybe the current behavior could be restored with a customization, but not allowed by default.
k
Ah got it, I think there’s a way to present those items in the cart even without having them physically connected with the order with quantity 0. If I got it correctly they do not change from order to order so if those product have a relationship between each other you can still present them close to the item they are associated with, and add a button/form to add to cart with some real quantity, am I right?
Something like this in the cart:
Copy code
line_item.variant.add_ons.each do |item|
  render :addons_add_to_cart, item: item
end
So they are still there, ready to be added, but they are not yet line items
j
These are personalized options, so they are customer and parent item specific. For example, you can choose a card, but then choose to have a custom envelope design (perhaps out of hundreds of options). We need to remember what you chose, even if you start or change to 0, then later increase the quantity. I could imagine storing this info with parent item metadata or something though instead of having these weird 0 quantity items, as we then also have code to filter them out when an order is placed, which feels a bit convoluted.
k
that’s what I was asking 🙂
👍 1
thanks a lot for the feedback!