Skip to content

Commit 69d7dc8

Browse files
committed
Enhance further coupon creation initiated track parameters for restrictions
1 parent fb7b16e commit 69d7dc8

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

WooCommerce/Classes/ViewRelated/Coupons/Add and Edit Coupons/AddEditCouponViewModel.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,19 @@ private extension AddEditCouponViewModel {
391391
return coupon.discountType != initialCoupon.discountType
392392
}
393393

394+
func checkUsageRestrictionsOnCreation(of coupon: Coupon) -> Bool {
395+
coupon.maximumAmount.isNotEmpty ||
396+
coupon.minimumAmount.isNotEmpty ||
397+
(coupon.usageLimit ?? 0) > 0 ||
398+
(coupon.usageLimitPerUser ?? 0) > 0 ||
399+
(coupon.limitUsageToXItems ?? 0) > 0 ||
400+
coupon.emailRestrictions.isNotEmpty ||
401+
coupon.individualUse ||
402+
coupon.excludeSaleItems ||
403+
coupon.excludedProductIds.isNotEmpty ||
404+
coupon.excludedProductCategories.isNotEmpty
405+
}
406+
394407
func checkUsageRestrictionsUpdated(for coupon: Coupon) -> Bool {
395408
guard let initialCoupon = self.coupon else {
396409
return false
@@ -465,9 +478,7 @@ private extension AddEditCouponViewModel {
465478
"includes_free_shipping": coupon.freeShipping,
466479
"has_description": coupon.description.isNotEmpty,
467480
"has_product_or_category_restrictions": coupon.excludedProductCategories.isNotEmpty || coupon.excludedProductIds.isNotEmpty,
468-
"has_usage_restrictions": (coupon.usageLimit ?? 0) > 0
469-
|| (coupon.limitUsageToXItems ?? 0) > 0
470-
|| (coupon.usageLimitPerUser ?? 0) > 0
481+
"has_usage_restrictions": checkUsageRestrictionsOnCreation(of: coupon)
471482
])
472483
}
473484

0 commit comments

Comments
 (0)