M
M
Mikhail Lepeshkin2021-06-14 17:04:23
1C-Bitrix
Mikhail Lepeshkin, 2021-06-14 17:04:23

How to change the date of the coupon of the rules for working with the basket in Bitrix?

It is necessary to make changes to the date of the existing coupon of the rules for working with the basket, there are all coupon parameters (id, code, etc.).
Tried like this:

$PERIOD   = '190 day';
          $activeTo = new Bitrix\Main\Type\DateTime();
          $activeTo = $activeTo->add($PERIOD);
          $fields   = [
            'ACTIVE_TO' => $activeTo,
          ];

          CCatalogDiscountCoupon::CheckFields('UPDATE', $fields, $cupon["ID"]);
          CCatalogDiscountCoupon::Update($cupon["ID"], $fields);

The methods work return true and the coupon id, but nothing changes in the admin panel, I read that for coupons of the cart rules, you need to use the ORM class \Bitrix\Sale\Internals\DiscountCouponTable, but I can’t find there any method for changing the coupon (only events on update ).

Friends help, if you can give the code

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2021-06-15
@ursusuma

\Bitrix\Sale\Internals\DiscountCouponTable::update($id, $fields);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question