当前位置: 首页>>代码示例>>PHP>>正文


PHP CSaleBasketHelper::isSetItem方法代码示例

本文整理汇总了PHP中CSaleBasketHelper::isSetItem方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleBasketHelper::isSetItem方法的具体用法?PHP CSaleBasketHelper::isSetItem怎么用?PHP CSaleBasketHelper::isSetItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSaleBasketHelper的用法示例。


在下文中一共展示了CSaleBasketHelper::isSetItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: OnBasketChange

	public static function OnBasketChange($ID, $arFields = false)
	{
		if(isset($_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]))
		{
			$num_products = $_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID];
		}
		else
		{
			if(!CModule::IncludeModule("sale"))
			{
				return;
			}
			$fUserID = CSaleBasket::GetBasketUserID(True);
			$fUserID = IntVal($fUserID);
			$num_products = 0;
			if ($fUserID > 0)
			{
				$dbRes = CSaleBasket::GetList(
					array(),
					array(
						"FUSER_ID" => $fUserID,
						"LID" => SITE_ID,
						"ORDER_ID" => "NULL",
						"CAN_BUY" => "Y",
						"DELAY" => "N",
						"SUBSCRIBE" => "N"
					)
				);
				while ($arItem = $dbRes->GetNext())
				{
					if (!CSaleBasketHelper::isSetItem($arItem))
						$num_products++;
				}
			}
			$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID] = intval($num_products);
		}

		echo "<script>
			if (document.getElementById('bx_cart_num'))
				document.getElementById('bx_cart_num').innerHTML = '".(($num_products > 0) ? " (".$num_products.")" : "")."';
			</script>";
	}
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:42,代码来源:include.php

示例2: DoProcessOrder


//.........这里部分代码省略.........
             }
             unset($discountID);
             if (!empty($needDiscountHandlers)) {
                 $discountHandlersList = CSaleDiscount::getDiscountHandlers($needDiscountHandlers);
                 if (!empty($discountHandlersList)) {
                     foreach ($discountHandlersList as $discountID => $discountHandlers) {
                         self::$cacheDiscountHandlers[$discountID] = $discountHandlers;
                     }
                     unset($discountHandlers, $discountID);
                 }
                 unset($discountHandlersList);
             }
             unset($needDiscountHandlers);
         }
         $strDate = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")));
         CTimeZone::Disable();
         $rsDiscounts = CSaleDiscount::GetList(array('PRIORITY' => 'DESC', 'SORT' => 'ASC', 'ID' => 'ASC'), array('ID' => $arIDS, 'LID' => $arOrder['SITE_ID'], 'ACTIVE' => 'Y', '!>ACTIVE_FROM' => $strDate, '!<ACTIVE_TO' => $strDate), false, false, array('ID', 'PRIORITY', 'SORT', 'LAST_DISCOUNT', 'UNPACK', 'APPLICATION'));
         CTimeZone::Enable();
         $discountApply = array();
         $resultDiscountList = array();
         $resultDiscountKeys = array();
         $resultDiscountIndex = 0;
         while ($arDiscount = $rsDiscounts->Fetch()) {
             if (!isset($discountApply[$arDiscount['ID']])) {
                 $discountApply[$arDiscount['ID']] = true;
                 $applyFlag = true;
                 if (isset(self::$cacheDiscountHandlers[$arDiscount['ID']])) {
                     $moduleList = self::$cacheDiscountHandlers[$arDiscount['ID']]['MODULES'];
                     if (!empty($moduleList)) {
                         foreach ($moduleList as &$moduleID) {
                             if (!isset(self::$usedModules[$moduleID])) {
                                 self::$usedModules[$moduleID] = Loader::includeModule($moduleID);
                             }
                             if (!self::$usedModules[$moduleID]) {
                                 $applyFlag = false;
                                 break;
                             }
                         }
                         unset($moduleID);
                     }
                     unset($moduleList);
                 }
                 if ($applyFlag && self::__Unpack($arOrder, $arDiscount['UNPACK'])) {
                     $oldOrder = $arOrder;
                     self::__ApplyActions($arOrder, $arDiscount['APPLICATION']);
                     $discountResult = self::getDiscountResult($oldOrder, $arOrder, false);
                     if (!empty($discountResult)) {
                         $resultDiscountList[$resultDiscountIndex] = array('ID' => $arDiscount['ID'], 'PRIORITY' => $arDiscount['PRIORITY'], 'SORT' => $arDiscount['SORT'], 'LAST_DISCOUNT' => $arDiscount['LAST_DISCOUNT'], 'UNPACK' => $arDiscount['UNPACK'], 'APPLICATION' => $arDiscount['APPLICATION'], 'RESULT' => $discountResult, 'HANDLERS' => self::$cacheDiscountHandlers[$arDiscount['ID']]);
                         $resultDiscountKeys[$arDiscount['ID']] = $resultDiscountIndex;
                         $resultDiscountIndex++;
                         if ($arDiscount['LAST_DISCOUNT'] == 'Y') {
                             break;
                         }
                     }
                     unset($discountResult);
                 }
             }
         }
         unset($arDiscount, $rsDiscounts);
         if ($resultDiscountIndex > 0) {
             $rsDiscounts = CSaleDiscount::GetList(array(), array('ID' => array_keys($resultDiscountKeys)), false, false, array('ID', 'NAME', 'CONDITIONS', 'ACTIONS'));
             while ($arDiscount = $rsDiscounts->Fetch()) {
                 $arDiscount['ID'] = (int) $arDiscount['ID'];
                 if (isset($resultDiscountKeys[$arDiscount['ID']])) {
                     $key = $resultDiscountKeys[$arDiscount['ID']];
                     $resultDiscountList[$key]['NAME'] = $arDiscount['NAME'];
                     $resultDiscountList[$key]['CONDITIONS'] = $arDiscount['CONDITIONS'];
                     $resultDiscountList[$key]['ACTIONS'] = $arDiscount['ACTIONS'];
                 }
             }
         }
         $arOrder["ORDER_PRICE"] = 0;
         $arOrder["ORDER_WEIGHT"] = 0;
         $arOrder["USE_VAT"] = false;
         $arOrder["VAT_RATE"] = 0;
         $arOrder["VAT_SUM"] = 0;
         $arOrder["DISCOUNT_PRICE"] = 0.0;
         $arOrder["DISCOUNT_VALUE"] = $arOrder["DISCOUNT_PRICE"];
         $arOrder["DELIVERY_PRICE"] = $arOrder["PRICE_DELIVERY"];
         foreach ($arOrder['BASKET_ITEMS'] as &$arShoppingCartItem) {
             if (!CSaleBasketHelper::isSetItem($arShoppingCartItem)) {
                 $arOrder["ORDER_PRICE"] += doubleval($arShoppingCartItem["PRICE"]) * doubleval($arShoppingCartItem["QUANTITY"]);
                 $arOrder["ORDER_WEIGHT"] += $arShoppingCartItem["WEIGHT"] * $arShoppingCartItem["QUANTITY"];
                 $arShoppingCartItem["PRICE_FORMATED"] = CCurrencyLang::CurrencyFormat($arShoppingCartItem["PRICE"], $arShoppingCartItem["CURRENCY"], true);
                 $arShoppingCartItem["DISCOUNT_PRICE_PERCENT"] = $arShoppingCartItem["DISCOUNT_PRICE"] * 100 / ($arShoppingCartItem["DISCOUNT_PRICE"] + $arShoppingCartItem["PRICE"]);
                 $arShoppingCartItem["DISCOUNT_PRICE_PERCENT_FORMATED"] = roundEx($arShoppingCartItem["DISCOUNT_PRICE_PERCENT"], SALE_VALUE_PRECISION) . "%";
                 if ($arShoppingCartItem["VAT_RATE"] > 0) {
                     $arOrder["USE_VAT"] = true;
                     if ($arShoppingCartItem["VAT_RATE"] > $arOrder["VAT_RATE"]) {
                         $arOrder["VAT_RATE"] = $arShoppingCartItem["VAT_RATE"];
                     }
                     $arOrder["VAT_SUM"] += $arShoppingCartItem["VAT_VALUE"] * $arShoppingCartItem["QUANTITY"];
                 }
             }
         }
         if (isset($arShoppingCartItem)) {
             unset($arShoppingCartItem);
         }
     }
 }
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:discount.php

