Trouble applying quantity based discounts to line items

Hello,

I am having trouble applying quantity based discounts to line items using the Orders API .NET SDK. Specifically, the issue I am having is that the quantity of the line item is not being factored in when calculating the line item’s applied discounts amount. Instead just the fixed amount of the discount is being applied, but I am expecting that it would be multiplied by the line item’s quantity. Let me explain.

I have setup the quantity based discount shown by the screenshot. If at least 6 items are purchased, then a $0.25 discount should be applied to each one.

When using the POS this discount works perfectly, that is, if I create an order with a line item for empanadas with a quantity of 6, a discount of $1.50 is applied to the line item, which is correct because 6 x $0.25 equals $1.50. But when I use the Orders API the applied discount for the same line item is only $0.25, even though the quantity of the line item is 6. Why would this be?

Here’s the code I am using to create the discounts for the order and the line items.

For the order I create the following:
new OrderLineItemDiscount(catalogObjectId: “XXX”, uid: “XXX”, scope: “LINE_ITEM”)

For the line item I create the following which reference the above OrderLineItemDiscount:
new OrderLineItemAppliedDiscount(discountUid: “XXX”)

But when I create the order, the resulting order object’s applied discounts for the line item is only $0.25 when I am expecting it to be $1.50.

What am I doing wrong? Thank you for your help

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Automatically Apply Discounts
Create Volume Discounts
Create Bundled Discounts

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

Based on the information provided, it seems like you’re correctly applying the discount to the line item. However, the issue you’re experiencing might be due to how the Orders API handles quantity-based discounts.

When you create an order with the Orders API, it doesn’t automatically apply quantity-based discounts in the same way as the Square Point of Sale. The Orders API applies the discount to the line item as a whole, not to each individual unit within the line item.

In your case, the Orders API is applying the $0.25 discount to the line item of 6 empanadas as a whole, not to each individual empanada. That’s why you’re seeing a total discount of $0.25 instead of $1.50.

To achieve the desired result, you would need to create separate line items for each unit of the product, and then apply the discount to each line item. This way, the $0.25 discount would be applied to each individual empanada, giving you the total discount of $1.50 for 6 empanadas.

This answer was reviewed by @Bryan-Square.