简体   繁体   中英

Create a Coupon In BigCommerce Using API

I am trying to create a coupon in big commerce using their API. I am using the following code after connecting with the store.

$coupon = array('name' => 'somecoupon', 'type' => 'percentage_discount', 'amount' => '50.0', 'code' => '50off', 'enabled' => true);
echo Bigcommerce::createCoupon($coupon);

I simply copied the code from their Support Page

All the other codes on that page work but create coupon doesnt work. If I use get coupons codes, they work perfectly but creating coupon is not working what so ever. Any ideas on this?

Any help would be highly appreciated. Thanks

The developer page neglects to mention that 'applies_to' is also a required field, hence why your code is failing.

Try

$coupon = array('name' => 'somecoupon', 'type' => 'percentage_discount', 'amount' => '50.0', 'code' => '50off', 'enabled' => true, 'applies_to'=> array('entity'  => 'categories', 'ids' => array('value' => 0)));
echo Bigcommerce::createCoupon($coupon);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM