Coupons


Overview

The coupons API allows you to create, view, update, and delete individual, or a batch, of coupon codes.


Create a coupon

This API helps you to create a new coupon.

createCoupon({})

Parameters

@required String code,
@required String discountType,
@required String amount,
@required bool individualUse,
@required bool excludeSaleItems,
@required String minimumAmount,

API Call

// CONFIG FOR WOOSIGNAL
var wsConfig = {
"appKey":"your app key",
"debugMode":true
};

// CREATING AN INSTANCE
WooSignal.getInstance(config: wsConfig).then( (wcStore) {

    wcStore.createCoupon({
      code,
      discountType,
      amount,
      individualUse,
      excludeSaleItems,
      minimumAmount,
      }).then( (coupon) {
        print(coupon.toJson());
    });

});

Response

Coupon instance

Represents the following object - WooCommerce Coupon


Retrieve a coupon

This API lets you retrieve and view a specific coupon by ID.

retrieveCoupons({int id})

Parameters

int id

API Call

// CONFIG FOR WOOSIGNAL
var wsConfig = {
"appKey":"your app key",
"debugMode":true
};

// CREATING AN INSTANCE
WooSignal.getInstance(config: wsConfig).then( (wcStore) {

    wcStore.retrieveCoupons({int id}).then( (coupon) {
        print(coupon.toJson());
    });

});

Response

Coupon instance

Represents the following object - WooCommerce Coupon


List all coupons

This API helps you to list all the coupons that have been created.

getCoupons({})

Parameters

String context
int page
int perPage
String search
String after
String before
List<int> exclude
List<int> include
String order
String orderby
String code

API Call

// CONFIG FOR WOOSIGNAL
var wsConfig = {
"appKey":"your app key",
"debugMode":true
};

// CREATING AN INSTANCE
WooSignal.getInstance(config: wsConfig).then( (wcStore) {

    wcStore.getCoupons({}).then( (coupons) {
        print(coupons.toString());
    });

});

Response

List<Coupon> instance

Represents the following object - WooCommerce Coupon List


Update a coupon

This API lets you make changes to a coupon.

updateCoupon(int id, {Map data})

Parameters

int id, 
{Map<String, dynamic> data}

API Call

// CONFIG FOR WOOSIGNAL
var wsConfig = {
"appKey":"your app key",
"debugMode":true
};

// CREATING AN INSTANCE
WooSignal.getInstance(config: wsConfig).then( (wcStore) {

    wcStore.updateCoupon(int id, {Map<String, dynamic> data}).then( (coupon) {
        print(coupon.toJson());
    });

});

Response

List<Coupon> instance

Represents the following object - WooCommerce Coupon


Delete a coupon

This API helps you delete a coupon.

deleteCoupon(int id)

Parameters

int id

API Call

// CONFIG FOR WOOSIGNAL
var wsConfig = {
"appKey":"your app key",
"debugMode":true
};

// CREATING AN INSTANCE
WooSignal.getInstance(config: wsConfig).then( (wcStore) {
    wcStore.deleteCoupon(int id).then( (coupon) {
        print(coupon.toJson());
    });
});

Response

List<Coupon> instance

Represents the following object - WooCommerce Coupon


Batch update coupons

This API helps you to batch create, update and delete multiple coupons.

batchCoupon({Map data})

Parameters

Map<String, dynamic> data

API Call

// CONFIG FOR WOOSIGNAL
var wsConfig = {
"appKey":"your app key",
"debugMode":true
};

// CREATING AN INSTANCE
WooSignal.getInstance(config: wsConfig).then( (wcStore) {
    wcStore.batchCoupon(data: {}).then( (couponBatch) {
        print(couponBatch.toJson());
    });
});

Response

List<CouponBatch> instance

Represents the following object - WooCommerce CouponBatch