Answer the question
In order to leave comments, you need to log in
How to get a list of coupons in Bitrix?
There is a list of coupons.
I can change them, by code or by ID
use Bitrix\Sale\Internals;
if (CModule::IncludeModule("catalog") && CModule::IncludeModule("sale")) {
// $fields["DISCOUNT_ID"] = 8;
$fields["COUPON"] = 'asd';
// $fields["ACTIVE"] = "Y";
// $fields["TYPE"] = 2;
// $fields["MAX_USE"] = 0;
$fields['DESCRIPTION'] = '111';
$id = 4090104;
$dd = \Bitrix\Sale\Internals\DiscountCouponTable::update($id, $fields); //Создаем купон для этого правила
if (!$dd->isSuccess()) {
$err = $dd->getErrorMessages();
} else {
echo 'Купон на скидку';
}
}
use \Bitrix\Main,
\Bitrix\Sale\Internals;
try
{
/* @var string Номер купона */
$code = 'asd';
if ( !Main\Loader::IncludeModule('sale') )
{
throw new \Exception("Module 'sale' not installed");
}
$arCoupon = Internals\DiscountCouponTable::getRow([
'filter' => [
//'>ID' => 4090098,
//'<ID' => 4090106,
'COUPON' => 'asd',
]
]);
if ( !empty($arCoupon) )
{
echo "<pre style='display: block !important;'>";
print_r($arCoupon);
echo "</pre>";
}
else
{
throw new \Exception("Coupon [CODE:{$code}] not found");
}
}
catch( \Exception $e)
{
var_dump($e->getMessage() );
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question