Discounts/Codes/Methods

Discounts/Codes/Methods

Methods

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

Source:
Parameters:
Name Type Attributes Description
doc Object

A Discounts document to be inserted

docId String <optional>

DEPRECATED. Existing ID to trigger an update. Use discounts/editCode method instead.

Returns:

Insert result

Type
String

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

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

Source:
Parameters:
Name Type Description
id String

cart/order id of which to remove a code

code String

valid discount code

collection String

collection (either Orders or Cart)

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) → {String}

removes discounts that have been previously applied to a cart.

Source:
Parameters:
Name Type 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)

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/editCode(details) → {String}

Source:
Parameters:
Name Type Description
details Object

An object with _id and modifier props

Returns:

Update result

Type
String