In PrestaShop how to create a coupon/voucher via the API?

This situation: when you buy in the store But, you need to create a coupon in store B.
Store B is prestashop. Is it possible to create a coupon via the API?
The gugleniya fails, very little information at all about coupons and vouchers.
June 14th 19 at 18:07
1 answer
June 14th 19 at 18:09
As an example:
$cart_rule = new CartRule();
 $cart_rule->code = $discountCode;
 foreach (Language::getLanguages(false) as $language)
 $cart_rule->name[$language['id_lang']] = Configuration::get('COUPON_DESC');
 $cart_rule->id_customer = (int)$customer->id;
 $cart_rule->free_shipping = false;
 $cart_rule->quantity = 1;
 $cart_rule->quantity_per_user = 1;
 $cart_rule->reduction_currency = (int)$this->context->cart->id_currency;
 $cart_rule->reduction_percent = Configuration::get('COUPON_DISCOUNT');
 $cart_rule->date_from = date('Y-m-d H:i:s', time());
 $cart_rule->date_to = date('Y-m-d H:i:s', time() + (3600 * 24 * Configuration::get('COUPON_DAY')));
 $cart_rule->active = 1;

 if ($cart_rule->add())
 Mail::Send(Configuration::get('PS_LANG_DEFAULT'), 'coupon', 'Get discount coupon', array('{shop_name}' => Configuration::get('PS_SHOP_NAME'), '{firstname}' => $customer->firstname, '{lastname}' => ", '{email}' => $customer->email, '{classname}' => $discountCode), $customer->email, NULL, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/');
Thank you! How to create a new path in the API, or something in this spirit? - beaulah.Gaylord commented on June 14th 19 at 18:12

Find more questions by tags Prestashop