A
A
andreysiteprotect2019-02-27 16:15:14
1C-Bitrix
andreysiteprotect, 2019-02-27 16:15:14

Is it possible to set a price for a product offered as a gift through the rules for working with the basket?

I registered a rule for working with a basket - to provide a gift when entering a coupon.
There was a task - to add to the basket with the price not 0, but 1 rub.
Registered the handler in init.php

AddEventHandler("sale", "OnBeforeBasketAdd", "CorrectSumm");
function CorrectSumm(&$arFields){

  if($arFields['PRICE'] == 0)
    $arFields['PRICE'] = 1;
}

I print the $arFields array through AddMessage2Log, the PRICE value in it is equal to 1, the product gets into the basket with a cost of 0 rubles.
Are there any ways to solve such a problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2019-03-01
@gromdron

Are there any ways to solve such a problem?

Yes, you can not provide a "gift", but set a price for 1 item. Of course, you will not have a block with gifts, but you will definitely solve the problem.
There is another way to solve it - set a fixed price for a gift on the order saving event.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question