question

Jai avatar image
Jai asked voski commented

Clover line Item discounting schema

In Clover Setup Application , if we check the setting of group similar Line Items from Orders tab, We have configured a discount rule such that the , if the same line item is present in the order with quantity 2 then we will apply 2 discounts with same Discount.discount.id.

"Let us assume we have line Item ABC in the order with qty.2 and we apply $5 to first product and $25 to second product but in Order Summary UI I am seeing Line Item ABC with qty 2 and applied discount $50 instead of $30 . Although in order subtotal $30 amount is getting reduced from order."

If we unchecked the setting from setup app, then two line items are getting displayed with the respective discount amounts.

By the clover behaviour it seems grouping of line items is done on the basis of item to which line item is associated. However if grouped line items have different discount with the same name then clover is taking the first discount object amount for the key and multiplying it with number of quantities and showing improper discount values on line items and proper in the order subtotal.

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

voski avatar image voski commented ·

Hello,

Can you please help me understand how to reproduce this? I am interested in how you are adding the discounts.

How are you detecting that you need to add the discount? Is there some broadcast you are listening for?

What is the code that is adding the actual discounts it would help to see that.

Best, Narbe

0 Likes 0 ·

1 Answer

Jai avatar image
Jai answered

Hi Narbe,

Please refer to the following snippet, In the above snippet , Assume that order is created using clover order connector and order has 2 line items in it. lineItem1 and lineItem2 has same price lets say 10000 cents. Now we are applying two different discounts for line items with the same name i.e. "Test Discount".

Discount discount = new Discount();
Reference reference = new Reference();
reference.setId("test.discount");
discount.setDiscount(reference);
discount.setAmount(1000 * -1);
discount.setName("Test Discount");
  connector.addLineItemDiscount2(orderID, lineItemID1, discount);

Discount discount = new Discount();
Reference reference = new Reference();
reference.setId("test.discount");
discount.setDiscount(reference);
discount.setAmount(5000 * -1);
discount.setName("Test Discount");
 connector.addLineItemDiscount2(orderID, lineItemID2, discount);

As per our code in clover order summary , clover should show one line item with qty 2 with price 20000 cents. Applied discounts are 1000 cents for lineItem1 and 5000 cents for lineItem2 so discount should be 6000 cents. However clover shows 10000 cents discount in line items section but from order 6000 cents are getting deducted. As per our analysis clover groups discounts by its name, gets the amount and multiplies it with all the other discounts having same name.

Thanks, Jai

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community