@@ -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