/coupon/generateCouponProduct
Used to generate a one time usage coupon for a client.
Parameter | Type | Description | Required |
---|---|---|---|
api_token | string | API Token | YES |
string | Customer Email | YES | |
days_expire | integer | Number of days coupon should be valid for | YES |
discount_type | string | valid values are either '$' or '%' | YES |
discount_amount | decimal | discount amount. Enter the dollar value to discount or the percentage. For example if you want to give 10% off enter 10 as the value | YES |
sku | string | SKU of the product that you wish to generate a coupon for | YES |
website_id | integer | ID of the website generating the coupon | YES |
Example PHP Code using the Codebookie Class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
require "codeBookie.php"; $codeBookie = new CodeBookie(); //the email address the coupon will be generated for $email = "test@test.com"; //coupon will expire in 3 days $daysExpire = 3; //discount type is either $ or % $discountType = '%'; //we want the discount type to be 10% off original price $discountAmount = '10'; //sku of the product $sku = 'PRODUCTCODE1'; //website ID of your site you want the coupon generated for $websiteID = 1; $result = $codeBookie->createLimitedOneTimeCouponForProduct($email,$daysExpire,$discountType,$discountAmount,$sku,$websiteID); //coupon generated successfully if ($result['status'] == "OK"): $coupon = $result['coupon_code']; //anthing else is an error else: $errorMessage = $result['message']; endif; |
Output:
Variable | Type | Description |
---|---|---|
status | string | OK or Error |
message | string | Command Message |
coupon_code | string | the newly generated coupon code |