示例3: Delete

 function Delete($ID)
 {
     global $DB;
     $ID = intval($ID);
     if (0 >= $ID) {
         return false;
     }
     $rsBaskets = CSaleBasket::GetList(array(), array('ID' => $ID), false, false, array('ID', 'ORDER_ID', 'PRODUCT_ID', 'NAME', 'SUBSCRIBE', 'FUSER_ID', 'TYPE', 'SET_PARENT_ID'));
     if (!($arBasket = $rsBaskets->Fetch())) {
         return false;
     }
     foreach (GetModuleEvents("sale", "OnBeforeBasketDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
             return false;
         }
     }
     if (CSaleBasketHelper::isSetParent($arBasket)) {
         $rsSetItems = CSaleBasket::GetList(array(), array("SET_PARENT_ID" => $ID, "TYPE" => ""), false, false, array('ID', 'ORDER_ID', 'PRODUCT_ID', 'NAME', 'SUBSCRIBE', 'FUSER_ID', 'TYPE', 'SET_PARENT_ID'));
         while ($arSetItem = $rsSetItems->GetNext()) {
             CSaleBasket::Delete($arSetItem["ID"]);
         }
     }
     if (0 < intval($arBasket["ORDER_ID"])) {
         CSaleOrderChange::AddRecord($arBasket["ORDER_ID"], "BASKET_REMOVED", array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "NAME" => $arBasket["NAME"]));
     }
     $DB->Query("DELETE FROM b_sale_basket_props WHERE BASKET_ID = " . $ID, true);
     if (intval($_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]) > 0 && !CSaleBasketHelper::isSetItem($arBasket)) {
         $_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]--;
     }
     $DB->Query("DELETE FROM b_sale_store_barcode WHERE BASKET_ID = " . $ID, true);
     $DB->Query("DELETE FROM b_sale_basket WHERE ID = " . $ID, true);
     if ('Y' == $arBasket['SUBSCRIBE'] && array_key_exists('NOTIFY_PRODUCT', $_SESSION)) {
         $intUserID = CSaleUser::GetUserID($arBasket['FUSER_ID']);
         if ($intUserID && array_key_exists($intUserID, $_SESSION['NOTIFY_PRODUCT'])) {
             if (array_key_exists($arBasket['PRODUCT_ID'], $_SESSION['NOTIFY_PRODUCT'][$intUserID])) {
                 unset($_SESSION['NOTIFY_PRODUCT'][$intUserID][$arBasket['PRODUCT_ID']]);
             }
         }
     }
     foreach (GetModuleEvents("sale", "OnBasketDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID));
     }
     return true;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:44,代码来源:basket.php

示例4: recalculateBasket

 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;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:83,代码来源:class.php

示例5: foreach

        $arBasketItems[] = $arItem;
        if (CSaleBasketHelper::isSetItem($arItem)) {
            $arSetParentWeight[$arItem["SET_PARENT_ID"]] += $arItem["WEIGHT"] * $arItem['QUANTITY'];
        }
    }
}
if (!empty($arBasketItems)) {
    // count weight for set parent products
    foreach ($arBasketItems as &$arItem) {
        if (CSaleBasketHelper::isSetParent($arItem)) {
            $arItem["WEIGHT"] = $arSetParentWeight[$arItem["ID"]] / $arItem["QUANTITY"];
        }
    }
    unset($arItem);
    foreach ($arBasketItems as &$arItem) {
        if (CSaleBasketHelper::isSetItem($arItem)) {
            continue;
        }
        $boolOneReady = false;
        if ($arItem["DELAY"] == "N" && $arItem["CAN_BUY"] == "Y") {
            $boolOneReady = true;
            $bReady = true;
            $allSum += $arItem["PRICE"] * $arItem["QUANTITY"];
            $allWeight += $arItem["WEIGHT"] * $arItem["QUANTITY"];
        } elseif ($arItem["DELAY"] == "Y" && $arItem["CAN_BUY"] == "Y") {
            if ('N' == $arParams['SHOW_DELAY']) {
                continue;
            }
            $bDelay = true;
        } elseif ($arItem["CAN_BUY"] == "N" && $arItem["SUBSCRIBE"] == "N") {
            if ('N' == $arParams['SHOW_NOTAVAIL']) {
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:component.php

示例6: _Delete

 function _Delete($ID)
 {
     global $DB, $USER_FIELD_MANAGER;
     $ID = IntVal($ID);
     $bSuccess = True;
     foreach (GetModuleEvents("sale", "OnBeforeOrderDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
             return false;
         }
     }
     $DB->StartTransaction();
     if ($bSuccess) {
         $dbBasket = CSaleBasket::GetList(array(), array("ORDER_ID" => $ID));
         while ($arBasket = $dbBasket->Fetch()) {
             if (CSaleBasketHelper::isSetItem($arBasket)) {
                 // set items are deleted when parent is deleted
                 continue;
             }
             $bSuccess = CSaleBasket::Delete($arBasket["ID"]);
             if (!$bSuccess) {
                 break;
             }
         }
     }
     if ($bSuccess) {
         $dbRecurring = CSaleRecurring::GetList(array(), array("ORDER_ID" => $ID));
         while ($arRecurring = $dbRecurring->Fetch()) {
             $bSuccess = CSaleRecurring::Delete($arRecurring["ID"]);
             if (!$bSuccess) {
                 break;
             }
         }
     }
     if ($bSuccess) {
         $bSuccess = CSaleOrderPropsValue::DeleteByOrder($ID);
     }
     if ($bSuccess) {
         $bSuccess = CSaleOrderTax::DeleteEx($ID);
     }
     if ($bSuccess) {
         $bSuccess = CSaleUserTransact::DeleteByOrder($ID);
     }
     if ($bSuccess) {
         unset($GLOBALS["SALE_ORDER"]["SALE_ORDER_CACHE_" . $ID]);
     }
     if ($bSuccess) {
         $bSuccess = $DB->Query("DELETE FROM b_sale_order WHERE ID = " . $ID . "", true);
     }
     if ($bSuccess) {
         $USER_FIELD_MANAGER->Delete("ORDER", $ID);
     }
     if ($bSuccess) {
         $DB->Commit();
     } else {
         $DB->Rollback();
     }
     foreach (GetModuleEvents("sale", "OnOrderDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID, $bSuccess));
     }
     return $bSuccess;
 }
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:61,代码来源:order.php

示例7: reSortItems

 /**
  * resorting of elements in the parent
  * @param $basketItems
  * @param bool $setIndexAsId
  * @return array
  */
 public static function reSortItems($basketItems, $setIndexAsId = false)
 {
     $basketItemsTmp = $basketItems;
     $parentItems = array();
     $parentItemFound = false;
     foreach ($basketItemsTmp as $basketItemKey => $basketItem) {
         if (CSaleBasketHelper::isSetParent($basketItem) || CSaleBasketHelper::isSetItem($basketItem)) {
             $parentItemFound = true;
             if (!array_key_exists($basketItem['SET_PARENT_ID'], $parentItems)) {
                 $parentItems[$basketItem['SET_PARENT_ID']] = array();
             }
             if (CSaleBasketHelper::isSetItem($basketItem)) {
                 $parentItems[$basketItem['SET_PARENT_ID']][] = $basketItem;
                 unset($basketItemsTmp[$basketItemKey]);
             }
         }
     }
     if ($parentItemFound === true && !empty($basketItemsTmp) && is_array($basketItemsTmp) && !empty($parentItems) && is_array($parentItems)) {
         $basketItems = array();
         foreach ($basketItemsTmp as $basketItem) {
             if ($setIndexAsId === true) {
                 $basketItems[$basketItem['ID']] = $basketItem;
             } else {
                 $basketItems[] = $basketItem;
             }
             if (array_key_exists($basketItem['ID'], $parentItems)) {
                 foreach ($parentItems[$basketItem['ID']] as $childItem) {
                     if ($setIndexAsId === true) {
                         $basketItems[$childItem['ID']] = $childItem;
                     } else {
                         $basketItems[] = $childItem;
                     }
                 }
             }
         }
     }
     return $basketItems;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:44,代码来源:basket_helper.php

示例8: OrderDeduction


//.........这里部分代码省略.........
             }
             if (!$bRealDeductionAllowed) {
                 break;
             }
         }
     }
     // real deduction
     if ($bRealDeductionAllowed) {
         $bProductsDeductedSuccessfully = true;
         $arDeductedItems = array();
         foreach ($arItems as $arItem) {
             /** @var $productProvider IBXSaleProductProvider */
             if ($productProvider = CSaleBasket::GetProductProvider($arItem)) {
                 $arItem["FIELDS"]["EMULATE"] = "N";
                 if (defined("SALE_DEBUG") && SALE_DEBUG) {
                     CSaleHelper::WriteToLog("Call ::DeductProduct", array("fields" => $arItem["FIELDS"]), "OD10");
                 }
                 // finally real deduction
                 $res = $productProvider::DeductProduct($arItem["FIELDS"]);
                 if ($res["RESULT"]) {
                     $arDeductedItems[] = $arItem;
                     if (!$bUndoDeduction && $storesCount > 0) {
                         if ($bAutoDeduction) {
                             $arStoreBarcodeFields = array("BASKET_ID" => $arItem["ID"], "BARCODE" => "", "STORE_ID" => array_pop(array_keys($res["STORES"])), "QUANTITY" => $arItem["QUANTITY"], "CREATED_BY" => intval($GLOBALS["USER"]->GetID()) > 0 ? IntVal($GLOBALS["USER"]->GetID()) : "", "MODIFIED_BY" => intval($GLOBALS["USER"]->GetID()) > 0 ? IntVal($GLOBALS["USER"]->GetID()) : "");
                             if (defined("SALE_DEBUG") && SALE_DEBUG) {
                                 CSaleHelper::WriteToLog("Call CSaleStoreBarcode::Add (auto deduction = true)", array("arStoreBarcodeFields" => $arStoreBarcodeFields), "OD11");
                             }
                             CSaleStoreBarcode::Add($arStoreBarcodeFields);
                         }
                     }
                     if ($bUndoDeduction) {
                         $dbStoreBarcode = CSaleStoreBarcode::GetList(array(), array("BASKET_ID" => $arItem["ID"]), false, false, array("ID", "BASKET_ID"));
                         while ($arStoreBarcode = $dbStoreBarcode->GetNext()) {
                             CSaleStoreBarcode::Delete($arStoreBarcode["ID"]);
                         }
                     }
                     $tmpRes = $bUndoDeduction ? "N" : "Y";
                     CSaleBasket::Update($arItem["ID"], array("DEDUCTED" => $tmpRes));
                     // set parent deducted status
                     if ($bUndoDeduction) {
                         if (CSaleBasketHelper::isSetItem($arItem)) {
                             CSaleBasket::Update($arItem["SET_PARENT_ID"], array("DEDUCTED" => "N"));
                         }
                     } else {
                         if (CSaleBasketHelper::isSetItem($arItem) && CSaleBasketHelper::isSetDeducted($arItem["SET_PARENT_ID"])) {
                             CSaleBasket::Update($arItem["SET_PARENT_ID"], array("DEDUCTED" => "Y"));
                         }
                     }
                     if (defined("SALE_DEBUG") && SALE_DEBUG) {
                         CSaleHelper::WriteToLog("Call ::DeductProduct - Success (DEDUCTED = " . $tmpRes . ")", array(), "OD11");
                     }
                 } else {
                     CSaleBasket::Update($arItem["ID"], array("DEDUCTED" => "N"));
                     $bProductsDeductedSuccessfully = false;
                     if ($ex = $APPLICATION->GetException()) {
                         $arResult["ERROR"]["MESSAGE"] = $ex->GetString();
                         $arResult["ERROR"]["CODE"] = $ex->GetID();
                     }
                     if (defined("SALE_DEBUG") && SALE_DEBUG) {
                         CSaleHelper::WriteToLog("Call ::DeductProduct - Error (DEDUCTED = N)", array(), "OD12");
                     }
                     break;
                 }
             }
         }
         if ($bProductsDeductedSuccessfully) {
             $arResult["RESULT"] = true;
         } else {
             $arFields = array();
             foreach ($arDeductedItems as $arItem) {
                 /** @var $productProvider IBXSaleProductProvider */
                 if ($productProvider = CSaleBasket::GetProductProvider($arItem)) {
                     if ($storesCount > 0) {
                         $arFields = array("PRODUCT_ID" => $arItem["PRODUCT_ID"], "QUANTITY" => $arItem["QUANTITY"], "UNDO_DEDUCTION" => "Y", "EMULATE" => "N", "PRODUCT_RESERVED" => $arItem["FIELDS"]["PRODUCT_RESERVED"], "STORE_DATA" => $arItem["FIELDS"]["STORE_DATA"]);
                     } else {
                         $arFields = array("PRODUCT_ID" => $arItem["PRODUCT_ID"], "QUANTITY" => $arItem["QUANTITY"], "UNDO_DEDUCTION" => "Y", "PRODUCT_RESERVED" => $arItem["FIELDS"]["PRODUCT_RESERVED"], "EMULATE" => "N");
                     }
                     if (defined("SALE_DEBUG") && SALE_DEBUG) {
                         CSaleHelper::WriteToLog("Call ::DeductProduct - Revert deduction", array("storesCount" => $storesCount, "arFields" => $arFields), "OD13");
                     }
                     $res = $productProvider::DeductProduct($arFields);
                     if ($res["RESULT"]) {
                         CSaleBasket::Update($arItem["ID"], array("DEDUCTED" => "N"));
                         if (CSaleBasketHelper::isSetItem($arItem)) {
                             // todo - possibly not all the time, but once
                             CSaleBasket::Update($arItem["SET_PARENT_ID"], array("DEDUCTED" => "N"));
                         }
                     }
                 }
             }
             $arResult["RESULT"] = false;
         }
     } else {
         $arResult["RESULT"] = false;
     }
     if (defined("SALE_DEBUG") && SALE_DEBUG) {
         CSaleHelper::WriteToLog("OrderDeduction - result", array("arResult" => $arResult), "OD14");
     }
     return $arResult;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:basket.php

示例9: getProducts

 private function getProducts()
 {
     if (!($arFilter = $this->getUserFilter())) {
         return array();
     }
     if ($this->arParams['SHOW_NOTAVAIL'] == 'N') {
         $arFilter['CAN_BUY'] = 'Y';
     }
     if ($this->arParams['SHOW_DELAY'] == 'N') {
         $arFilter['DELAY'] = 'N';
     }
     if ($this->arParams['SHOW_SUBSCRIBE'] == 'N') {
         $arFilter["SUBSCRIBE"] = 'N';
     }
     $dbItems = CSaleBasket::GetList(array("NAME" => "ASC", "ID" => "ASC"), $arFilter, false, false, array("ID", "NAME", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY", "CAN_BUY", "PRICE", "WEIGHT", "DETAIL_PAGE_URL", "CURRENCY", "VAT_RATE", "CATALOG_XML_ID", "MEASURE_NAME", "PRODUCT_XML_ID", "SUBSCRIBE", "DISCOUNT_PRICE", "PRODUCT_PROVIDER_CLASS", "TYPE", "SET_PARENT_ID"));
     $arBasketItems = array();
     $arElementId = array();
     $arSku2Parent = array();
     while ($arItem = $dbItems->GetNext(true, false)) {
         if (CSaleBasketHelper::isSetItem($arItem)) {
             continue;
         }
         $arItem["PRICE_FMT"] = CCurrencyLang::CurrencyFormat($arItem["PRICE"], $arItem["CURRENCY"], true);
         $arItem["FULL_PRICE"] = CCurrencyLang::CurrencyFormat($arItem["PRICE"] + $arItem["DISCOUNT_PRICE"], $arItem["CURRENCY"], true);
         $arItem['QUANTITY'] += 0;
         // remove excessive zeros after period
         if (!$arItem['MEASURE_NAME']) {
             $arItem['MEASURE_NAME'] = GetMessage('TSB1_MEASURE_NAME');
         }
         if ($this->arParams['SHOW_IMAGE'] == 'Y' && $this->bUseCatalog && $arItem["MODULE"] == 'catalog') {
             $arElementId[] = $arItem["PRODUCT_ID"];
             $arParent = CCatalogSku::GetProductInfo($arItem["PRODUCT_ID"]);
             if ($arParent) {
                 $arElementId[] = $arParent["ID"];
                 $arSku2Parent[$arItem["PRODUCT_ID"]] = $arParent["ID"];
             }
         }
         $arBasketItems[] = $arItem;
     }
     $arResult = array('CATEGORIES' => array(), 'TOTAL_PRICE' => 0);
     if ($arBasketItems) {
         if ($this->arParams['SHOW_IMAGE'] == 'Y') {
             $this->setImgSrc($arBasketItems, $arElementId, $arSku2Parent);
         }
         $arResult["CATEGORIES"] = array("READY" => array(), "DELAY" => array(), "SUBSCRIBE" => array(), "NOTAVAIL" => array());
         // fill item arrays for templates
         foreach ($arBasketItems as $arItem) {
             if ($arItem["CAN_BUY"] == "Y") {
                 if ($arItem["DELAY"] == "Y") {
                     $arResult["CATEGORIES"]["DELAY"][] = $arItem;
                 } else {
                     $arResult["CATEGORIES"]["READY"][] = $arItem;
                 }
             } else {
                 if ($arItem["SUBSCRIBE"] == "Y") {
                     $arResult["CATEGORIES"]["SUBSCRIBE"][] = $arItem;
                 } else {
                     $arResult["CATEGORIES"]["NOTAVAIL"][] = $arItem;
                 }
             }
         }
         if ($this->arParams['SHOW_PRICE'] == 'Y' || $this->arParams['SHOW_SUMMARY'] == 'Y' || $this->arParams['SHOW_TOTAL_PRICE'] == 'Y') {
             $arOrder = $this->calculateOrder($arResult["CATEGORIES"]["READY"]);
             $arResult["CATEGORIES"]["READY"] = $arOrder['BASKET_ITEMS'];
             foreach ($arResult["CATEGORIES"]["READY"] as &$arItem) {
                 $arItem["SUM"] = CCurrencyLang::CurrencyFormat($arItem["PRICE"] * $arItem["QUANTITY"], $arItem["CURRENCY"], true);
                 $arItem["PRICE_FMT"] = CCurrencyLang::CurrencyFormat($arItem["PRICE"], $arItem["CURRENCY"], true);
             }
             $arResult["TOTAL_PRICE"] = $arOrder['ORDER_PRICE'];
         }
     }
     return array('NUM_PRODUCTS' => count($arBasketItems), 'TOTAL_PRICE' => $arResult["TOTAL_PRICE"], 'CATEGORIES' => $arResult["CATEGORIES"]);
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:73,代码来源:class.php

示例10: UpdateBasketPrices

 function UpdateBasketPrices($fuserID, $siteID)
 {
     $fuserID = (int) $fuserID;
     if ($fuserID <= 0) {
         return false;
     }
     $siteID = (string) $siteID;
     if ($siteID == '') {
         $siteID = SITE_ID;
     }
     $isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N');
     DiscountCouponsManager::clearApply(false);
     $basketItems = array();
     /*
     if (!empty($arBasketItems) && is_array($arBasketItems))
     			{
     				foreach ($arBasketItems as &$basketItemData)
     				{
     					if (array_key_exists('MEASURE_RATIO', $basketItemData))
     					{
     						$basketItemQuantity = floatval($basketItemData['QUANTITY']);
     						$basketItemRatio = floatval($basketItemData['MEASURE_RATIO']);
     
     						$mod = roundEx(($basketItemQuantity / $basketItemRatio - intval($basketItemQuantity / $basketItemRatio)), 6);
     
     						if ($mod !== 0)
     						{
     							$basketItemData['QUANTITY'] = ceil(ceil($basketItemQuantity) / $basketItemRatio)* $basketItemRatio;
     							CSaleBasket::Update($basketItemData['ID'], array('QUANTITY' => $basketItemData['QUANTITY']));
     						}
     					}
     				}
     				unset($basketItemData);
     			}
     */
     $dbBasketItems = CSaleBasket::GetList(array("ALL_PRICE" => "DESC"), array("FUSER_ID" => $fuserID, "LID" => $siteID, "ORDER_ID" => "NULL", "SUBSCRIBE" => "N"), false, false, array("ID", "MODULE", "PRODUCT_ID", "QUANTITY", "CALLBACK_FUNC", "PRODUCT_PROVIDER_CLASS", "CAN_BUY", "DELAY", "NOTES", "TYPE", "SET_PARENT_ID"));
     while ($arItem = $dbBasketItems->Fetch()) {
         $basketItems[] = $arItem;
     }
     if (!empty($basketItems) && is_array($basketItems)) {
         $basketItems = getRatio($basketItems);
         foreach ($basketItems as $basketItem) {
             $fields = array();
             $basketItem['CALLBACK_FUNC'] = (string) $basketItem['CALLBACK_FUNC'];
             $basketItem['PRODUCT_PROVIDER_CLASS'] = (string) $basketItem['PRODUCT_PROVIDER_CLASS'];
             if (strval(trim($basketItem['PRODUCT_PROVIDER_CLASS'])) !== '' || strval(trim($basketItem['CALLBACK_FUNC'])) !== '') {
                 $basketItem['MODULE'] = (string) $basketItem['MODULE'];
                 $basketItem['PRODUCT_ID'] = (int) $basketItem['PRODUCT_ID'];
                 $basketItem['QUANTITY'] = (double) $basketItem['QUANTITY'];
                 if ($productProvider = CSaleBasket::GetProductProvider($basketItem)) {
                     $fields = $productProvider::GetProductData(array("PRODUCT_ID" => $basketItem["PRODUCT_ID"], "QUANTITY" => $basketItem["QUANTITY"], "RENEWAL" => "N", "CHECK_COUPONS" => 'Y' == $basketItem['CAN_BUY'] && 'N' == $basketItem['DELAY'] ? 'Y' : 'N', "CHECK_DISCOUNT" => CSaleBasketHelper::isSetItem($basketItem) ? 'N' : 'Y', "BASKET_ID" => $basketItem["ID"], "NOTES" => $basketItem["NOTES"]));
                 } else {
                     $fields = CSaleBasket::ExecuteCallbackFunction($basketItem["CALLBACK_FUNC"], $basketItem["MODULE"], $basketItem["PRODUCT_ID"], $basketItem["QUANTITY"], "N");
                 }
                 if (!empty($fields) && is_array($fields)) {
                     if ($isOrderConverted == 'Y' && $basketItem['DELAY'] == 'N') {
                         if (!Sale\Compatible\DiscountCompatibility::isInited()) {
                             Sale\Compatible\DiscountCompatibility::init();
                         }
                         if (Sale\Compatible\DiscountCompatibility::usedByClient()) {
                             Sale\Compatible\DiscountCompatibility::setBasketItemData($basketItem['ID'], $fields);
                         }
                     }
                     $fields['CAN_BUY'] = 'Y';
                     $fields['TYPE'] = (int) $basketItem['TYPE'];
                     $fields['SET_PARENT_ID'] = (int) $basketItem['SET_PARENT_ID'];
                 } else {
                     $fields = array('CAN_BUY' => 'N');
                 }
             }
             if (array_key_exists('MEASURE_RATIO', $basketItem)) {
                 $basketItemQuantity = floatval($basketItem['QUANTITY']);
                 $basketItemRatio = floatval($basketItem['MEASURE_RATIO']);
                 $mod = roundEx($basketItemQuantity / $basketItemRatio - intval($basketItemQuantity / $basketItemRatio), 6);
                 if ($mod != 0) {
                     $fields['QUANTITY'] = floor(ceil($basketItemQuantity) / $basketItemRatio) * $basketItemRatio;
                 }
             }
             if (!empty($fields) && is_array($fields)) {
                 CSaleBasket::Update($basketItem['ID'], $fields);
             }
         }
     }
     return true;
 }
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:85,代码来源:basket.php

示例11: Delete

 /**
  * <p>Метод удаляет запись корзины с кодом ID. Метод динамичный.</p> <a name="examples"></a>
  *
  *
  * @param int $ID  
  *
  * @return bool 
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * if (CSaleBasket::Delete(22))
  *     echo "Запись успешно удалена";
  * ?&gt;
  * </htmМетод может использоваться и для удаления записей корзин, которые уже превращены в заказы. То есть, мы можем удалить запись из состава заказа. Но следует помнить, что после использования метода необходимо обновлять итоговую сумму заказа, например, так: 
  * 
  * 
  *  $contents = array();
  *  $dbBasketItems = CSaleBasket::GetList(
  *             array(
  *                "NAME" =&gt; "ASC",
  *                "ID" =&gt; "ASC"
  *             ),
  *             array(
  *               "LID" =&gt; SITE_ID,
  *               "ORDER_ID" =&gt; $order_id,
  *             )
  *          );
  *   while ($arItems = $dbBasketItems-&gt;Fetch()){
  *             $contents[] = $arItems;
  *          }
  *   $sum = 0;
  *   foreach($contents as $basket_item){
  *             if($basket_item['DISCOUNT_PRICE']&gt;0){
  *                $sum += $basket_item['DISCOUNT_PRICE']*$basket_item['QUANTITY'];
  *             }else{
  *                $sum += $basket_item['PRICE']*$basket_item['QUANTITY'];
  *             }
  *          }
  *    $arFields = array(
  *             "PRICE" =&gt; $sum,
  *          );
  *    CSaleOrder::Update($order_id, $arFields);
  * </pre>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalebasket/csalebasket__delete.e0d06223.php
  * @author Bitrix
  */
 public static function Delete($ID)
 {
     global $DB, $APPLICATION;
     $isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N');
     $ID = intval($ID);
     if (0 >= $ID) {
         return false;
     }
     if ($isOrderConverted == "Y") {
         /** @var \Bitrix\Sale\Result $r */
         $r = \Bitrix\Sale\Compatible\BasketCompatibility::delete($ID);
         if (!$r->isSuccess(true)) {
             foreach ($r->getErrorMessages() as $error) {
                 $APPLICATION->ThrowException($error);
             }
             return false;
         }
         return true;
     }
     $rsBaskets = CSaleBasket::GetList(array(), array('ID' => $ID), false, false, array('ID', 'ORDER_ID', 'PRODUCT_ID', 'NAME', 'SUBSCRIBE', 'FUSER_ID', 'TYPE', 'SET_PARENT_ID'));
     if (!($arBasket = $rsBaskets->Fetch())) {
         return false;
     }
     foreach (GetModuleEvents("sale", "OnBeforeBasketDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
             return false;
         }
     }
     if (CSaleBasketHelper::isSetParent($arBasket)) {
         $rsSetItems = CSaleBasket::GetList(array(), array("SET_PARENT_ID" => $ID, "TYPE" => ""), false, false, array('ID', 'ORDER_ID', 'PRODUCT_ID', 'NAME', 'SUBSCRIBE', 'FUSER_ID', 'TYPE', 'SET_PARENT_ID'));
         while ($arSetItem = $rsSetItems->GetNext()) {
             CSaleBasket::Delete($arSetItem["ID"]);
         }
     }
     if (0 < intval($arBasket["ORDER_ID"])) {
         CSaleOrderChange::AddRecord($arBasket["ORDER_ID"], "BASKET_REMOVED", array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "NAME" => $arBasket["NAME"]));
     }
     $DB->Query("DELETE FROM b_sale_basket_props WHERE BASKET_ID = " . $ID, true);
     if (intval($_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]) > 0 && !CSaleBasketHelper::isSetItem($arBasket)) {
         $_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]--;
     }
     $DB->Query("DELETE FROM b_sale_store_barcode WHERE BASKET_ID = " . $ID, true);
     $DB->Query("DELETE FROM b_sale_basket WHERE ID = " . $ID, true);
     if ('Y' == $arBasket['SUBSCRIBE'] && array_key_exists('NOTIFY_PRODUCT', $_SESSION)) {
         $intUserID = CSaleUser::GetUserID($arBasket['FUSER_ID']);
         if ($intUserID && array_key_exists($intUserID, $_SESSION['NOTIFY_PRODUCT'])) {
             if (array_key_exists($arBasket['PRODUCT_ID'], $_SESSION['NOTIFY_PRODUCT'][$intUserID])) {
                 unset($_SESSION['NOTIFY_PRODUCT'][$intUserID][$arBasket['PRODUCT_ID']]);
             }
         }
//.........这里部分代码省略.........
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:101,代码来源:basket.php

示例12: getBasketItems

 public function getBasketItems()
 {
     global $APPLICATION;
     $bUseCatalog = CModule::IncludeModule("catalog");
     $bUseIblock = $bUseCatalog;
     $bShowReady = False;
     $bShowDelay = False;
     $bShowSubscribe = False;
     $bShowNotAvail = False;
     $allSum = 0;
     $allWeight = 0;
     $allCurrency = CSaleLang::GetLangCurrency($this->getSiteId());
     $allVATSum = 0;
     $arParents = array();
     $arResult["ITEMS"]["AnDelCanBuy"] = array();
     $arResult["ITEMS"]["DelDelCanBuy"] = array();
     $arResult["ITEMS"]["nAnCanBuy"] = array();
     $arResult["ITEMS"]["ProdSubscribe"] = array();
     $DISCOUNT_PRICE_ALL = 0;
     // BASKET PRODUCTS (including measures, ratio, iblock properties data)
     $arImgFields = array("PREVIEW_PICTURE", "DETAIL_PICTURE");
     $arBasketItems = array();
     $arSku2Parent = array();
     $arSetParentWeight = array();
     $basketItemsFilter = array("USER_ID" => $this->userId, "ORDER_ID" => "NULL");
     if ($this->showDelay != 'Y') {
         $basketItemsFilter['DELAY'] = 'N';
     }
     $dbItems = CSaleBasket::GetList(array("ID" => "ASC"), $basketItemsFilter, false, false, array("ID", "NAME", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY", "CAN_BUY", "PRICE", "WEIGHT", "DETAIL_PAGE_URL", "NOTES", "CURRENCY", "VAT_RATE", "CATALOG_XML_ID", "PRODUCT_XML_ID", "SUBSCRIBE", "DISCOUNT_PRICE", "PRODUCT_PROVIDER_CLASS", "TYPE", "SET_PARENT_ID"));
     while ($arItem = $dbItems->GetNext()) {
         $arBasketItems[] = $arItem;
         if (CSaleBasketHelper::isSetItem($arItem)) {
             continue;
         }
         $arElementId[] = $arItem["PRODUCT_ID"];
         if ($bUseCatalog) {
             $arParent = CCatalogSku::GetProductInfo($arItem["PRODUCT_ID"]);
             if ($arParent) {
                 $arElementId[] = $arParent["ID"];
                 $arSku2Parent[$arItem["PRODUCT_ID"]] = $arParent["ID"];
                 $arParents[$arItem["PRODUCT_ID"]]["PRODUCT_ID"] = $arParent["ID"];
                 $arParents[$arItem["PRODUCT_ID"]]["IBLOCK_ID"] = $arParent["IBLOCK_ID"];
             }
         }
     }
     // get measures, ratio, sku props data and available quantity
     if (!empty($arBasketItems) && $bUseCatalog) {
         $arBasketItems = getMeasures($arBasketItems);
         $arBasketItems = getRatio($arBasketItems);
         $arBasketItems = $this->getAvailableQuantity($arBasketItems);
     }
     // get product properties data
     $arProductData = getProductProps($arElementId, array_merge(array("ID"), $arImgFields, $this->arCustomSelectFields));
     foreach ($arBasketItems as &$arItem) {
         $quantityIsFloat = false;
         if (number_format(doubleval($arItem['QUANTITY']), 2, '.', '') != intval($arItem['QUANTITY'])) {
             $quantityIsFloat = true;
         }
         $arItem["QUANTITY"] = $quantityIsFloat === false && $this->quantityFloat != "Y" ? intval($arItem['QUANTITY']) : number_format(doubleval($arItem['QUANTITY']), 2, '.', '');
         $arItem["QUANTITY_FORMATED"] = $arItem["QUANTITY"] . " " . $arItem["MEASURE_TEXT"];
         $arItem["PROPS"] = array();
         $dbProp = CSaleBasket::GetPropsList(array("SORT" => "ASC", "ID" => "ASC"), array("BASKET_ID" => $arItem["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")));
         while ($arProp = $dbProp->GetNext()) {
             $arItem["PROPS"][] = $arProp;
         }
         $arItem["PRICE_VAT_VALUE"] = $arItem["PRICE"] / ($arItem["VAT_RATE"] + 1) * $arItem["VAT_RATE"];
         $arItem["PRICE_FORMATED"] = $this->getSaleFormatCurrency($arItem["PRICE"], $arItem["CURRENCY"]);
         $arItem["WEIGHT"] = doubleval($arItem["WEIGHT"]);
         $arItem["WEIGHT_FORMATED"] = roundEx(doubleval($arItem["WEIGHT"] / $this->weightKoef), SALE_WEIGHT_PRECISION) . " " . $this->weightUnit;
         $arItem["DISCOUNT_FORMATED"] = $this->getSaleFormatCurrency($arItem["DISCOUNT_PRICE"], $arItem["CURRENCY"]);
         if (CSaleBasketHelper::isSetItem($arItem)) {
             $arSetParentWeight[$arItem["SET_PARENT_ID"]] += $arItem["WEIGHT"] * $arItem["QUANTITY"];
         }
         if (array_key_exists($arItem["PRODUCT_ID"], $arProductData) && is_array($arProductData[$arItem["PRODUCT_ID"]])) {
             foreach ($arProductData[$arItem["PRODUCT_ID"]] as $key => $value) {
                 if (strpos($key, "PROPERTY_") !== false || in_array($key, $arImgFields)) {
                     $arItem[$key] = $value;
                 }
             }
         }
         if (array_key_exists($arItem["PRODUCT_ID"], $arSku2Parent)) {
             $arFieldsToFill = array_merge($this->arCustomSelectFields, $arImgFields);
             // fields to be filled with parents' values if empty
             foreach ($arFieldsToFill as $field) {
                 $fieldVal = in_array($field, $arImgFields) ? $field : $field . "_VALUE";
                 $parentId = $arSku2Parent[$arItem["PRODUCT_ID"]];
                 if ((!isset($arItem[$fieldVal]) || isset($arItem[$fieldVal]) && strlen($arItem[$fieldVal]) == 0) && (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal]))) {
                     $arItem[$fieldVal] = $arProductData[$parentId][$fieldVal];
                 }
             }
         }
         foreach ($arItem as $key => $value) {
             if (strpos($key, "PROPERTY_", 0) === 0 && strrpos($key, "_VALUE") == strlen($key) - 6) {
                 $code = str_replace(array("PROPERTY_", "_VALUE"), "", $key);
                 $propData = $this->arIblockProps[$code];
                 $arItem[$key] = CSaleHelper::getIblockPropInfo($value, $propData);
             }
         }
         $arItem["PREVIEW_PICTURE_SRC"] = "";
         if (isset($arItem["PREVIEW_PICTURE"]) && intval($arItem["PREVIEW_PICTURE"]) > 0) {
//.........这里部分代码省略.........
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:101,代码来源:class.php

示例13: recalculateBasket

	public function recalculateBasket($arPost)
	{
		global $USER;
		$arRes = array();

		if ($this->hideCoupon != "Y")
		{
			if (isset($arPost["coupon"]) && !empty($arPost["coupon"]))
			{
				$arRes["VALID_COUPON"] = CCatalogDiscountCoupon::SetCoupon($arPost["coupon"]);
			}

			if (!isset($arRes["VALID_COUPON"]) || (isset($arRes["VALID_COUPON"]) && $arRes["VALID_COUPON"] === false))
			{
				CCatalogDiscountCoupon::ClearCoupon();
			}
		}

		$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) && CModule::IncludeModule("catalog"))
			$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")
			{
				unset($arFields);
				$arFields = array();

				if (in_array("QUANTITY", $this->columns))
					$arFields["QUANTITY"] = $quantityTmp;
				if (in_array("DELAY", $this->columns))
					$arFields["DELAY"] = $delayTmp;

				if (count($arFields) > 0
					&&
						($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")
			{
				unset($arFields);
				$arFields = array();

				if (in_array("DELAY", $this->columns))
					$arFields["DELAY"] = $delayTmp;
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:101,代码来源:class.php

示例14: obtainDataOrders

 /**
  * Perform reading main data from database, no cache is used
  * @return void
  */
 protected function obtainDataOrders()
 {
     $select = array('ID', 'LID', 'PERSON_TYPE_ID', 'PAYED', 'DATE_PAYED', 'EMP_PAYED_ID', 'CANCELED', 'DATE_CANCELED', 'EMP_CANCELED_ID', 'REASON_CANCELED', 'MARKED', 'DATE_MARKED', 'EMP_MARKED_ID', 'REASON_MARKED', 'STATUS_ID', 'DATE_STATUS', 'PAY_VOUCHER_NUM', 'PAY_VOUCHER_DATE', 'EMP_STATUS_ID', 'PRICE_DELIVERY', 'ALLOW_DELIVERY', 'DATE_ALLOW_DELIVERY', 'EMP_ALLOW_DELIVERY_ID', 'DEDUCTED', 'DATE_DEDUCTED', 'EMP_DEDUCTED_ID', 'REASON_UNDO_DEDUCTED', 'RESERVED', 'PRICE', 'CURRENCY', 'DISCOUNT_VALUE', 'SUM_PAID', 'USER_ID', 'PAY_SYSTEM_ID', 'DELIVERY_ID', 'DATE_INSERT', 'DATE_UPDATE', 'USER_DESCRIPTION', 'ADDITIONAL_INFO', 'COMMENTS', 'TAX_VALUE', 'STAT_GID', 'RECURRING_ID', 'RECOUNT_FLAG', 'DELIVERY_DOC_NUM', 'DELIVERY_DOC_DATE', 'STORE_ID', 'ORDER_TOPIC', 'RESPONSIBLE_ID', 'DATE_PAY_BEFORE', 'DATE_BILL', 'ACCOUNT_NUMBER', 'TRACKING_NUMBER', 'XML_ID');
     $usePageNavigation = true;
     $navyParams = array();
     $navyParams = \CDBResult::GetNavParams();
     if ($navyParams['SHOW_ALL']) {
         $usePageNavigation = false;
     } else {
         $navyParams['PAGEN'] = (int) $navyParams['PAGEN'];
         $navyParams['SIZEN'] = (int) $navyParams['SIZEN'];
     }
     if (isset($this->arParams["ORDERS_PER_PAGE"]) && intval($this->arParams["ORDERS_PER_PAGE"]) > 0) {
         $navyParams['SIZEN'] = $this->arParams["ORDERS_PER_PAGE"];
     }
     if (isset($_REQUEST['show_all']) && $_REQUEST['show_all'] == "Y") {
         $usePageNavigation = false;
     }
     $getListParams = array('order' => array($this->sortBy => $this->sortOrder), 'filter' => $this->filter, 'select' => $select);
     if ($usePageNavigation) {
         $getListParams['limit'] = $navyParams['SIZEN'];
         $getListParams['offset'] = $navyParams['SIZEN'] * ($navyParams['PAGEN'] - 1);
     }
     $totalPages = 0;
     if ($usePageNavigation) {
         $countQuery = new \Bitrix\Main\Entity\Query(\Bitrix\Sale\Internals\OrderTable::getEntity());
         $countQuery->addSelect(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(1)'));
         $countQuery->setFilter($getListParams['filter']);
         $totalCount = $countQuery->setLimit(null)->setOffset(null)->exec()->fetch();
         unset($countQuery);
         $totalCount = (int) $totalCount['CNT'];
         if ($totalCount > 0) {
             $totalPages = ceil($totalCount / $navyParams['SIZEN']);
             if ($navyParams['PAGEN'] > $totalPages) {
                 $navyParams['PAGEN'] = $totalPages;
             }
             $getListParams['limit'] = $navyParams['SIZEN'];
             $getListParams['offset'] = $navyParams['SIZEN'] * ($navyParams['PAGEN'] - 1);
         } else {
             $navyParams['PAGEN'] = 1;
             $getListParams['limit'] = $navyParams['SIZEN'];
             $getListParams['offset'] = 0;
         }
     }
     $this->dbQueryResult['ORDERS'] = new \CDBResult(\Bitrix\Sale\Internals\OrderTable::getList($getListParams));
     if ($usePageNavigation) {
         $this->dbQueryResult['ORDERS']->NavStart($getListParams['limit'], $navyParams['SHOW_ALL'], $navyParams['PAGEN']);
         $this->dbQueryResult['ORDERS']->NavRecordCount = $totalCount;
         $this->dbQueryResult['ORDERS']->NavPageCount = $totalPages;
         $this->dbQueryResult['ORDERS']->NavPageNomer = $navyParams['PAGEN'];
     } else {
         $this->dbQueryResult['ORDERS']->NavStart($this->arParams["ORDERS_PER_PAGE"], false);
     }
     if (empty($this->dbQueryResult['ORDERS'])) {
         return;
     }
     while ($arOrder = $this->dbQueryResult['ORDERS']->GetNext()) {
         $arOBasket = array();
         $dbBasket = CSaleBasket::GetList(array('NAME' => 'asc'), array("ORDER_ID" => $arOrder["ID"]), false, false, array('*'));
         while ($arBasket = $dbBasket->Fetch()) {
             if (CSaleBasketHelper::isSetItem($arBasket)) {
                 continue;
             }
             $arOBasket[$arBasket['ID']] = $arBasket;
         }
         $arOShipment = array();
         $dbShipment = \Bitrix\Sale\Internals\ShipmentTable::getList(array('select' => array('DELIVERY_NAME', 'SYSTEM', 'DELIVERY_ID'), 'filter' => array('ORDER_ID' => $arOrder['ID'])));
         while ($arShipment = $dbShipment->fetch()) {
             if ($arShipment['SYSTEM'] == 'Y') {
                 continue;
             }
             $arOShipment[] = $arShipment;
         }
         $dbPayment = \Bitrix\Sale\Internals\PaymentTable::getList(array('select' => array('PAY_SYSTEM_NAME', 'PAY_SYSTEM_ID'), 'filter' => array('ORDER_ID' => $arOrder['ID'])));
         $arOPayment = array();
         while ($arPayment = $dbPayment->fetch()) {
             $arOPayment[] = $arPayment;
         }
         $this->dbResult['ORDERS'][] = array("ORDER" => $arOrder, "BASKET_ITEMS" => $arOBasket, "SHIPMENT" => $arOShipment, "PAYMENT" => $arOPayment);
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:85,代码来源:class.php

示例15: UpdateBasketPrices

 function UpdateBasketPrices($fuserID, $siteID)
 {
     $fuserID = (int) $fuserID;
     if ($fuserID <= 0) {
         return false;
     }
     $siteID = (string) $siteID;
     if ($siteID == '') {
         $siteID = SITE_ID;
     }
     $isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N');
     $dbBasketItems = CSaleBasket::GetList(array("ALL_PRICE" => "DESC"), array("FUSER_ID" => $fuserID, "LID" => $siteID, "ORDER_ID" => "NULL", "SUBSCRIBE" => "N"), false, false, array("ID", "MODULE", "PRODUCT_ID", "QUANTITY", "CALLBACK_FUNC", "PRODUCT_PROVIDER_CLASS", "CAN_BUY", "DELAY", "NOTES", "TYPE", "SET_PARENT_ID"));
     while ($arItem = $dbBasketItems->Fetch()) {
         if ($arItem['CAN_BUY'] != 'Y') {
             continue;
         }
         $arFields = false;
         $arItem['CALLBACK_FUNC'] = (string) $arItem['CALLBACK_FUNC'];
         $arItem['PRODUCT_PROVIDER_CLASS'] = (string) $arItem['PRODUCT_PROVIDER_CLASS'];
         if ('' != $arItem['PRODUCT_PROVIDER_CLASS'] || '' != $arItem['CALLBACK_FUNC']) {
             $arItem['MODULE'] = (string) $arItem['MODULE'];
             $arItem['PRODUCT_ID'] = (int) $arItem['PRODUCT_ID'];
             $arItem['QUANTITY'] = (double) $arItem['QUANTITY'];
             if ($productProvider = CSaleBasket::GetProductProvider($arItem)) {
                 $arFields = $productProvider::GetProductData(array("PRODUCT_ID" => $arItem["PRODUCT_ID"], "QUANTITY" => $arItem["QUANTITY"], "RENEWAL" => "N", "CHECK_COUPONS" => 'Y' == $arItem['CAN_BUY'] && 'N' == $arItem['DELAY'] ? 'Y' : 'N', "CHECK_DISCOUNT" => CSaleBasketHelper::isSetItem($arItem) ? 'N' : 'Y', "BASKET_ID" => $arItem["ID"], "NOTES" => $arItem["NOTES"]));
             } else {
                 $arFields = CSaleBasket::ExecuteCallbackFunction($arItem["CALLBACK_FUNC"], $arItem["MODULE"], $arItem["PRODUCT_ID"], $arItem["QUANTITY"], "N");
             }
             if (!empty($arFields) && is_array($arFields)) {
                 if ($isOrderConverted == 'Y' && $arItem['DELAY'] == 'N') {
                     if (!Sale\Compatible\DiscountCompatibility::isInited()) {
                         Sale\Compatible\DiscountCompatibility::init();
                     }
                     if (Sale\Compatible\DiscountCompatibility::usedByClient()) {
                         if (isset($arFields['BASE_PRICE']) && isset($arFields['CURRENCY'])) {
                             Sale\Compatible\DiscountCompatibility::setBasketItemBasePrice($arItem['ID'], $arFields['BASE_PRICE'], $arFields['CURRENCY']);
                         }
                         if (!empty($arFields['DISCOUNT_LIST'])) {
                             Sale\Compatible\DiscountCompatibility::setBasketItemDiscounts($arItem['ID'], $arFields['DISCOUNT_LIST']);
                         }
                     }
                 }
                 $arFields['CAN_BUY'] = 'Y';
                 $arFields['TYPE'] = (int) $arItem['TYPE'];
                 $arFields['SET_PARENT_ID'] = (int) $arItem['SET_PARENT_ID'];
             } else {
                 $arFields = array('CAN_BUY' => 'N');
             }
             CSaleBasket::Update($arItem['ID'], $arFields);
         }
     }
     return true;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:53,代码来源:basket.php


注:本文中的CSaleBasketHelper::isSetItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。