M
M
mirexdoors2018-10-08 19:43:29
1C-Bitrix
mirexdoors, 2018-10-08 19:43:29

How to recalculate the cart after applying the cart rules coupon?

Hello!
There is a slightly customized sale.order.ajax. Also, in his template, a basket is displayed to the heap. There is also a coupon entry field. The problem is that when using a product discount coupon (via CCatalogDiscountCoupon::SetCoupon() ) everything works fine. But with a coupon, there are no basket rules.
The component has the following code:

$couponsDB = CCatalogDiscountCoupon::GetList(array("ID" => "ASC"), array("COUPON" => $_POST['COUPON'], "ACTIVE" => "Y"));

                if($couponItem = $couponsDB->Fetch()) {
                    CCatalogDiscountCoupon::SetCoupon($couponItem['COUPON']);
                    $arResult['DISCOUNT_COUPON'] = $couponItem['COUPON'];
                } else {
                    CCatalogDiscountCoupon::ClearCoupon();
                }

in $_POST['COUPON'] - the coupon code arrives correctly, but the CCatalogDiscountCoupon::GetList() selection is empty.
Tried to test without fetch:
CCatalogDiscountCoupon::SetCoupon($_POST['COUPON'])

- the method returns 1, then I pass it, but further along the code in the CSaleOrder::DoCalculateOrder method , automatic recalculation still does not occur. When applying the coupon in the admin panel - everything is fine. In general, there is a strong feeling that I'm doing something wrong, but I can't figure out what :) $arResult['DISCOUNT_COUPON'] = $_POST['COUPON'];

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question