jawheele avatar image
jawheele asked ·

Best Way To Detect A Change To An Order


In order to safeguard against applying coupons erroneously, I'd like to be able to check whenever an order is changed (in particular, when a lineitem is removed or its quantity decreased). As it stands, my application interacts with the transaction in the payment activity to identify coupons applicable to the customer's cart and add the appropriate discounts, but I need to remove the discounts if any items are removed. I know the Register activity broadcasts the ACTIVEREGISTERORDER, and this is sufficient to safeguard in the event that all order modifications are made through the Register activity, but couldn't other applications potentially modify the order without going through the Register activity?

My question is: does another application's modifying the order broadcast the ACTIVEREGISTERORDER Intent? If not, what is the best way to detect a removal of items from an order? Is there an unlisted counterpart to the LINEITEMADDED Intent broadcast by clover?

1 comment
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.

Jawheele, You can use ACTIVE_REGISTER_ORDER or other intents provided by Clover to detect a change in an Order. There is a drawback with this approach, Clover doesn't broadcast any event when it get synced via an API transaction (like online order). If any order or item gets changed from the outside like using REST api call Clover won't broadcast any such event. My suggestion would be to register Content Observer for Order URI and track the order in the OnChange event.

Hope this helps.

0 Likes 0 · ·

0 Answers

Welcome to the
Clover Developer Community