is there a simplistic way to get a line item disco...
# support
j
is there a simplistic way to get a line item discount to not stack on top of a line if it has an existing line item discount?
✅ 1
c
I am not really sure what you mean by this? Can multiple discounts even be applied to the same line item, or are you mixing order level and line item level discounts?
IIRC the biggest discount is the one that is picked per line item.
j
perhaps it's because i'm using custom rules -- they're stacking on my store though
but i guess it's a line item discount stacking with a custom rule discount
i haven't check 2 strict line item discounts
for now i've decorated
create_item_adjusments
to skip line items if they already have and adjustment applied
c
Technically you can have multiple adjustments applied to a single line item, but only one should be
eligible
, but I am having trouble finding the code in Solidus that’s responsible for that.
I might be wrong on the stacking or my search is failing me 😄
OK, with the help of @Adam Mueller, I’ve found the thing I am talking about - https://github.com/solidusio/solidus/blob/master/core/app/models/spree/promotion_chooser.rb. This is a configurable class in Solidus, but essentially it’s purpose is to define the logic for choosing the best promotion to apply.
@jakemumu I would check if your app doesn’t provide a custom version of this class and probably put your logic in there rather than overriding
create_item_adjusments
.
If you prevent the adjustment from being created altogether, what can happen is if something with the order changes and all of a sudden the “other” eligible adjustment is no longer eligible, you won’t be able to activate the non-eligible one because in your case it won’t exist.
j
oooo
i had no idea that existed
c
Haha, me too, I only knew that there should be only one eligible adjustment per line item 😂
j
Thanks for the explanation -- it's gotta be because our rules are voiding that logic and causing all the math to go funky
👍🏼 1