Interface ICouponService
Manages available coupons able to discount orders or items.
Namespace: DirectScale.Disco.Extension.Services
Assembly: DirectScale.Disco.Extension.Abstractions.dll
Syntax
public interface ICouponService
Methods
CalculateCoupon(OrderTotal[], String, String)
Checks to see if a specific couponCode
is currently applied in totals
, and for how much.
Declaration
Task<double> CalculateCoupon(OrderTotal[] totals, string currencyCode, string couponCode)
Parameters
Type | Name | Description |
---|---|---|
OrderTotal[] | totals | The order totals for an order that has not yet been completed. |
System.String | currencyCode | Only the total found with this currency will be checked. |
System.String | couponCode | The coupon to check. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Double> | The amount (in |
DeleteCoupon(Int32)
Delete an existing coupon.
Declaration
Task DeleteCoupon(int couponId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | couponId | The coupon's DB Id. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
See Also
FindCoupons(DateTime, DateTime, String)
Searches for active coupons withing a time frame, optional search.
Declaration
Task<Coupon[]> FindCoupons(DateTime beginDate, DateTime endDate, string search)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | beginDate | Begin date to look for active coupons. |
System.DateTime | endDate | End date to look for active coupons. |
System.String | search | Optional. Filter only coupons who's coupon code contains this search term. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Coupon[]> | Array of coupons in time range with search term. |
Remarks
This will return all possible coupons that could have been used during this date range. So, if the range is one month, and a coupon was only available for a single day at the end or beginning, it will still be included as one of the coupons active during this time.
See Also
GetAssociateCouponUsage(Int32)
Gets all coupons the associate has ever used in their orders.
Declaration
Task<OrderCoupon[]> GetAssociateCouponUsage(int associateId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | Associate to check. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<OrderCoupon[]> | Array of OrderCoupons. |
GetCoupons(String)
Get the coupons matching the coupon code.
Declaration
Task<Coupon[]> GetCoupons(string couponCode)
Parameters
Type | Name | Description |
---|---|---|
System.String | couponCode | The coupon code. Case-insensitive. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Coupon[]> | Array of coupons that match that code. |
Remarks
All matching coupons are returned, even expired, etc.
Normally only one coupon should be returned.
See Also
GetOrderCouponUsage(Int32)
Finds which coupons were applied to a specific order.
Declaration
Task<OrderCoupon[]> GetOrderCouponUsage(int orderId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | orderId | The order to get coupons used on. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<OrderCoupon[]> |
GetValidAssociateCoupons(Int32)
Gets all coupons currently available for this associate to use.
Declaration
Task<Coupon[]> GetValidAssociateCoupons(int associateId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | The associate looking for coupons. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Coupon[]> | Array of Coupons. |
Remarks
This finds all public coupons and coupons specifically assigned to this associate (see
See Also
GetValidCartAssociateCoupons(Int32, Int32, LineItem[])
Similar to GetValidAssociateCoupons(Int32) but it will remove coupons that require specific items that are not in the cart.
Declaration
Task<Coupon[]> GetValidCartAssociateCoupons(int associateId, int regionId, LineItem[] cartLineItems)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | The associate who is placing an order. |
System.Int32 | regionId | The associate's region. |
LineItem[] | cartLineItems | The items currently in the associate's cart. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Coupon[]> | Array of Coupons. |
Remarks
Coupons with AllItemIdsRequired set to false will never be removed.
See Also
GetValidCartAssociateCouponsWithPriceGroup(Int32, Int32, Int32, LineItem[])
Similar to GetValidCartAssociateCoupons(Int32, Int32, LineItem[]) but this call includes a Price Group, which will filter out coupons that don't match the provided Price Group ID. So, the item list passed in must be in the coupon item list, and the coupon must be marked available for the particular provided price group (or Associate Type).
Declaration
Task<Coupon[]> GetValidCartAssociateCouponsWithPriceGroup(int associateId, int regionId, int priceGroupId, LineItem[] cartLineItems)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | The associate who is placing an order. |
System.Int32 | regionId | The associate's region. |
System.Int32 | priceGroupId | The price group ID (associate type) of the associate. |
LineItem[] | cartLineItems | The items currently in the associate's cart. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Coupon[]> | Array of Coupons. |
Remarks
Coupons with AllItemIdsRequired set to false will never be removed.
See Also
IsCouponUsed(Int32, Int32)
Indicates if an associate has ever used this coupon id before.
Declaration
Task<bool> IsCouponUsed(int couponId, int associateId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | couponId | The coupon's DB id. |
System.Int32 | associateId | The associate. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> |
SaveCoupon(Coupon)
Validate coupon info, then create or update DB record. To update a coupon set CouponId.
Declaration
Task<SaveCouponResponse> SaveCoupon(Coupon couponInfo)
Parameters
Type | Name | Description |
---|---|---|
Coupon | couponInfo | The coupon to create or update. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<SaveCouponResponse> | Id of coupon and a list of backoffice ids found in BackOfficeIds, but not found in the DB. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If |
System.ArgumentException | If Code is not unique. |
System.ArgumentException |