Coupons
Sleekshop provides various endpoints to manage coupons, allowing you to add coupons to a cart dynamically and create new coupons programmatically. Below, we cover how to use these endpoints effectively.
Add Coupons to Cart
This endpoint allows you to add one or more coupons to a cart. If the coupons are valid, they will be attached to the cart and dynamically calculated. During checkout, these coupons will be permanently added to the cart.
Required attributes
- Name
session
- Type
- string
- Description
A valid session code.
- Name
coupons
- Type
- json-array
- Description
A well-formed JSON array containing all the coupons you want to add. The format should be
[[code1, name1], [code2, name2]]
. Thename
field is optional; if not provided, the name of the coupon itself will be used.
- Name
licence_username
- Type
- string
- Description
Your licence username.
- Name
licence_password
- Type
- string
- Description
Your licence password.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='add_coupons' \
-d session=A_VALID_SESSION_CODE \
-d coupons='[["code1","name1"],["code2","name2"]]'
Response
{
"object": "add_coupons",
"status": "SUCCESS"
}
Create Coupons
This endpoint allows you to create new coupons. You can specify the number of coupons, their name, amount, type, and optionally, a custom code for each coupon.
Required attributes
- Name
count
- Type
- int
- Description
The number of coupons you want to create.
- Name
name
- Type
- string
- Description
The name of the new coupons.
- Name
amount
- Type
- float
- Description
The amount or value associated with the coupons.
- Name
type
- Type
- string
- Description
The type of coupon you want to create. Valid values include:
- UNIQUE_NOMINAL
- UNIQUE_PERCENTAGE
- MULTIPLE_NOMINAL
- MULTIPLE_PERCENTAGE
- Name
licence_username
- Type
- string
- Description
Your licence username.
- Name
licence_password
- Type
- string
- Description
Your licence password.
- Name
licence_secret_key
- Type
- string
- Description
Your licence secret key.
Optional attributes
- Name
code
- Type
- string
- Description
A custom code you want to generate for the coupons. If not provided, a generic code will be generated.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d licence_secret_key='your_secret_key' \
-d request='create_coupons' \
-d count=10 \
-d name='name_new' \
-d amount=10 \
-d type='UNIQUE_NOMINAL'
Response
{
"object": "create_coupons",
"coupons": [
{"code": "a8wj-roey-2184-8zmh"},
{"code": "wokg-eq25-t6uj-2w4v"},
{"code": "3zsw-hh42-e4lt-ax8r"},
{"code": "58pn-idsm-i7lr-rx52"},
{"code": "4mc9-8189-vojj-rhhy"},
{"code": "p7no-qvir-qycm-lt03"},
{"code": "cqz4-lopt-6hwb-lvae"},
{"code": "z8t0-tq88-ljiz-6nr6"},
{"code": "c6b4-jp0b-2kp3-75tb"},
{"code": "bkup-eg8w-umzr-ivbk"}
]
}