coupon

0.4.0 • Public • Published

Coupon

NPM

Coupon — discount coupons generator. Coupon is designed to be the simplest way possible to create a discount coupons for e-commerce purposes.

Installation

npm install coupon

Usage:

var coupon = require("coupon");
var myCoupon = coupon("GREAT-30")
    .give("30%")
    .limit(10)
    .person("Mr. Fetus")
    .only("Banana")
    .expire(new Date(2015, 0, 1));
console.log(myCoupon.json());

Examples:

5% discount coupon for anyone

var coupon = require("coupon");
var myCoupon = coupon("HELLO-5").give("5%");
console.log(myCoupon.json());
{
    id: 'W0YEPW913C8M279D0ECV2P5P0C11QAV1',
    name: 'HELLO-5',
    discount: 0.05
}

20% one-time discount coupon for John

var coupon = require("coupon");
var myCoupon = coupon("HELLO-JOHN").give("20%").person("John").limit(1);
console.log(myCoupon.json());
{
    id: 'K5PL08XU1GG71T9VW00Y4CEUJFVPMM2F',
    name: 'HELLO-JOHN',
    user: 'John',
    countMax: 1,
    discount: 0.2 
}

API

give()

Specifies amount of discount.

coupon().give(10);

or

coupon().give("10%");

You can pass "free" string

coupon().give("free").only("Delivery");

person()

Specifies user

coupon().give("5%").person("John Smith");

limit()

Specifies how many times you can use coupon

coupon().give("5%");

expire()

Specifies expiration date of coupon

coupon().give("10%").expire(new Date(2015, 5, 15));

only()

Specifies the service

coupon().give("5%").only("Banana");

json()

Generate JSON object

coupon().give("5%");

Test

npm test

License

Licensed under the MIT license

Copyright © 2014 Roman Timashev roman@tmshv.ru (http://roman.tmshv.ru)

Package Sidebar

Install

npm i coupon

Weekly Downloads

4

Version

0.4.0

License

MIT

Last publish

Collaborators

  • tmshv