question

ojhatushar avatar image
ojhatushar asked Jeffrey Blattman edited

How to get only New line item added from register app

We have make an app using clover sdk. I am applying discount through my app on a line item from background service.I always want to get only new line item which are added from register app and not all of the them which are already discounted means when applying discount I do not want to traverse each and every line item which are already discounted.I want to get only that line item which are not discounted.
LineItemsDiscounts
2 comments
10 |2000

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

zgreathouse avatar image zgreathouse commented ·

I am not sure I understand the question.
Are you asking how to get the most recently added line item of an order or how to get all the line items which do not have lineItem discounts already applied to them?

0 Likes 0 ·
ojhatushar avatar image ojhatushar zgreathouse commented ·

Hi
We have make an app using clover sdk in which we are applying discount. I am adding Item from register app but every time we are getting list of all the line items added in order through clover by looping below function whether it is discounted or not.

orderConnector.getOrder(orderID).getLineItems()

So I want only that line item which is recently added,because we have a background service in that app that is updating the order and putting discount when some criteria gets fulfilled on register app. So if any method is there by which we get only that particular line item which is not discounted or recently added or anything by which we apply discount on that newly added line item ignoring others line item.

0 Likes 0 ·

1 Answer

Jeffrey Blattman avatar image
Jeffrey Blattman answered Jeffrey Blattman edited
You can inspect the time stamp on the line items. You'll need to track a "last time I checked the line items" yourself and compare the LineItem.createdTime field.

You could also track a list of UUIDs you've "seen", and only consider those you have not.

There's no way from the SDK to directly ask "give me the line items added since this time".
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