2Checkout Documentation

Update Coupon

The update_coupon call is used to update a coupon.



Input Parameters

Parameter Description
coupon_code The string value of the existing coupon code. Required.
new_code String value of new coupon code. Optional.
date_expire New expiration date of coupon. (YYYY-MM-DD) Optional.
type Denotes if coupon applies to shipping, sale or product. Required.
percentage_off Percentage, if supplied, to discount from purchase price. (value_off must be NULL, if percentage_off used) Optional.
value_off Decimal value of amount to discount. (percentage_off must be NULL, if value_off used) Optional.
minimum_purchase Decimal value indicating minimum purchase required before discount applies. Required if percentage_off or value_off are specified.
product_id Can accept multiple product_ids in querystring. (i.e. product_id=1112223333&product_id=2223334444) Required for product coupons if select_all is not specified.
select_all Set to 1 to enable. Set to 0 to remove all product assignments. Required for product coupons if product_id is not specified.

Data Returned

Parameter Description
response_code Tells the user whether or not the operation was successful.
response_message Tells the user why the operation was or was not successful.

Example API Call


$args = array(
    'coupon_code' => 'ABCD123',
    'new_code' => '123ABCD',
    'type' => 'sale'

$result = Twocheckout_Coupon::update($args);
Twocheckout::API.credentials = { :username => 'APIuser1817037', :password => 'APIpass1817037' }

coupon = Twocheckout::Coupon.find(:coupon_code => '7EBHKS2')
coupon = coupon.update(:date_expire => '2020-01-01')
args = {
    coupon_code: "APIMODIFY002",
    value_off: "0.02",
    minimum_purchase: "0.03"
};, function (error, data) {
    if (error) {
    } else {
find_params = {
    'coupon_code': 'PYTEST12'

coupon = twocheckout.Coupon.find(find_params)

update_params = {
    'date_expire': '2020-01-01'

coupon = coupon.update(update_params)
var ServiceObject = new CouponService();
var ArgsObject = new CouponCreateServiceOptions();
ArgsObject.coupon_code = time;
ArgsObject.date_expire = "2099-12-22";
ArgsObject.type = "shipping";

var result = ServiceObject.Create(ArgsObject);
Coupon coupon = TwocheckoutCoupon.retrieve(coupon_code);
TwocheckoutResponse result = coupon.update();
curl -X POST \
    -H 'Accept: application/json' -u 'username:password' \
    -d 'coupon_code=APIMODIFY002' -d 'date_expire=2099-12-22' -d 'type=sale'

Example Successful Response

       "coupon_code" : "APIMODIFY002",
       "response_code" : "OK",
       "response_message" : "Coupon updated successfully"


Common Error Codes

Code Description
PARAMETER_MISSING Required parameter missing:
PARAMETER_INVALID Invalid value for parameter:
RECORD_NOT_FOUND Unable to find record.