Search Results for

    Show / Hide Table of Contents

    Class CouponService

    Inheritance
    System.Object
    CouponService
    Implements
    ICouponService
    Namespace: DirectScale.Disco.Extension.Services
    Assembly: DirectScale.Disco.Extension.Abstractions.dll
    Syntax
    public class CouponService : Object, ICouponService

    Constructors

    CouponService(IApiService)

    Declaration
    public CouponService(IApiService apiService)
    Parameters
    Type Name Description
    IApiService apiService

    Methods

    CalculateCoupon(OrderTotal[], String, String)

    Checks to see if a specific couponCode is currently applied in totals, and for how much.

    Declaration
    public 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 currencyCode) that this coupon has discounted. 0 if the coupon has not been applied.

    DeleteCoupon(Int32)

    Delete an existing coupon.

    Declaration
    public 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
    CouponId

    FindCoupons(DateTime, DateTime, String)

    Searches for active coupons withing a time frame, optional search.

    Declaration
    public 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
    GetCoupons(String)

    GetAssociateCouponUsage(Int32)

    Gets all coupons the associate has ever used in their orders.

    Declaration
    public 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
    public 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. doesn't allow for duplicate codes.

    See Also
    Code

    GetOrderCouponUsage(Int32)

    Finds which coupons were applied to a specific order.

    Declaration
    public 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
    public 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 ), then filters them down and returns only the ones that are: Still within valid dates, availabe in the associate's region, and have not been used before (or are allowed multiple uses).

    See Also
    GetValidCartAssociateCoupons(Int32, Int32, LineItem[])
    BeginDate
    EndDate
    Recurring
    BackOfficeIds
    RegionIds

    GetValidCartAssociateCoupons(Int32, Int32, LineItem[])

    Similar to GetValidAssociateCoupons(Int32) but it will remove coupons that require specific items that are not in the cart.

    Declaration
    public 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
    AllItemIdsRequired
    AppliedItemIds

    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
    public 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
    AllItemIdsRequired
    AppliedItemIds

    IsCouponUsed(Int32, Int32)

    Indicates if an associate has ever used this coupon id before.

    Declaration
    public 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
    public 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 couponInfo, RegionIds, BackOfficeIds, or AppliedItemIds is null.

    System.ArgumentException

    If Code is not unique.

    System.ArgumentException

    If BeginDate or EndDate is invalid.

    Implements

    ICouponService
    In This Article
    Back to top Copyright © 2022 DirectScale
    Generated by DocFX