khyati11 avatar image
khyati11 asked prakash commented

Broadcast for decrease product quantity/ remove line item

Is there any intent or broadcast that can be used to find out when decrease quantity button is pressed on the register app?

I just want to know when the new line item is added to Clover register it notifies my app through broadcast action(com.clover.intent.action.LINE_ITEM_ADDED") when I trigger plus icon in a register to increment the quantity of line Item it again triggers the same action which is ok,

So the main point of my question is when user will trigger the subtract icon for decrement of line items quantity it will not notify me, I don't know which action I use or which technique I use to get decremented line item detail.

10 |2000

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

Jeffrey Blattman avatar image
Jeffrey Blattman answered chathuranga-shan-j commented

There is not a way to know when a line item has been removed from an order. It does seem like an oversight.

You could consider listening for some other broadcast like ACTION_PAYMENT_PROCESSED to take action on the order. I.e., do you really need to know when anything happens to the order? Or can you just examine the completed order at some later point? As a side issue, having to wake up your app every time a line item changes is not great performance-wise.

Without knowing what is your app / how it works it's hard to suggest anything though.

10 |2000

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

khyati11 avatar image khyati11 commented ·

Our app's requirement is to calculate discount dynamically as an when any item is added/updated or removed from order.
We really need to know when ever any updates are there in the order. As we are getting "com.clover.intent.action.LINE_ITEM_ADDED" action in the same way do we get any other action for update/removed of the line item.

Any suggestion will be much appreciated.

0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ khyati11 commented ·

Why does it need to do it after every change. Could it do it at a later point?

This is not a "line item removed" broadcast. You can look into register an OnOrderUpdateListener2 (see SDK docs), and using a foreground service to keep your process running. Android doesn't guarantee it will keep running but it should unless the device is under extreme memory pressure. The irony is that keeping your app in memory raises the chance that will be under extreme memory pressure.

0 Likes 0 ·
chathuranga-shan-j avatar image chathuranga-shan-j Jeffrey Blattman ♦♦ commented ·

Hi, we are facing similar challenge in our application implementation. We have a custom tender app to apply offers. The "Register" application operator can add a discount using our app and as you have mentioned in the answer we are using ACTION_PAYMENT_PROCESSED to finalize the process. But in our case we have some discount that are eligible base on the product in the order. There can be a situation someone apply such discount and without paying stayaway go back and delete the product from the order that made that offer eligible and comes back. At this point I need to remove previously added offer from the order.

So is there a way to validate the order before payment submission. Something like show loading animation in the "Register" application and and do a network call to our server side and check the eligibility of applied discount and remove it if it doesn't meet our requirements.

0 Likes 0 ·
drawtugofwar avatar image
drawtugofwar answered prakash commented

To act on the order, you can think about keeping an eye out for another broadcast like action payment processed. Do you really need to know when anything changes the order, for example? Or is it possible to simply review the completed order later? A side issue is that it is not very performance-friendly to have to wake up your app each time a line item changes.

drift hunters 2

10 |2000

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

chathuranga-shan-j avatar image chathuranga-shan-j commented ·

The Scenario as follows,

1. An item discount is added to an order item provided user has qualifying items in the basket.

2. Prior to the payment user decides to remove the qualifying item making the discount ineligible.

3. At this time we need to remove the applied discount.

Reviewing later is not option as , then payment amount will be incorrect as discount application will fail since qualifying items are not in the basket.

Is there anyway to handle this kind of scenario ? (A line item change broadcast would be nice.)

Or a boardcast just get triggered prior to the payment, where we can perform our own validation and let user to proceed with the payment if all checks are successful. Validation will happen over a network call so we need option to show a loading animation or something in register app to block POS operator from operating app till the network call is completed.

Let us know your input.

0 Likes 0 ·
prakash avatar image prakash chathuranga-shan-j commented ·

We have added this feature. Hopefully, soon the documentation will be published.

0 Likes 0 ·

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