Esempio n. 1
0
                 $newValues[] = array("NAME" => $productSkuProp["NAME"], "CODE" => $productSkuProp["CODE"], "VALUE" => $productSkuProp["VALUE"], "SORT" => $productSkuProp["SORT"]);
             }
         }
         $newValues[] = array("NAME" => "Product XML_ID", "CODE" => "PRODUCT.XML_ID", "VALUE" => $newProductId["XML_ID"]);
         $arFields['PROPS'] = isset($arItem['PROPS']) ? updateBasketOffersProps($arItem['PROPS'], $newValues) : $newValues;
         unset($newValues);
         if (empty($arErrors)) {
             $bBasketUpdate = CSaleBasket::Update($arItem['ID'], $arFields);
         }
     } else {
         $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;
Esempio n. 2
0
 public function recalculateBasket($arPost)
 {
     global $USER;
     $arRes = array();
     if ($this->hideCoupon != "Y") {
         if (!empty($arPost['delete_coupon'])) {
             $arRes['VALID_COUPON'] = DiscountCouponsManager::delete($arPost['delete_coupon']);
         } else {
             $oldUse = false;
             if (array_key_exists('coupon', $arPost)) {
                 $arPost['coupon'] = trim((string) $arPost['coupon']);
                 if ($arPost['coupon'] != '') {
                     $arRes['VALID_COUPON'] = DiscountCouponsManager::add($arPost['coupon']);
                 } else {
                     $oldUse = true;
                 }
             }
             if ($oldUse) {
                 if (!isset($arRes["VALID_COUPON"]) || $arRes["VALID_COUPON"] === false) {
                     DiscountCouponsManager::clear(true);
                 }
             }
         }
     }
     $arTmpItems = array();
     $dbItems = CSaleBasket::GetList(array("PRICE" => "DESC"), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL"), false, false, array("ID", "NAME", "PRODUCT_PROVIDER_CLASS", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY", "CAN_BUY", "CURRENCY", "SUBSCRIBE", "TYPE", "SET_PARENT_ID", "NOTES"));
     while ($arItem = $dbItems->Fetch()) {
         if (CSaleBasketHelper::isSetItem($arItem)) {
             continue;
         }
         $arTmpItems[] = $arItem;
     }
     if (!empty($arTmpItems)) {
         if (self::$catalogIncluded === null) {
             self::$catalogIncluded = Loader::includeModule('catalog');
         }
         if (self::$catalogIncluded) {
             $arTmpItems = getRatio($arTmpItems);
         }
         foreach ($arTmpItems as $arItem) {
             $isFloatQuantity = isset($arItem["MEASURE_RATIO"]) && floatval($arItem["MEASURE_RATIO"]) > 0 && $arItem["MEASURE_RATIO"] != 1 || $this->quantityFloat == "Y" ? true : false;
             if (!isset($arPost["QUANTITY_" . $arItem["ID"]]) || floatval($arPost["QUANTITY_" . $arItem["ID"]]) <= 0) {
                 $quantityTmp = $isFloatQuantity === true ? floatval($arItem["QUANTITY"]) : intval($arItem["QUANTITY"]);
             } else {
                 $quantityTmp = $isFloatQuantity === true ? floatval($arPost["QUANTITY_" . $arItem["ID"]]) : intval($arPost["QUANTITY_" . $arItem["ID"]]);
             }
             $deleteTmp = $arPost["DELETE_" . $arItem["ID"]] == "Y" ? "Y" : "N";
             $delayTmp = $arPost["DELAY_" . $arItem["ID"]] == "Y" ? "Y" : "N";
             if ($arItem["CAN_BUY"] == "Y") {
                 $res = $this->checkQuantity($arItem, $quantityTmp);
                 if (!empty($res)) {
                     $arRes["WARNING_MESSAGE"][] = $res["ERROR"];
                 }
             }
             if ($deleteTmp == "Y" && in_array("DELETE", $this->columns)) {
                 if ($arItem["SUBSCRIBE"] == "Y" && is_array($_SESSION["NOTIFY_PRODUCT"][$USER->GetID()])) {
                     unset($_SESSION["NOTIFY_PRODUCT"][$USER->GetID()][$arItem["PRODUCT_ID"]]);
                 }
                 CSaleBasket::Delete($arItem["ID"]);
             } elseif ($arItem["DELAY"] == "N" && $arItem["CAN_BUY"] == "Y") {
                 $arFields = array();
                 if (in_array("QUANTITY", $this->columns)) {
                     $arFields["QUANTITY"] = $quantityTmp;
                 }
                 if (in_array("DELAY", $this->columns)) {
                     $arFields["DELAY"] = $delayTmp;
                 }
                 if (!empty($arFields) && ($arItem["QUANTITY"] != $arFields["QUANTITY"] && in_array("QUANTITY", $this->columns) || $arItem["DELAY"] != $arFields["DELAY"] && in_array("DELAY", $this->columns))) {
                     CSaleBasket::Update($arItem["ID"], $arFields);
                 }
             } elseif ($arItem["DELAY"] == "Y" && $arItem["CAN_BUY"] == "Y") {
                 $arFields = array();
                 if (in_array("DELAY", $this->columns)) {
                     $arFields["DELAY"] = $delayTmp;
                 }
                 if (!empty($arFields) && ($arItem["DELAY"] != $arFields["DELAY"] && in_array("DELAY", $this->columns))) {
                     CSaleBasket::Update($arItem["ID"], $arFields);
                 }
             }
         }
     }
     return $arRes;
 }
Esempio n. 3
0
                 $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;
                 }
             }
         }
     }
 } 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();