Add product coupon
Last updated: 12-Apr-2017
Rate this article:
Overview
Apply discount coupons to products added to the shopping cart.
Requirements
Parameters
Parameter | Type/Description |
---|---|
sessionID | Required (String) |
Session identifier, which is the output of the Login method. An exception is thrown if the values are incorrect. | |
coupon | Required (String) |
The coupon/voucher code for a promotion impacting a product added to cart. |
Response
Parameter | Type/Description |
---|---|
Result | Boolean |
True or false |
Request
<?php
require ('PATH_TO_AUTH'); // Authentication example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/02Authentication
require ('PATH_TO_SET_PARTNER'); // setPartner example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/06Reference/Partner/00Set_partner
require ('PATH_TO_ADD_PRODUCT'); // addProduct example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/06Reference/08Place_an_order/00Add_product_to_cart
$couponCode = 'YOUR_COUPON_CODE';
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'setCoupon',
'params' => array($sessionID,$couponCode)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));
Errors
Error | Description |
---|---|
EMPTY_CART |
The shopping cart is empty. |
INVALID_COUPON_CODE |
The coupon code is empty or invalid. |
Rate this article: