Beispiel #1
0
                 $arErrors[] = GetMessage('SBB_PRODUCT_PRICE_NOT_FOUND');
             }
         }
         if ($bBasketUpdate === true) {
             CBitrixComponent::includeComponentClass("bitrix:sale.basket.basket");
             $basket = new CBitrixBasketComponent();
             $basket->weightKoef = htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_koef', 1, SITE_ID));
             $basket->weightUnit = htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_unit', "", SITE_ID));
             $basket->columns = $arColumns;
             $basket->offersProps = $strOffersProps;
             $basket->quantityFloat = isset($_POST["quantity_float"]) && $_POST["quantity_float"] == "Y" ? "Y" : "N";
             $basket->countDiscount4AllQuantity = isset($_POST["count_discount_4_all_quantity"]) && $_POST["count_discount_4_all_quantity"] == "Y" ? "Y" : "N";
             $basket->priceVatShowValue = isset($_POST["price_vat_show_value"]) && $_POST["price_vat_show_value"] == "Y" ? "Y" : "N";
             $basket->hideCoupon = isset($_POST["hide_coupon"]) && $_POST["hide_coupon"] == "Y" ? "Y" : "N";
             $basket->usePrepayment = isset($_POST["use_prepayment"]) && $_POST["use_prepayment"] == "Y" ? "Y" : "N";
             $columnsData = $basket->getCustomColumns();
             $basketData = $basket->getBasketItems();
             $arRes["DELETE_ORIGINAL"] = "Y";
             $arRes["BASKET_DATA"] = $basketData;
             $arRes["BASKET_DATA"]["GRID"]["HEADERS"] = $columnsData;
             $arRes["COLUMNS"] = $strColumns;
             $arRes["BASKET_ID"] = $arItem['ID'];
         }
         $arRes["CODE"] = $bBasketUpdate === true ? "SUCCESS" : "ERROR";
         if ($bBasketUpdate === false && is_array($arErrors) && !empty($arErrors)) {
             foreach ($arErrors as $error) {
                 $arRes["MESSAGE"] .= (strlen($arRes["MESSAGE"]) > 0 ? "<br/>" : "") . $error;
             }
         }
     }
 }
Beispiel #2
0
    } else {
        if ($_POST[$action_var] == "recalculate") {
            // todo: extract duplicated code to function
            CBitrixComponent::includeComponentClass("bitrix:sale.basket.basket");
            $basket = new CBitrixBasketComponent();
            $basket->onIncludeComponentLang();
            $basket->weightKoef = htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_koef', 1, SITE_ID));
            $basket->weightUnit = htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_unit', "", SITE_ID));
            $basket->columns = $arColumns;
            $basket->offersProps = $strOffersProps;
            $basket->quantityFloat = isset($_POST["quantity_float"]) && $_POST["quantity_float"] == "Y" ? "Y" : "N";
            $basket->countDiscount4AllQuantity = isset($_POST["count_discount_4_all_quantity"]) && $_POST["count_discount_4_all_quantity"] == "Y" ? "Y" : "N";
            $basket->priceVatShowValue = isset($_POST["price_vat_show_value"]) && $_POST["price_vat_show_value"] == "Y" ? "Y" : "N";
            $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";
        }
    }
}
$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);
die;