M
M
mirexdoors2018-09-11 11:17:30
1C-Bitrix
mirexdoors, 2018-09-11 11:17:30

Why might coupons not work at checkout?

Hello1 There is a customized sale.order.ajax with the functionality of discount coupons. The problem is that when applying a coupon and using an Ajax request, the CSaleOrder::DoCalculateOrder() method does not recalculate the order. And the recalculation occurs only when the page is reloaded.
Basically, I do this:

if (isset($_REQUEST['AJAX_CALL']) && $_REQUEST['AJAX_CALL'] == "Y") {
            $arError = array();
            $arWarnings = array();

            
            $arOrderDat = CSaleOrder::DoCalculateOrder(
                SITE_ID,
                $GLOBALS["USER"]->GetID(),
                $arResult['BASKET_ITEMS'],
                $arUserResult['PERSON_TYPE_ID'],
                $arUserResult['ORDER_PROP'],
                $arUserResult['DELIVERY_ID'],
                $arUserResult['PAY_SYSTEM_ID'],
                array(),
                $arError,
                $arWarnings
            );

            if ($arOrderDat) {
                foreach ($arResult['BASKET_ITEMS'] as $id => &$item) {
                     $item = &$arResult['BASKET_ITEMS'][$id];
                    $item['PRICE'] = ($arOrderDat['BASKET_ITEMS'][$id]['PRICE']);
                    $item['DISCOUNT_PRICE'] = ($item['BASE_PRICE'] - $arOrderDat['BASKET_ITEMS'][$id]['PRICE']);

                    $item['PRICE_FORMATED'] = SaleFormatCurrency($item['PRICE'], $arResult["BASE_LANG_CURRENCY"]);
                }

                $arOrderDat['BASKET_ITEMS'] = $arResult['BASKET_ITEMS'];
                $orderPrice = $arResult["ORDER_PRICE"] = $arOrderDat["ORDER_PRICE"];
            }
        }

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