D
D
dimitriylutsenko2021-03-30 11:05:11
1C-Bitrix
dimitriylutsenko, 2021-03-30 11:05:11

How to display a coupon in the public part of the 1s-Bitrix website?

Good afternoon.

Tell me, please, how can I withdraw a coupon to an authorized buyer on the 1s-Bitrix website, which component needs to be modified for this, where to create the necessary template for this?

Help, please, with this question. It seems like you need to use DiscountCouponsManager but I can't find the right example to solve my question.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Gritsuk, 2021-03-30
@dimitriylutsenko

if you have 1 coupon, then why invent something? Just display the coupon code when the conditions you need are met.
You can generally generate a new coupon for each new user and only then display it. for example like this:

$coupon = DiscountCouponTable::generateCoupon(true);
//$activeFrom = new \Bitrix\Main\Type\DateTime;
//$activeTo = clone $activeFrom;
$addDb = DiscountCouponTable::add(array(
  'DISCOUNT_ID' => $saleDiscountId,//ID скидки
  //'ACTIVE_FROM' => $activeFrom,
  //'ACTIVE_TO' => $activeTo->add('+365 days'),
  'COUPON' => $coupon,
  'TYPE' => \Bitrix\Sale\Internals\DiscountCouponTable::TYPE_ONE_ORDER,
  'MAX_USE' => 1,
  'USER_ID' => $USER->GetID(),
  'DESCRIPTION' => 'описание купона',
));

If there are doubts about the conditions for displaying a coupon on a page, then you can go the other way.
- Register a user
- On the OnAfterUserAdd event, create a coupon and send an email via CEvent::Send. In it, the user will receive both a registration confirmation and a discount coupon.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question