The JSMA vouchers allows access of vouchers (voucher campaigns) used in carts and orders.
What can JSMA vouchers do for me?With the JSMA vouchers you can create and find vouchers for carts and orders on your shopping website. You can use it to dynamically generate voucher campains which, in combination with JSMA voucher, allows you to synchronize IKONA with an external voucher system. |
The JSMA vouchers provides the following methods:
Creates a JSMA voucher campain with the parameters given in the attributes object.
Example
... vouchers.create({'validFrom' : date.getTime(), 'validUntil' : dateInOneWeek.getTime(), 'discountType' : 'absolute', 'affectShipping' : false, 'value' : 500}); ... |
Parameter attributes (required)
The attributes objects can take in the following keys:
string title (optional)
A title for your voucher campain.
int minValue (optional)
Minimal value a voucher can be redeemed for. Must be a positive integer in cents.
int validFrom
Time in milliseconds from when a voucher will be valid from.
int validUntil
Time in milliseconds up to when a voucher will be valid until.
int value
Value of the voucher. Must be a positive integer in cents for absolute vouchers or a percentage for relative vouchers.
Returns a JSMA voucher for given parameter id.
Avoid usage of findByIdIds change whenever a package is reimported. So please avoid using ids whenever possible. Also delivering contents to users by id might make it possible for users to flip through the files (and by that see contents of others possibly) by changing the ids in requests. |
CartApi.prototype.doAddVoucher = function (id) { [...] var voucherCampaign = vouchers.findById(id); if (!voucherCampaign) { throw new Error("ERROR_VOUCHER_FOR_ID_NOT_FOUND"); } [...] } |
Returns a JSMA voucher for given parameter name.
CartApi.prototype.doAddVoucher = function (token) { [...] var voucherCampaign = vouchers.findByName("Gutschein"); voucherCampaign.addToken(voucherCode); [...] } |
Returns a JSMA voucher for given parameter token.
CartApi.prototype.doAddVoucher = function (token) { [...] var voucherCampaign = vouchers.findByToken(token); if (!voucherCampaign) { throw new Error("ERROR_VOUCHER_COULD_NOT_BE_ADDED"); } [...] } |