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


PHP CSaleUser::_Add方法代码示例

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


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

示例1: DoSaveOrderBasket

 /**
  * Updates information about basket products after changes have been made in the order_new form
  * (saves newly added basket items, changes their quantity, saves barcodes etc)
  *
  * @param int $orderId - order ID
  * @param string $siteId - site ID
  * @param bool $userId - user ID
  * @param array $arShoppingCart - array of basket items
  * @param array $arErrors
  * @param array $arCoupons
  * @param array $arStoreBarcodeOrderFormData - array of stores and barcodes for deduction (from order_new form)
  * @param bool $bSaveBarcodes - flat to save given barcode data. Used if the order is already deducted or at least has saved other barcodes
  * @return bool
  */
 public static function DoSaveOrderBasket($orderId, $siteId, $userId, &$arShoppingCart, &$arErrors, $arCoupons = array(), $arStoreBarcodeOrderFormData = array(), $bSaveBarcodes = false)
 {
     global $DB, $USER;
     $currentUserID = 0;
     if (isset($USER) && $USER instanceof CUser) {
         $currentUserID = (int) $USER->GetID();
     }
     if (defined("SALE_DEBUG") && SALE_DEBUG) {
         CSaleHelper::WriteToLog("DoSaveOrderBasket - Started", array("orderId" => $orderId, "siteId" => $siteId, "userId" => $userId, "arShoppingCart" => $arShoppingCart, "bSaveBarcodes" => $bSaveBarcodes, "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData), "DSOB1");
     }
     $orderId = (int) $orderId;
     if ($orderId <= 0) {
         return false;
     }
     if (empty($arShoppingCart) || !is_array($arShoppingCart)) {
         $arErrors[] = array("CODE" => "PARAM", "TEXT" => Loc::getMessage('SKGB_SHOPPING_CART_EMPTY'));
         return false;
     }
     $isOrderReserved = false;
     $isOrderDeducted = false;
     $dbOrderTmp = CSaleOrder::GetList(array(), array("ID" => $orderId), false, false, array("ID", "RESERVED", "DEDUCTED"));
     if ($arOrder = $dbOrderTmp->Fetch()) {
         if ($arOrder["RESERVED"] == "Y") {
             $isOrderReserved = true;
         }
         if ($arOrder["DEDUCTED"] == "Y") {
             $isOrderDeducted = true;
         }
     }
     $arOldItems = array();
     $dbItems = CSaleBasket::GetList(array(), array("ORDER_ID" => $orderId), false, false, array("ID", "QUANTITY", "CANCEL_CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "PRODUCT_PROVIDER_CLASS", "RESERVED", "RESERVE_QUANTITY", "TYPE", "SET_PARENT_ID"));
     while ($arItem = $dbItems->Fetch()) {
         $arOldItems[$arItem["ID"]] = array("QUANTITY" => $arItem["QUANTITY"], "CANCEL_CALLBACK_FUNC" => $arItem["CANCEL_CALLBACK_FUNC"], "PRODUCT_PROVIDER_CLASS" => $arItem["PRODUCT_PROVIDER_CLASS"], "MODULE" => $arItem["MODULE"], "PRODUCT_ID" => $arItem["PRODUCT_ID"], "RESERVED" => $arItem["RESERVED"], "RESERVE_QUANTITY" => $arItem["RESERVE_QUANTITY"], "TYPE" => $arItem["TYPE"], "SET_PARENT_ID" => $arItem["SET_PARENT_ID"]);
     }
     if (!empty($arCoupons)) {
         if (!is_array($arCoupons)) {
             $arCoupons = array($arCoupons);
         }
         foreach (GetModuleEvents("sale", "OnSetCouponList", true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array($userId, $arCoupons, array()));
         }
         foreach ($arCoupons as &$coupon) {
             $couponResult = DiscountCouponsManager::add($coupon);
         }
         unset($coupon);
     }
     $arFUserListTmp = CSaleUser::GetList(array("USER_ID" => $userId));
     if (empty($arFUserListTmp)) {
         $arFields = array("=DATE_INSERT" => $DB->GetNowFunction(), "=DATE_UPDATE" => $DB->GetNowFunction(), "USER_ID" => $userId, "CODE" => md5(time() . randString(10)));
         $FUSER_ID = CSaleUser::_Add($arFields);
     } else {
         $FUSER_ID = $arFUserListTmp["ID"];
     }
     // re-sort basket data so newly added Set parents come before Set items (used to correctly add Set items to the table)
     usort($arShoppingCart, array("CSaleBasketHelper", "cmpSetData"));
     foreach ($arShoppingCart as &$arItem) {
         $arItemKeys = array_keys($arItem);
         foreach ($arItemKeys as $fieldName) {
             if (array_key_exists("~" . $fieldName, $arItem)) {
                 if (is_array($arItem["~" . $fieldName]) && !empty($arItem["~" . $fieldName]) || !is_array($arItem["~" . $fieldName]) && strlen($arItem["~" . $fieldName]) > 0) {
                     $arItem[$fieldName] = $arItem["~" . $fieldName];
                 }
                 unset($arItem["~" . $fieldName]);
             }
         }
         $arItem = array_filter($arItem, array("CSaleBasketHelper", "filterFields"));
     }
     unset($arItem);
     $arTmpSetParentId = array();
     foreach ($arShoppingCart as $arItem) {
         if (strpos($arItem["SET_PARENT_ID"], "tmp") !== false) {
             $arTmpSetParentId[$arItem["SET_PARENT_ID"]] = $arItem["SET_PARENT_ID"];
         }
     }
     // iterate over basket data to save it to basket or change quantity (and reserve/deduct accordingly)
     foreach ($arShoppingCart as &$arItem) {
         foreach ($arItem as $tmpKey => $tmpVal) {
             if (is_array($tmpVal) && !in_array($tmpKey, array("STORES", "CATALOG", "PROPS"))) {
                 $arItem[$tmpKey] = serialize($tmpVal);
             }
         }
         if (defined("SALE_DEBUG") && SALE_DEBUG) {
             CSaleHelper::WriteToLog("DoSaveOrderBasket - Item", array("arItem" => $arItem), "DSOB2");
         }
         if (array_key_exists("ID", $arItem) && (int) $arItem["ID"] > 0) {
             $arItem["ID"] = (int) $arItem["ID"];
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:basket.php

示例2: __MakeOrder

		function __MakeOrder($prdCnt=1, $arData = Array())
		{
			global $APPLICATION, $USER, $DB;
			CModule::IncludeModule("iblock");
			CModule::IncludeModule("sale");
			CModule::IncludeModule("catalog");
			$arPrd = Array();
			$dbItem = CIBlockElement::GetList(Array("PROPERTY_MORE_PHOTO" => "DESC", "ID" => "ASC"), Array("IBLOCK_TYPE" => "offers", "IBLOCK_SITE_ID" => WIZARD_SITE_ID, "PROPERTY_NEWPRODUCT" => false), false, Array("nTopCount" => 10), Array("ID", "IBLOCK_ID", "XML_ID", "NAME", "DETAIL_PAGE_URL", "IBLOCK_XML_ID"));
			while($arItem = $dbItem->GetNext())
				$arPrd[] = $arItem;

			if(!empty($arPrd))
			{
				for($i=0; $i<$prdCnt;$i++)
				{
					$prdID = $arPrd[mt_rand(0, 9)];
					$arProduct = CCatalogProduct::GetByID($prdID["ID"]);
					$CALLBACK_FUNC = "";
					$arCallbackPrice = CSaleBasket::ReReadPrice($CALLBACK_FUNC, "catalog", $prdID["ID"], 1);

					$arFields = array(
							"PRODUCT_ID" => $prdID["ID"],
							"PRODUCT_PRICE_ID" => $arCallbackPrice["PRODUCT_PRICE_ID"],
							"PRICE" => $arCallbackPrice["PRICE"],
							"CURRENCY" => $arCallbackPrice["CURRENCY"],
							"WEIGHT" => $arProduct["WEIGHT"],
							"QUANTITY" => 1,
							"LID" => WIZARD_SITE_ID,
							"DELAY" => "N",
							"CAN_BUY" => "Y",
							"NAME" => $prdID["NAME"],
							"CALLBACK_FUNC" => $CALLBACK_FUNC,
							"MODULE" => "catalog",
							"PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider",
							"ORDER_CALLBACK_FUNC" => "",
							"CANCEL_CALLBACK_FUNC" => "",
							"PAY_CALLBACK_FUNC" => "",
							"DETAIL_PAGE_URL" => $prdID["DETAIL_PAGE_URL"],
							"CATALOG_XML_ID" => $prdID["IBLOCK_XML_ID"],
							"PRODUCT_XML_ID" => $prdID["XML_ID"],
							"VAT_RATE" => $arCallbackPrice['VAT_RATE'],
						);
					$addres = CSaleBasket::Add($arFields);
				}

				$arOrder = Array(
						"LID" => $arData["SITE_ID"],
						"PERSON_TYPE_ID" => $arData["PERSON_TYPE_ID"],
						"PAYED" => "N",
						"CANCELED" => "N",
						"STATUS_ID" => "N",
						"PRICE" => 1,
						"CURRENCY" => $arData["CURRENCY"],
						"USER_ID" => $arData["USER_ID"],
						"PAY_SYSTEM_ID" => $arData["PAY_SYSTEM_ID"],
						//"PRICE_DELIVERY" => $arData["PRICE_DELIVERY"],
						//"DELIVERY_ID" => $arData["DELIVERY_ID"],
					);

				$dbFUserListTmp = CSaleUser::GetList(array("USER_ID" => $arData["USER_ID"]));
				if(empty($dbFUserListTmp))
				{
					$arFields = array(
							"=DATE_INSERT" => $DB->GetNowFunction(),
							"=DATE_UPDATE" => $DB->GetNowFunction(),
							"USER_ID" => $arData["USER_ID"]
						);

					$ID = CSaleUser::_Add($arFields);
				}

				$orderID = CSaleOrder::Add($arOrder);
				CSaleBasket::OrderBasket($orderID, CSaleBasket::GetBasketUserID(), WIZARD_SITE_ID);
				$dbBasketItems = CSaleBasket::GetList(
						array("NAME" => "ASC"),
						array(
								"FUSER_ID" => CSaleBasket::GetBasketUserID(),
								"LID" => WIZARD_SITE_ID,
								"ORDER_ID" => $orderID
							),
						false,
						false,
						array("ID", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY", "CAN_BUY", "PRICE", "WEIGHT", "NAME")
					);
				$ORDER_PRICE = 0;
				while ($arBasketItems = $dbBasketItems->GetNext())
				{
					$ORDER_PRICE += roundEx($arBasketItems["PRICE"], SALE_VALUE_PRECISION) * DoubleVal($arBasketItems["QUANTITY"]);
				}

				$totalOrderPrice = $ORDER_PRICE + $arData["PRICE_DELIVERY"];
				CSaleOrder::Update($orderID, Array("PRICE" => $totalOrderPrice));
				foreach($arData["PROPS"] as $val)
				{
					$arFields = Array(
							"ORDER_ID" => $orderID,
							"ORDER_PROPS_ID" => $val["ID"],
							"NAME" => $val["NAME"],
							"CODE" => $val["CODE"],
							"VALUE" => $val["VALUE"],
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:101,代码来源:step1.php

示例3: NextPayment


//.........这里部分代码省略.........
					{
						$arTaxSums[$arTaxList[$di]["TAX_ID"]]["VALUE"] = $arTaxList[$di]["VALUE_MONEY"];
						$arTaxSums[$arTaxList[$di]["TAX_ID"]]["NAME"] = $arTaxList[$di]["NAME"];
						if ($arTaxList[$di]["IS_IN_PRICE"] != "Y")
						{
							$taxPrice += $arTaxList[$di]["VALUE_MONEY"];
						}
					}
				}
				else
				{
					$arTaxList[0]["VALUE_MONEY"] = (($discountPrice / ($vatRate +1)) * $vatRate) * DoubleVal($arProduct["QUANTITY"]);
					$taxVatPrice = $arTaxList[0]["VALUE_MONEY"];
				}
			}


			// Changed by Sigurd, 2007-08-16
			$totalOrderPrice = $discountPrice * DoubleVal($arProduct["QUANTITY"]) + $deliveryPrice + $taxPrice;

			$arProduct["WITHOUT_ORDER"] = (($arProduct["WITHOUT_ORDER"]=="Y") ? "Y" : "N");
			if ($arProduct["WITHOUT_ORDER"] == "N")
			{
				$DB->StartTransaction();

				// Saving
				$arSaleUser = CSaleUser::GetList(Array(), Array("USER_ID" => $arOrder["USER_ID"]));
				if(!empty($arSaleUser))
				{
					$currentFUser = $arSaleUser["ID"];
				}
				else
				{
					$currentFUser = CSaleUser::_Add(
							array(
									"=DATE_INSERT" => $DB->GetNowFunction(),
									"=DATE_UPDATE" => $DB->GetNowFunction(),
									"USER_ID" => $arOrder["USER_ID"]
								)
						);
				}

				$arFields = array(
						"FUSER_ID" => $currentFUser,
						"PRODUCT_ID" => $arProduct["PRODUCT_ID"],
						"PRODUCT_NAME" => $arProduct["PRODUCT_NAME"],
						"PRODUCT_URL" => $arProduct["PRODUCT_URL"],
						"PRODUCT_PRICE_ID" => $arProduct["PRODUCT_PRICE_ID"],
						"PRICE" => $arProduct["PRICE"],
						"CURRENCY" => $arProduct["CURRENCY"],
						"WEIGHT" => $arProduct["WEIGHT"],
						"QUANTITY" => $arProduct["QUANTITY"],
						"LID" => $arOrder["LID"],
						"DELAY" => "N",
						"CAN_BUY" => "Y",
						"NAME" => $arProduct["NAME"],
						"CALLBACK_FUNC" => $arProduct["CALLBACK_FUNC"],
						"ORDER_CALLBACK_FUNC" => $arProduct["ORDER_CALLBACK_FUNC"],
						"CANCEL_CALLBACK_FUNC" => $arProduct["CANCEL_CALLBACK_FUNC"],
						"PAY_CALLBACK_FUNC" => $arProduct["PAY_CALLBACK_FUNC"],
						"PRODUCT_PROVIDER_CLASS" => $arProduct["PRODUCT_PROVIDER_CLASS"],
						"MODULE" => $arRecur["MODULE"],
						"NOTES" => $arProduct["CATALOG_GROUP_NAME"],
						"DETAIL_PAGE_URL" => $arProduct["DETAIL_PAGE_URL"],
						"VATE_RATE" => $arProduct["VATE_RATE"],
						"PRODUCT_XML_ID" => $arProduct["PRODUCT_XML_ID"],
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:67,代码来源:recurring.php

示例4: Add

 public static function Add()
 {
     global $DB, $USER;
     $arFields = array("=DATE_INSERT" => $DB->GetNowFunction(), "=DATE_UPDATE" => $DB->GetNowFunction(), "USER_ID" => is_object($USER) && $USER->IsAuthorized() ? IntVal($USER->GetID()) : False, "CODE" => md5(time() . randString(10)));
     $ID = CSaleUser::_Add($arFields);
     $ID = IntVal($ID);
     $secure = false;
     if (COption::GetOptionString("sale", "use_secure_cookies", "N") == "Y" && CMain::IsHTTPS()) {
         $secure = 1;
     }
     if (COption::GetOptionString("sale", "encode_fuser_id", "N") == "Y") {
         $arRes = CSaleUser::GetList(array("ID" => $ID));
         if (!empty($arRes)) {
             $GLOBALS["APPLICATION"]->set_cookie("SALE_UID", $arRes["CODE"], false, "/", false, $secure, "Y", false);
         }
     } else {
         $GLOBALS["APPLICATION"]->set_cookie("SALE_UID", $ID, false, "/", false, $secure, "Y", false);
     }
     return $ID;
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:20,代码来源:basket.php

示例5: __MakeOrder

 function __MakeOrder($prdCnt = 1, $arData = array())
 {
     global $APPLICATION, $USER, $DB;
     CModule::IncludeModule("iblock");
     CModule::IncludeModule("sale");
     CModule::IncludeModule("catalog");
     $arPrd = array();
     $dbItem = CIBlockElement::GetList(array(), array("IBLOCK_TYPE" => "offers", "IBLOCK_SITE_ID" => WIZARD_SITE_ID, "PROPERTY_NEWPRODUCT" => false), false, array("nTopCount" => 100), array("ID", "IBLOCK_ID", "XML_ID", "NAME", "DETAIL_PAGE_URL", "IBLOCK_XML_ID"));
     while ($arItem = $dbItem->GetNext()) {
         $arPrd[] = $arItem;
     }
     if (!empty($arPrd)) {
         $arOrder = array("LID" => $arData["SITE_ID"], "PERSON_TYPE_ID" => $arData["PERSON_TYPE_ID"], "PAYED" => "N", "CANCELED" => "N", "STATUS_ID" => "N", "PRICE" => 1, "CURRENCY" => $arData["CURRENCY"], "USER_ID" => $arData["USER_ID"], "PAY_SYSTEM_ID" => $arData["PAY_SYSTEM_ID"]);
         $fuserID = 0;
         $dbFUserListTmp = CSaleUser::GetList(array("USER_ID" => $arData["USER_ID"]));
         if (empty($dbFUserListTmp)) {
             $arFields = array("=DATE_INSERT" => $DB->GetNowFunction(), "=DATE_UPDATE" => $DB->GetNowFunction(), "USER_ID" => $arData["USER_ID"]);
             $fuserID = CSaleUser::_Add($arFields);
         } else {
             $fuserID = $dbFUserListTmp['ID'];
         }
         $orderID = CSaleOrder::Add($arOrder);
         CCatalogProduct::setPriceVatIncludeMode(true);
         CCatalogProduct::setUsedCurrency(CSaleLang::GetLangCurrency(WIZARD_SITE_ID));
         CCatalogProduct::setUseDiscount(true);
         for ($i = 0; $i < $prdCnt; $i++) {
             $prdID = $arPrd[mt_rand(20, 99)];
             $arProduct = CCatalogProduct::GetByID($prdID["ID"]);
             $arPrice = CCatalogProduct::GetOptimalPrice($prdID["ID"], 1, array(2), 'N', array(), WIZARD_SITE_ID, array());
             $arFields = array("IGNORE_CALLBACK_FUNC" => "Y", "PRODUCT_ID" => $prdID["ID"], "PRODUCT_PRICE_ID" => $arPrice['PRICE']['ID'], "BASE_PRICE" => $arPrice['RESULT_PRICE']['BASE_PRICE'], "PRICE" => $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'], "VAT_RATE" => $arPrice['PRICE']['VAT_RATE'], "CURRENCY" => $arPrice['RESULT_PRICE']['CURRENCY'], "WEIGHT" => $arProduct["WEIGHT"], "DIMENSIONS" => serialize(array("WIDTH" => $arProduct["WIDTH"], "HEIGHT" => $arProduct["HEIGHT"], "LENGTH" => $arProduct["LENGTH"])), "QUANTITY" => 1, "LID" => WIZARD_SITE_ID, "DELAY" => "N", "CAN_BUY" => "Y", "NAME" => $prdID["NAME"], "CALLBACK_FUNC" => "", "MODULE" => "catalog", "PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider", "ORDER_CALLBACK_FUNC" => "", "CANCEL_CALLBACK_FUNC" => "", "PAY_CALLBACK_FUNC" => "", "DETAIL_PAGE_URL" => $prdID["DETAIL_PAGE_URL"], "CATALOG_XML_ID" => $prdID["IBLOCK_XML_ID"], "PRODUCT_XML_ID" => $prdID["XML_ID"], "NOTES" => $arPrice["PRICE"]["CATALOG_GROUP_NAME"], "FUSER_ID" => $fuserID, "ORDER_ID" => $orderID);
             $addres = CSaleBasket::Add($arFields);
         }
         $dbBasketItems = CSaleBasket::GetList(array(), array("ORDER_ID" => $orderID), false, false, array("ID", "QUANTITY", "PRICE"));
         $ORDER_PRICE = 0;
         while ($arBasketItems = $dbBasketItems->GetNext()) {
             $ORDER_PRICE += roundEx($arBasketItems["PRICE"], SALE_VALUE_PRECISION) * DoubleVal($arBasketItems["QUANTITY"]);
         }
         $totalOrderPrice = $ORDER_PRICE + $arData["PRICE_DELIVERY"];
         CSaleOrder::Update($orderID, array("PRICE" => $totalOrderPrice));
         foreach ($arData["PROPS"] as $val) {
             $arFields = array("ORDER_ID" => $orderID, "ORDER_PROPS_ID" => $val["ID"], "NAME" => $val["NAME"], "CODE" => $val["CODE"], "VALUE" => $val["VALUE"]);
             CSaleOrderPropsValue::Add($arFields);
         }
         return $orderID;
     }
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:46,代码来源:step1.php

示例6: DoSaveOrderBasket

 static function DoSaveOrderBasket($orderId, $siteId, $userId, &$arShoppingCart, &$arErrors, $arCoupons = array(), $arStoreBarcodeOrderFormData = array(), $bSaveBarcodes = false)
 {
     global $DB;
     if (defined("SALE_DEBUG") && SALE_DEBUG) {
         CSaleHelper::WriteToLog("DoSaveOrderBasket - Started", array("orderId" => $orderId, "siteId" => $siteId, "userId" => $userId, "bSaveBarcodes" => $bSaveBarcodes, "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData), "DSOB1");
     }
     $orderId = IntVal($orderId);
     if ($orderId <= 0) {
         return false;
     }
     if (!is_array($arShoppingCart) || count($arShoppingCart) <= 0) {
         $arErrors[] = array("CODE" => "PARAM", "TEXT" => GetMessage('SKGB_SHOPPING_CART_EMPTY'));
         return false;
     }
     $isOrderReserved = false;
     $isOrderDeducted = false;
     $dbOrderTmp = CSaleOrder::GetList(array(), array("ID" => $orderId), false, false, array("ID", "RESERVED", "DEDUCTED"));
     if ($arOrder = $dbOrderTmp->Fetch()) {
         if ($arOrder["RESERVED"] == "Y") {
             $isOrderReserved = true;
         }
         if ($arOrder["DEDUCTED"] == "Y") {
             $isOrderDeducted = true;
         }
     }
     $arOldItems = array();
     $dbResult = CSaleBasket::GetList(array(), array("ORDER_ID" => $orderId), false, false, array("ID", "QUANTITY", "CANCEL_CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "PRODUCT_PROVIDER_CLASS", "RESERVED", "RESERVE_QUANTITY"));
     while ($arResult = $dbResult->Fetch()) {
         $arOldItems[$arResult["ID"]] = array("QUANTITY" => $arResult["QUANTITY"], "CANCEL_CALLBACK_FUNC" => $arResult["CANCEL_CALLBACK_FUNC"], "PRODUCT_PROVIDER_CLASS" => $arResult["PRODUCT_PROVIDER_CLASS"], "MODULE" => $arResult["MODULE"], "PRODUCT_ID" => $arResult["PRODUCT_ID"], "RESERVED" => $arResult["RESERVED"], "RESERVE_QUANTITY" => $arResult["RESERVE_QUANTITY"]);
     }
     if (is_array($arCoupons) && count($arCoupons) > 0) {
         foreach (GetModuleEvents("sale", "OnSetCouponList", true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array($userId, $arCoupons, array()));
         }
     }
     $FUSER_ID = 0;
     $arFUserListTmp = CSaleUser::GetList(array("USER_ID" => $userId));
     if (empty($arFUserListTmp)) {
         $arFields = array("=DATE_INSERT" => $DB->GetNowFunction(), "=DATE_UPDATE" => $DB->GetNowFunction(), "USER_ID" => $userId);
         $FUSER_ID = CSaleUser::_Add($arFields);
     } else {
         $FUSER_ID = $arFUserListTmp["ID"];
     }
     foreach ($arShoppingCart as $id => &$arItem) {
         if (defined("SALE_DEBUG") && SALE_DEBUG) {
             CSaleHelper::WriteToLog("DoSaveOrderBasket - Item", array("arItem" => $arItem), "DSOB2");
         }
         if (array_key_exists("ID", $arItem) && intval($arItem["ID"]) > 0) {
             $arItem["ID"] = intval($arItem["ID"]);
             if (defined("SALE_DEBUG") && SALE_DEBUG) {
                 CSaleHelper::WriteToLog("DoSaveOrderBasket - Product #" . $arItem["ID"] . " already in the basket", array(), "DSOB3");
             }
             //product already in the basket, change quantity
             if (array_key_exists($arItem["ID"], $arOldItems)) {
                 if ($arOldItems[$arItem["ID"]]["QUANTITY"] - $arItem["QUANTITY"] != 0) {
                     self::DoChangeProductQuantity($arItem, $arItem["QUANTITY"] - $arOldItems[$arItem["ID"]]["QUANTITY"], $isOrderReserved, $isOrderDeducted, $arStoreBarcodeOrderFormData[$arItem["ID"]], array("ORDER_ID" => $orderId, "USER_ID" => $userId, "SITE_ID" => $siteId));
                 }
                 unset($arOldItems[$arItem["ID"]]);
             } else {
                 if ($arItem["QUANTITY"] != 0) {
                     self::DoChangeProductQuantity($arItem, $arItem["QUANTITY"], $isOrderReserved, $isOrderDeducted, $arStoreBarcodeOrderFormData[$arItem["ID"]], array("ORDER_ID" => $orderId, "USER_ID" => $userId, "SITE_ID" => $siteId));
                 }
             }
             $arFuserItems = CSaleUser::GetList(array("USER_ID" => intval($userId)));
             $arItem["FUSER_ID"] = $arFuserItems["ID"];
             //CSaleBasket::Update($arItem["ID"], array("CALLBACK_FUNC" => false, "ORDER_ID" => $orderId, "IGNORE_CALLBACK_FUNC" => "Y") + $arItem);
             CSaleBasket::Update($arItem["ID"], array("ORDER_ID" => $orderId, "IGNORE_CALLBACK_FUNC" => "Y") + $arItem);
         } else {
             if (defined("SALE_DEBUG") && SALE_DEBUG) {
                 CSaleHelper::WriteToLog("DoSaveOrderBasket - new product in the basket", array(), "DSOB3");
             }
             unset($arItem["ID"]);
             /** @var $productProvider IBXSaleProductProvider */
             if ($productProvider = CSaleBasket::GetProductProvider($arItem)) {
                 $arItem["ID"] = CSaleBasket::Add(array("ORDER_ID" => $orderId, "IGNORE_CALLBACK_FUNC" => "Y") + $arItem);
                 if ($bSaveBarcodes) {
                     if ($arItem["BARCODE_MULTI"] == "N") {
                         foreach ($arItem["STORES"] as $key => $arStore) {
                             $arStoreBarcodeFields = array("BASKET_ID" => $arItem["ID"], "BARCODE" => "", "STORE_ID" => $arStore["STORE_ID"], "QUANTITY" => $arStore["QUANTITY"], "CREATED_BY" => intval($GLOBALS["USER"]->GetID()) > 0 ? IntVal($GLOBALS["USER"]->GetID()) : "", "MODIFIED_BY" => intval($GLOBALS["USER"]->GetID()) > 0 ? IntVal($GLOBALS["USER"]->GetID()) : "");
                             CSaleStoreBarcode::Add($arStoreBarcodeFields);
                         }
                     } else {
                         if (is_array($arItem["STORES"]) && count($arItem["STORES"]) > 0) {
                             foreach ($arItem["STORES"] as $key => $arStore) {
                                 if (isset($arStore["BARCODE"]) && isset($arStore["BARCODE_FOUND"])) {
                                     foreach ($arStore["BARCODE"] as $barcodeId => $barcodeValue) {
                                         // save only non-empty and valid barcodes TODO - if errors?
                                         if (strlen($barcodeValue) > 0 && $arStore["BARCODE_FOUND"][$barcodeId] == "Y") {
                                             $arStoreBarcodeFields = array("BASKET_ID" => $arItem["ID"], "BARCODE" => $barcodeValue, "STORE_ID" => $arStore["STORE_ID"], "QUANTITY" => 1, "CREATED_BY" => intval($GLOBALS["USER"]->GetID()) > 0 ? IntVal($GLOBALS["USER"]->GetID()) : "", "MODIFIED_BY" => intval($GLOBALS["USER"]->GetID()) > 0 ? IntVal($GLOBALS["USER"]->GetID()) : "");
                                             CSaleStoreBarcode::Add($arStoreBarcodeFields);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($arItem["QUANTITY"] != 0) {
                     self::DoChangeProductQuantity($arItem, $arItem["QUANTITY"], $isOrderReserved, $isOrderDeducted, $arStoreBarcodeOrderFormData[$id], array("ORDER_ID" => $orderId, "USER_ID" => $userId, "SITE_ID" => $siteId));
                 }
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:basket.php


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