Discounts/Codes/Methods

Discounts/Codes/Methods

Methods

(static) discounts/addCode(doc) → {String}

Source:
Parameters:
Name Type Description
doc Object

A Discounts document to be inserted

Returns:

Insert result

Type
String

(static) discounts/codes/apply(id, code, collection, tokenopt) → {Boolean}

checks validity of code conditions and then applies a discount as a paymentMethod to cart

Source:
Parameters:
Name Type Attributes Description
id String

cart/order id of which to remove a code

code String

valid discount code

collection String

collection (either Orders or Cart)

token String <optional>

Cart or order token if anonymous

Returns:

returns true if successfully applied

Type
Boolean

(static) discounts/codes/credit(cartId, discountId, collections) → {Number}

calculates a credit off cart for discount codes

Source:
Parameters:
Name Type Description
cartId String

cartId

discountId String

discountId

collections Object

Map of MongoDB collections

Returns:

returns discount total

Type
Number

(static) discounts/codes/discount(cartId, discountId, collections) → {Number}

calculates percentage off discount rates

Source:
Parameters:
Name Type Description
cartId String

cartId

discountId String

discountId

collections Object

Map of MongoDB collections

Returns:

returns discount total

Type
Number

(static) discounts/codes/remove(id, codeId, collection, tokenopt) → {String}

removes discounts that have been previously applied to a cart.

Source:
Parameters:
Name Type Attributes Description
id String

cart id of which to remove a code

codeId String

discount Id from cart.billing

collection String

collection (either Orders or Cart)

token String <optional>

Cart or order token if anonymous

Returns:

returns update/insert result

Type
String

(static) discounts/codes/sale(cartId, discountId, collections) → {Number}

calculates a new price for an item

Source:
Parameters:
Name Type Description
cartId String

cartId

discountId String

discountId

collections Object

Map of MongoDB collections

Returns:

returns discount total

Type
Number

(static) discounts/codes/shipping(cartId, discountId, collections) → {Number}

calculates a discount based on the value of a calculated shipping rate in the cart.

Source:
Parameters:
Name Type Description
cartId String

cartId

discountId String

discountId

collections Object

Map of MongoDB collections

Returns:

returns discount total

Type
Number

(static) discounts/deleteCode(discountId) → {String}

Source:
Parameters:
Name Type Description
discountId String

discount id to delete

Returns:

returns remove result

Type
String

(static) discounts/editCode(details) → {String}

Source:
Parameters:
Name Type Description
details Object

An object with _id and modifier props

Returns:

Update result

Type
String