-
Notifications
You must be signed in to change notification settings - Fork 117
[Woo POS] Coupons: Disallow adding duplicate coupons to cart #15551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
11913c3
b3a53cb
60de14f
72e42f7
6868fe0
ff28aea
936f2b5
3bfe659
68096bc
3c28116
a7c5977
d004acc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,28 @@ final class StandardPOSItemActionHandler: POSItemActionHandler { | |
} | ||
} | ||
|
||
@available(iOS 17.0, *) | ||
final class CouponsItemActionHandler: POSItemActionHandler { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer needed, can be removed 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I didn't see that we stopped using
I've added a small helper function to handle this case in I'll leave this one without merging for now in case you want to take a look, in a nutshell when adding coupons from either list or search, the track event should be logged just once. |
||
private let posModel: PointOfSaleAggregateModelProtocol | ||
private let analytics: Analytics | ||
private let itemListType: ItemListType | ||
|
||
init(posModel: PointOfSaleAggregateModelProtocol, itemListType: ItemListType, analytics: Analytics = ServiceLocator.analytics) { | ||
self.posModel = posModel | ||
self.itemListType = itemListType | ||
self.analytics = analytics | ||
} | ||
|
||
func handleTap(_ item: POSItem) { | ||
let alreadyExists = posModel.cart.coupons.contains(where: { $0.id == item.id }) | ||
if alreadyExists { | ||
return | ||
} | ||
posModel.addToCart(item) | ||
trackTapAnalytics(for: item, itemListType: itemListType, using: analytics) | ||
} | ||
} | ||
|
||
/// Handler for handling taps on search result items, saving the search term | ||
@available(iOS 17.0, *) | ||
final class SearchResultItemActionHandler: POSItemActionHandler { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this check here if we skip the duplicate in the action handler?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't anymore, I've removed this on 68096bc and added initial tests for the action handler on a7c5977