question

bLoyal avatar image
bLoyal asked ·

Discount does not contain the same fields when the register app is closed and then the order is reopened.

I have an app that applies a discount. When I create the order and then click pay, the discount is properly applied and calling lineItem.getdiscounts() returns a list with just one item containing the following:

Discount{json='{"discount":{"id":"com.bloyal.discount"},"amount":-5000,"name":"bLoyal Product Promotion ($50.00)","id":"84MBQD88JT75P"}', bundle=null, changeLog=null}

However, if the register app is closed, then the order is reopened through the orders app, the value of the discount is:

Discount{json='{"id":"84MBQD88JT75P","orderRef":{"id":"AKVPA2DYRRD2Y"},"lineItemRef":{"id":"018WSWG7TYFNP"},"name":"bLoyal Product Promotion ($50.00)","amount":-5000}', bundle=null, changeLog=null}
This is resulting in discount.getDiscount() returning null. Can someone please explain why the value of the discount may have changed?

Thanks,

Ryan
Discounts
10 |2000 characters needed characters left characters exceeded

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

1 Answer

· Write an Answer
Dan avatar image
Dan answered ·
There are (at least) three types of discounts.
Inventory discounts - A discount the merchant sets up and can be applied to orders and line items
Order discounts - a discount applied to an entire order, either custom or based on an inventory discount
LineItem discounts - a discount applied to a specific line item, either custom or based on an inventory discount
When creating a lineitem discount, you can provide the inventory discount's uuid, and then the lineitem discount will be associated with the inventory discount (I think this is used with reporting). If the uuid provided is not valid for an inventory discount, it is silently ignored.
In your case,
Discount{json='{"discount":{"id":"com.bloyal.discount"},
'com.bloyal.discount' is not the uuid of an inventory discount in the server database, so the server is ignoring it.

Share
10 |2000 characters needed characters left characters exceeded

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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