Hey! Quick question for the crew -- is there a way...
# support
j
Hey! Quick question for the crew -- is there a way from a line item level to get an effective price of that line_item with consideration to both the line_item promo totals & the order level promo totals? It appears quite difficult because the line_item totals are added to the order level promos
finding myself have to some pretty quirky and edgecasey math to figure out -- what exactly a customer paid for a specific product on a order with respect to both
something like:
line_total = line_item.price - line_item.promo_total - (order.promo_total - all_line_item_promo_total) / line_items.count
?
^ but this doesn't work because it equally distributes an order discount across line items, instead of (if it was 50% off) -- take 50% off each item individually
b
You would need to go from the line item to its adjustments.
Something like
Copy code
line_item.adjustments.sum(:amount)
Oh and that's what you got in your snippet
Does this also include the shipment adjustments?
Yeah, it really should just be
line_item.amount - line_item.adjustments.sum(:amount) - order.item_total / order.line_items.size
Adjustments solves everything from taxes to manual changes to line items.
And the
item_total
makes it so that you don't inlcude the
shipment_total
in your calculation.
@jakemumu ^
j
hmm yeah -- finding weird stuff with promotions like allowing this on our site:
that's helpful though i'll give that a shot thank you!