Ejemplo n.º 1
0
            $basket->hideCoupon = isset($_POST["hide_coupon"]) && $_POST["hide_coupon"] == "Y" ? "Y" : "N";
            $basket->usePrepayment = isset($_POST["use_prepayment"]) && $_POST["use_prepayment"] == "Y" ? "Y" : "N";
            $res = $basket->recalculateBasket($_POST);
            foreach ($res as $key => $value) {
                $arRes[$key] = $value;
            }
            $arRes["BASKET_DATA"] = $basket->getBasketItems();
            $arRes["BASKET_DATA"]["GRID"]["HEADERS"] = $basket->getCustomColumns();
            $arRes["COLUMNS"] = $strColumns;
            $arRes["CODE"] = "SUCCESS";
            if (!empty($_POST["coupon"]) && $arRes['VALID_COUPON'] === true) {
                if (!empty($arRes['BASKET_DATA']['FULL_DISCOUNT_LIST'])) {
                    global $USER;
                    $userId = $USER instanceof CAllUser ? $USER->getId() : null;
                    $giftManager = \Bitrix\Sale\Discount\Gift\Manager::getInstance()->setUserId($userId);
                    \Bitrix\Sale\Compatible\DiscountCompatibility::stopUsageCompatible();
                    $collections = $giftManager->getCollectionsByBasket(\Bitrix\Sale\Basket::loadItemsForFUser(\Bitrix\Sale\Fuser::getId(), SITE_ID), $arRes['BASKET_DATA']['FULL_DISCOUNT_LIST'], $arRes['BASKET_DATA']['APPLIED_DISCOUNT_LIST']);
                    \Bitrix\Sale\Compatible\DiscountCompatibility::revertUsageCompatible();
                    if (count($collections)) {
                        $arRes['BASKET_DATA']['NEED_TO_RELOAD_FOR_GETTING_GIFTS'] = true;
                    }
                }
            }
        }
    }
}
unset($arRes['BASKET_DATA']['APPLIED_DISCOUNT_LIST'], $arRes['BASKET_DATA']['FULL_DISCOUNT_LIST']);
$arRes["PARAMS"]["QUANTITY_FLOAT"] = isset($_POST["quantity_float"]) && $_POST["quantity_float"] == "Y" ? "Y" : "N";
$APPLICATION->RestartBuffer();
header('Content-Type: application/json; charset=' . LANG_CHARSET);
echo CUtil::PhpToJSObject($arRes);