本文整理汇总了PHP中CSaleBasket::GetProductProvider方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleBasket::GetProductProvider方法的具体用法?PHP CSaleBasket::GetProductProvider怎么用?PHP CSaleBasket::GetProductProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleBasket
的用法示例。
在下文中一共展示了CSaleBasket::GetProductProvider方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isBarCodeValid
public static function isBarCodeValid($arParams)
{
$bResult = false;
$arBasket = array();
if (intval($arParams["basketItemId"]) > 0) {
$dbBasket = CSaleBasket::GetList(array("ID" => "DESC"), array("ID" => $arParams["basketItemId"]), false, false, array("ID", "PRODUCT_ID", "PRODUCT_PROVIDER_CLASS", "MODULE", "BARCODE_MULTI"));
$arBasket = $dbBasket->GetNext();
} else {
$arBasket = array("PRODUCT_PROVIDER_CLASS" => $arParams["productProvider"], "MODULE" => $arParams["moduleName"], "PRODUCT_ID" => $arParams["productId"], "BARCODE_MULTI" => $arParams["barcodeMult"]);
}
if (!empty($arBasket) && is_array($arBasket)) {
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) {
$arCheckBarcodeFields = array("BARCODE" => $arParams["barcode"], "PRODUCT_ID" => $arBasket["PRODUCT_ID"], "ORDER_ID" => $arParams["orderId"]);
if ($arBasket["BARCODE_MULTI"] == "Y") {
$arCheckBarcodeFields["STORE_ID"] = $arParams["storeId"];
}
$res = $productProvider::CheckProductBarcode($arCheckBarcodeFields);
if ($res) {
$bResult = true;
}
}
}
return $bResult;
}
示例2: getProductById
/**
* Wraps Product Provider Class::GetProductData from module catalog.
* @param int $productId Product Id.
* @param int $quantity Product quantity.
* @param string $siteId Site id.
* @return array.
* @throws \Bitrix\Main\SystemException
*/
public static function getProductById($productId, $quantity, $siteId)
{
$result = array();
if (\CModule::IncludeModule('catalog')) {
if ($productProvider = \CSaleBasket::GetProductProvider(array("MODULE" => "catalog", "PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider"))) {
global $USER;
$bTmpUserCreated = false;
if (!\CCatalog::IsUserExists()) {
$bTmpUserCreated = true;
if (isset($USER)) {
$USER_TMP = $USER;
unset($USER);
}
$USER = new \CUser();
}
$result = $productProvider::GetProductData(array("PRODUCT_ID" => $productId, "RENEWAL" => "N", "QUANTITY" => $quantity, "SITE_ID" => $siteId));
$result["MODULE"] = "catalog";
$result["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
$dbIblockElement = \CIBlockElement::GetList(array(), array("ID" => $productId), false, false, array('XML_ID', 'IBLOCK_EXTERNAL_ID'));
if ($IblockElement = $dbIblockElement->Fetch()) {
if (strlen($IblockElement["XML_ID"]) > 0) {
$result["PRODUCT_XML_ID"] = $IblockElement["XML_ID"];
}
if (strlen($IblockElement["IBLOCK_EXTERNAL_ID"]) > 0) {
$result["CATALOG_XML_ID"] = $IblockElement["IBLOCK_EXTERNAL_ID"];
}
}
if ($bTmpUserCreated) {
unset($USER);
if (isset($USER_TMP)) {
$USER = $USER_TMP;
unset($USER_TMP);
}
}
}
} else {
throw new \Bitrix\Main\SystemException("Can't include module \"Catalog\"!");
}
return $result;
}
示例3: CurrencyFormatNumber
$arPrice["PRICE"]["CURRENCY"] = $BASE_LANG_CURR;
}
$currentTotalPriceFormat = CurrencyFormatNumber($currentTotalPrice, $arPrice["PRICE"]["CURRENCY"]);
$summaFormated = CurrencyFormatNumber($currentPrice * $QUANTITY, $arPrice["PRICE"]["CURRENCY"]);
} else {
$currentTotalPriceFormat = CurrencyFormatNumber($currentTotalPrice, $arPrice["PRICE"]["CURRENCY"]);
$summaFormated = CurrencyFormatNumber($currentPrice * $QUANTITY, $arPrice["PRICE"]["CURRENCY"]);
}
$urlEdit = "/bitrix/admin/iblock_element_edit.php?ID=" . $arItems["ID"] . "&type=" . $arItems["IBLOCK_TYPE_ID"] . "&lang=" . LANG . "&IBLOCK_ID=" . $arItems["IBLOCK_ID"] . "&find_section_section=" . $arItems["IBLOCK_SECTION_ID"];
$bCanBuy = true;
if ($arCatalogProduct["CAN_BUY_ZERO"] != "Y" && ($arCatalogProduct["QUANTITY_TRACE"] == "Y" && doubleval($arCatalogProduct["QUANTITY"]) <= 0)) {
$bCanBuy = false;
}
$arStores = array();
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => "catalog", "PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider"))) {
$arStores = $productProvider::GetProductStores(array("PRODUCT_ID" => $arItems["ID"]));
}
if ($addDefault == "Y" || $bCanBuy && $addDefault == "N") {
$arParams = "{'id' : '" . $arItems["ID"] . "',\n\t\t\t\t'name' : '" . CUtil::JSEscape($arItems["NAME"]) . "',\n\t\t\t\t'url' : '" . CUtil::JSEscape($URL) . "',\n\t\t\t\t'urlEdit' : '" . CUtil::JSEscape($urlEdit) . "',\n\t\t\t\t'urlImg' : '" . CUtil::JSEscape($ImgUrl) . "',\n\t\t\t\t'price' : '" . CUtil::JSEscape($currentPrice) . "',\n\t\t\t\t'priceFormated' : '" . CUtil::JSEscape(CurrencyFormatNumber($currentPrice, $arPrice["PRICE"]["CURRENCY"])) . "',\n\t\t\t\t'valutaFormat' : '" . CUtil::JSEscape($priceValutaFormat) . "',\n\t\t\t\t'priceDiscount' : '" . CUtil::JSEscape($currentDiscount) . "',\n\t\t\t\t'priceBase' : '" . CUtil::JSEscape($currentBasePrice) . "',\n\t\t\t\t'priceBaseFormat' : '" . CUtil::JSEscape(CurrencyFormatNumber($currentBasePrice, $arPrice["PRICE"]["CURRENCY"])) . "',\n\t\t\t\t'discountPercent' : '" . CUtil::JSEscape($discountPercent) . "',\n\t\t\t\t'summaFormated' : '" . CUtil::JSEscape($summaFormated) . "',\n\t\t\t\t'quantity' : '" . CUtil::JSEscape($QUANTITY) . "',\n\t\t\t\t'module' : 'catalog',\n\t\t\t\t'currency' : '" . CUtil::JSEscape($arPrice["PRICE"]["CURRENCY"]) . "',\n\t\t\t\t'weight' : '" . DoubleVal($arCatalogProduct["WEIGHT"]) . "',\n\t\t\t\t'vatRate' : '" . DoubleVal($vatRate) . "',\n\t\t\t\t'priceType' : '" . CUtil::JSEscape($PriceType) . "',\n\t\t\t\t'balance' : '" . CUtil::JSEscape($balance) . "',\n\t\t\t\t'catalogXmlID' : '" . CUtil::JSEscape($arIBlock["XML_ID"]) . "',\n\t\t\t\t'productXmlID' : '" . CUtil::JSEscape($arItems["XML_ID"]) . "',\n\t\t\t\t'barcodeMulti' : '" . CUtil::JSEscape($arCatalogProduct["BARCODE_MULTI"]) . "',\n\t\t\t\t'stores' : '" . CUtil::JSEscape(CUtil::PhpToJSObject($arStores)) . "',\n\t\t\t\t'orderCallback' : '', 'cancelCallback' : '', 'payCallback' : '', 'callback' : '','productProviderClass' : 'CCatalogProductProvider'}";
// 'callback' : 'CatalogBasketCallback',
// 'orderCallback' : 'CatalogBasketOrderCallback',
// 'cancelCallback' : 'CatalogBasketCancelCallback',
// 'payCallback' : 'CatalogPayOrderCallback',
foreach (GetModuleEvents("sale", "OnProductSearchForm", true) as $arEvent) {
$arParams = ExecuteModuleEventEx($arEvent, array($arItems["ID"], $arParams));
}
$arParams = "var el" . $arItems["ID"] . " = " . $arParams;
$act = "<script>" . $arParams . "</script><input type='button' onClick=\"SelEl(el" . $arItems["ID"] . ", " . $arItems["ID"] . ")\" name='btn_select_" . $arItems["ID"] . "' id='btn_select_" . $arItems["ID"] . "' value='" . GetMessage("SPS_SELECT") . "' >";
$countField = "<input type=\"text\" name=\"quantity_" . $arItems["ID"] . "\" id=\"quantity_" . $arItems["ID"] . "\" value=\"1\" size=\"3\" >";
$active = GetMEssage('SPS_PRODUCT_ACTIVE');
示例4: Add2BasketByProductID
/**
* @param int $PRODUCT_ID
* @param float|int $QUANTITY
* @param array $arRewriteFields
* @param bool|array $arProductParams
* @return bool|int
*/
function Add2BasketByProductID($PRODUCT_ID, $QUANTITY = 1, $arRewriteFields = array(), $arProductParams = false)
{
global $APPLICATION;
/* for old use */
if ($arProductParams === false) {
$arProductParams = $arRewriteFields;
$arRewriteFields = array();
}
$boolRewrite = !empty($arRewriteFields) && is_array($arRewriteFields);
if ($boolRewrite && isset($arRewriteFields['SUBSCRIBE']) && $arRewriteFields['SUBSCRIBE'] == 'Y') {
return SubscribeProduct($PRODUCT_ID, $arRewriteFields, $arProductParams);
}
$PRODUCT_ID = (int) $PRODUCT_ID;
if ($PRODUCT_ID <= 0) {
$APPLICATION->ThrowException(Loc::getMessage('CATALOG_ERR_EMPTY_PRODUCT_ID'), "EMPTY_PRODUCT_ID");
return false;
}
$QUANTITY = (double) $QUANTITY;
if ($QUANTITY <= 0) {
$QUANTITY = 1;
}
if (!Loader::includeModule("sale")) {
$APPLICATION->ThrowException(Loc::getMessage('CATALOG_ERR_NO_SALE_MODULE'), "NO_SALE_MODULE");
return false;
}
if (Loader::includeModule("statistic") && isset($_SESSION['SESS_SEARCHER_ID']) && (int) $_SESSION["SESS_SEARCHER_ID"] > 0) {
$APPLICATION->ThrowException(Loc::getMessage('CATALOG_ERR_SESS_SEARCHER'), "SESS_SEARCHER");
return false;
}
$rsProducts = CCatalogProduct::GetList(array(), array('ID' => $PRODUCT_ID), false, false, array('ID', 'CAN_BUY_ZERO', 'QUANTITY_TRACE', 'QUANTITY', 'WEIGHT', 'WIDTH', 'HEIGHT', 'LENGTH', 'TYPE', 'MEASURE'));
if (!($arCatalogProduct = $rsProducts->Fetch())) {
$APPLICATION->ThrowException(Loc::getMessage('CATALOG_ERR_NO_PRODUCT'), "NO_PRODUCT");
return false;
}
$arCatalogProduct['MEASURE'] = (int) $arCatalogProduct['MEASURE'];
$arCatalogProduct['MEASURE_NAME'] = '';
$arCatalogProduct['MEASURE_CODE'] = 0;
if ($arCatalogProduct['MEASURE'] <= 0) {
$arMeasure = CCatalogMeasure::getDefaultMeasure(true, true);
$arCatalogProduct['MEASURE_NAME'] = $arMeasure['~SYMBOL_RUS'];
$arCatalogProduct['MEASURE_CODE'] = $arMeasure['CODE'];
} else {
$rsMeasures = CCatalogMeasure::getList(array(), array('ID' => $arCatalogProduct['MEASURE']), false, false, array('ID', 'SYMBOL_RUS', 'CODE'));
if ($arMeasure = $rsMeasures->GetNext()) {
$arCatalogProduct['MEASURE_NAME'] = $arMeasure['~SYMBOL_RUS'];
$arCatalogProduct['MEASURE_CODE'] = $arMeasure['CODE'];
}
}
$dblQuantity = (double) $arCatalogProduct["QUANTITY"];
$intQuantity = (int) $arCatalogProduct["QUANTITY"];
$boolQuantity = $arCatalogProduct["CAN_BUY_ZERO"] != 'Y' && $arCatalogProduct["QUANTITY_TRACE"] == 'Y';
if ($boolQuantity && $dblQuantity <= 0) {
$APPLICATION->ThrowException(Loc::getMessage('CATALOG_ERR_PRODUCT_RUN_OUT'), "PRODUCT_RUN_OUT");
return false;
}
$rsItems = CIBlockElement::GetList(array(), array("ID" => $PRODUCT_ID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSIONS" => "Y", "MIN_PERMISSION" => "R"), false, false, array("ID", "IBLOCK_ID", "XML_ID", "NAME", "DETAIL_PAGE_URL"));
if (!($arProduct = $rsItems->GetNext())) {
$APPLICATION->ThrowException(Loc::getMessage('CATALOG_ERR_NO_IBLOCK_ELEMENT'), "NO_IBLOCK_ELEMENT");
return false;
}
$strCallbackFunc = "";
$strProductProviderClass = "CCatalogProductProvider";
if ($boolRewrite) {
if (isset($arRewriteFields['CALLBACK_FUNC'])) {
$strCallbackFunc = $arRewriteFields['CALLBACK_FUNC'];
}
if (isset($arRewriteFields['PRODUCT_PROVIDER_CLASS'])) {
$strProductProviderClass = $arRewriteFields['PRODUCT_PROVIDER_CLASS'];
}
}
$arCallbackPrice = false;
if (!empty($strProductProviderClass)) {
if ($productProvider = CSaleBasket::GetProductProvider(array('MODULE' => 'catalog', 'PRODUCT_PROVIDER_CLASS' => $strProductProviderClass))) {
$providerParams = array('PRODUCT_ID' => $PRODUCT_ID, 'QUANTITY' => $QUANTITY, 'RENEWAL' => 'N');
$arCallbackPrice = $productProvider::GetProductData($providerParams);
unset($providerParams);
}
} elseif (!empty($strCallbackFunc)) {
$arCallbackPrice = CSaleBasket::ExecuteCallbackFunction($strCallbackFunc, 'catalog', $PRODUCT_ID, $QUANTITY, 'N');
}
if (empty($arCallbackPrice) || !is_array($arCallbackPrice)) {
$APPLICATION->ThrowException(Loc::getMessage('CATALOG_PRODUCT_PRICE_NOT_FOUND'), "NO_PRODUCT_PRICE");
return false;
}
$arProps = array();
$strIBlockXmlID = (string) CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'XML_ID');
if ($strIBlockXmlID !== '') {
$arProps[] = array('NAME' => 'Catalog XML_ID', 'CODE' => 'CATALOG.XML_ID', 'VALUE' => $strIBlockXmlID);
}
// add sku props
$arParentSku = CCatalogSku::GetProductInfo($PRODUCT_ID, $arProduct['IBLOCK_ID']);
if (!empty($arParentSku)) {
if (strpos($arProduct["~XML_ID"], '#') === false) {
//.........这里部分代码省略.........
示例5: getProductById
protected function getProductById($productId, $quantity)
{
$arResult = array();
if (CModule::IncludeModule('catalog')) {
if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => "catalog", "PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider"))) {
$arResult = $productProvider::GetProductData(array("PRODUCT_ID" => $productId, "RENEWAL" => "N", "QUANTITY" => $quantity, "SITE_ID" => $this->siteId));
}
} else {
$arResult = $this->processError(self::ERROR_STATUS_500, GetMessage("SALE_YMH_ERROR_CATALOG_NOT_INSTALLED"));
}
return $arResult;
}
示例6: 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;
}
示例7: OrderDeduction
/**
* Method is called to deduct all products of the order
*
* @param int $orderID
* @param bool $bUndoReservation
* @return mixed array
*/
function OrderDeduction($orderID, $bReturn = false, $recurringID = 0, $bAutoDeduction = true, $arStoreBarcodeOrderFormData = array())
{
global $DB;
static $storesCount = NULL;
static $bAutoDeductionAllowed = NULL;
$bRealDeductionAllowed = true;
$arSavedStoreBarcodeData = array();
$arItems = array();
$arResult = array();
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("OrderDeduction: started", array("orderID" => $orderID, "bReturn" => intval($bReturn), "bAutoDeduction" => intval($bAutoDeduction), "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData), "OD1");
}
//TODO - recurringID - ?
$orderID = IntVal($orderID);
if ($orderID <= 0) {
$arResult["RESULT"] = false;
return $arResult;
}
$dbBasketList = CSaleBasket::GetList(array(), array("ORDER_ID" => $orderID), false, false, array('ID', 'PRODUCT_ID', 'PRODUCT_PROVIDER_CLASS', 'MODULE', 'BARCODE_MULTI', 'QUANTITY', 'RESERVED'));
//check and emulate deduction
while ($arBasket = $dbBasketList->Fetch()) {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Deducting product #" . $arBasket["PRODUCT_ID"], array(), "OD2");
}
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) {
if (is_null($storesCount)) {
$storesCount = intval($productProvider::GetStoresCount());
}
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("stores count: " . $storesCount, array(), "OD3");
}
if (is_null($bAutoDeductionAllowed)) {
if ($storesCount == 1 || $storesCount == -1) {
// if stores' count = 1 or stores aren't used
$bAutoDeductionAllowed = true;
} else {
$bAutoDeductionAllowed = false;
}
}
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("auto deduction allowed: " . intval($bAutoDeductionAllowed), array(), "OD4");
}
if ($bAutoDeduction && !$bAutoDeductionAllowed && !$bReturn) {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("DDCT_AUTO_DEDUCT_WRONG_STORES_QUANTITY", array(), "OD5");
}
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("DDCT_AUTO_DEDUCT_WRONG_STORES_QUANTITY"), "DDCT_WRONG_STORES_QUANTITY");
$bRealDeductionAllowed = false;
} else {
if ($bAutoDeduction && $arBasket["BARCODE_MULTI"] == "Y" && !$bReturn) {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("DDCT_AUTO_DEDUCT_BARCODE_MULTI", array(), "OD6");
}
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("DDCT_AUTO_DEDUCT_BARCODE_MULTI", array("#PRODUCT_ID#" => $arBasket["PRODUCT_ID"])), "DDCT_CANT_DEDUCT_BARCODE_MULTI");
$bRealDeductionAllowed = false;
} else {
//get saved store & barcode data if stores are used to know where to return products
if ($bReturn && $storesCount > 0) {
$dbStoreBarcode = CSaleStoreBarcode::GetList(array(), array("BASKET_ID" => $arBasket["ID"]), false, false, array("ID", "BASKET_ID", "BARCODE", "QUANTITY", "STORE_ID"));
while ($arStoreBarcode = $dbStoreBarcode->Fetch()) {
$arSavedStoreBarcodeData[$arBasket["ID"]][] = $arStoreBarcode;
}
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("OrderDeduction: CSaleStoreBarcode data (stores) to return products to", array("arSavedStoreBarcodeData" => $arSavedStoreBarcodeData), "OD7");
}
}
$arFields = array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "EMULATE" => "Y", "PRODUCT_RESERVED" => $arBasket["RESERVED"], "UNDO_DEDUCTION" => $bReturn ? "Y" : "N");
if ($bReturn) {
if ($storesCount > 0) {
$arFields["QUANTITY"] = 0;
//won't be used during deduction
$arFields["STORE_DATA"] = $arSavedStoreBarcodeData[$arBasket["ID"]];
} else {
$arFields["QUANTITY"] = $arBasket["QUANTITY"];
$arFields["STORE_DATA"] = array();
}
} else {
if ($storesCount == 1) {
$arFields["QUANTITY"] = 0;
if ($bAutoDeduction) {
if ($arProductStore = $productProvider::GetProductStores(array("PRODUCT_ID" => $arBasket["PRODUCT_ID"]))) {
$arFields["STORE_DATA"] = array("0" => array("STORE_ID" => $arProductStore[0]["STORE_ID"], "QUANTITY" => $arBasket["QUANTITY"], "AMOUNT" => $arProductStore[0]["AMOUNT"]));
} else {
$arFields["STORE_DATA"] = array();
}
} else {
$arFields["STORE_DATA"] = $arStoreBarcodeOrderFormData[$arBasket["ID"]];
}
} else {
if ($storesCount > 1) {
$arFields["QUANTITY"] = 0;
//won't be used during deduction
//.........这里部分代码省略.........
示例8: array
$weight = 0;
$price = 0;
$price_total = 0;
$arProdIds = array();
//http://jabber.bx/view.php?id=37744
$arProdIdsPrIds = array();
$useStores = false;
while ($arBasket = $dbBasket->Fetch()) {
$arProdIds[] = $arBasket["PRODUCT_ID"];
$arProdIdsPrIds[$arBasket["PRODUCT_ID"]] = $arBasket["ID"];
$arBasket["BALANCE"] = "0";
$arBasket["STORES"] = array();
$arBasket["HAS_SAVED_QUANTITY"] = "N";
$arBasket["HAS_SAVED_BARCODES"] = false;
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) {
$storeCount = $productProvider::GetStoresCount(array("SITE_ID" => $LID));
if ($storeCount > 0) {
if ($arProductStore = $productProvider::GetProductStores(array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "SITE_ID" => $LID, 'BASKET_ID' => $arBasket['ID']))) {
foreach ($arProductStore as $arStore) {
$arBasket["STORES"][$arStore["STORE_ID"]] = $arStore;
}
if (!$useStores && $storeCount != -1) {
$useStores = true;
}
// if barcodes/store quantity are already saved for this product,
// then check if barcodes are still valid and save them to the store array
$ind = 0;
$dbres = CSaleStoreBarcode::GetList(array(), array("BASKET_ID" => $arBasket["ID"]), false, false, array("ID", "BASKET_ID", "BARCODE", "STORE_ID", "ORDER_ID", "QUANTITY", "DEDUCTED"));
while ($arRes = $dbres->GetNext()) {
$arCheckBarcodeFields = array("BARCODE" => $arRes["BARCODE"], "PRODUCT_ID" => $arBasket["PRODUCT_ID"], "ORDER_ID" => $arParams["ORDER_ID"]);
示例9: UpdateBasketPrices
function UpdateBasketPrices($fuserID, $siteID)
{
$fuserID = intval($fuserID);
if (0 >= $fuserID)
return false;
if(strlen($siteID) <= 0)
$siteID = SITE_ID;
$dbBasketItems = CSaleBasket::GetList(
array("ALL_PRICE" => "DESC"),
array(
"FUSER_ID" => $fuserID,
"LID" => $siteID,
"ORDER_ID" => "NULL",
"SUBSCRIBE" => "N"
),
false,
false,
array("ID", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "PRODUCT_PROVIDER_CLASS", "CAN_BUY", "DELAY", "NOTES")
);
while ($arItem = $dbBasketItems->Fetch())
{
$arFields = false;
$arItem['CALLBACK_FUNC'] = strval($arItem['CALLBACK_FUNC']);
$arItem['PRODUCT_PROVIDER_CLASS'] = strval($arItem['PRODUCT_PROVIDER_CLASS']);
if ('' != $arItem['PRODUCT_PROVIDER_CLASS'] || '' != $arItem['CALLBACK_FUNC'])
{
$arItem["MODULE"] = strval($arItem["MODULE"]);
$arItem['PRODUCT_ID'] = intval($arItem['PRODUCT_ID']);
$arItem['QUANTITY'] = floatval($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'),
"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))
{
$arFields["CAN_BUY"] = "Y";
}
else
{
$arFields = array('CAN_BUY' => 'N');
}
CSaleBasket::Update($arItem['ID'], $arFields);
}
}
}
示例10: getProductDataToFillBasket
//.........这里部分代码省略.........
$dbratio = \CCatalogMeasureRatio::GetList(array(), array("PRODUCT_ID" => $productId));
if ($arRatio = $dbratio->Fetch()) {
$proxyCatalogMeasureRatio[$productId] = $arRatio;
}
}
if (!empty($arRatio) && is_array($arRatio)) {
$arElementInfo["RATIO"] = $arRatio["RATIO"];
}
// image
$imgCode = '';
$imgUrl = '';
if ($arElementInfo["PREVIEW_PICTURE"] > 0) {
$imgCode = $arElementInfo["PREVIEW_PICTURE"];
} elseif ($arElementInfo["DETAIL_PICTURE"] > 0) {
$imgCode = $arElementInfo["DETAIL_PICTURE"];
}
if ($imgCode == "" && count($arParent) > 0) {
if ($arParent["PREVIEW_PICTURE"] > 0) {
$imgCode = $arParent["PREVIEW_PICTURE"];
} elseif ($arParent["DETAIL_PICTURE"] > 0) {
$imgCode = $arParent["DETAIL_PICTURE"];
}
}
if ($imgCode > 0) {
$arFile = \CFile::GetFileArray($imgCode);
$arImgProduct = \CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
if (is_array($arImgProduct)) {
$imgUrl = $arImgProduct["src"];
}
}
$arSetInfo = array();
$arStores = array();
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = \CSaleBasket::GetProductProvider(array("MODULE" => $arElementInfo["MODULE"], "PRODUCT_PROVIDER_CLASS" => $arElementInfo["PRODUCT_PROVIDER_CLASS"]))) {
// get set items if it is set
if ($arProduct["TYPE"] == \CCatalogProduct::TYPE_SET) {
if (method_exists($productProvider, "GetSetItems")) {
$arSets = $productProvider::GetSetItems($productId, \CSaleBasket::TYPE_SET);
if ($tmpId == "") {
$tmpId = randString(7);
}
if (!empty($arSets)) {
foreach ($arSets as $arSetData) {
foreach ($arSetData["ITEMS"] as $setItem) {
$arSetItemParams = self::getProductDataToFillBasket($setItem["PRODUCT_ID"], $setItem["QUANTITY"], $userId, $LID, $userColumns, $tmpId);
// recursive call
// re-define some fields with set data values
$arSetItemParams["PARENT_OFFER_ID"] = $productId;
$arSetItemParams["OFFER_ID"] = $setItem["PRODUCT_ID"];
$arSetItemParams["NAME"] = $setItem["NAME"];
$arSetItemParams["MODULE"] = $setItem["MODULE"];
$arSetItemParams["PRODUCT_PROVIDER_CLASS"] = $setItem["PRODUCT_PROVIDER_CLASS"];
$arSetItemParams["QUANTITY"] = $setItem["QUANTITY"] * $quantity;
$arSetItemParams["BARCODE_MULTI"] = $setItem["BARCODE_MULTI"];
$arSetItemParams["PRODUCT_TYPE"] = $setItem["TYPE"];
$arSetItemParams["WEIGHT"] = $setItem["WEIGHT"];
$arSetItemParams["VAT_RATE"] = $setItem["VAT_RATE"];
$arSetItemParams["SET_ITEMS"] = "";
$arSetItemParams["OLD_PARENT_ID"] = $productId . "_tmp" . $tmpId;
$arSetItemParams["IS_SET_ITEM"] = "Y";
$arSetItemParams["IS_SET_PARENT"] = "N";
$arSetItemParams["PROVIDER_DATA"] = serialize($setItem);
$arSetInfo[] = $arSetItemParams;
}
}
}
示例11: array
if (!isset($_REQUEST["by"])) {
$arViewSort = array("DATE_VISIT" => SORT_DESC);
} else {
$arViewSort[$_REQUEST["by"]] = $_REQUEST["order"] == "asc" ? SORT_ASC : SORT_DESC;
}
Bitrix\Main\Type\Collection::sortByColumn($arViewsData, $arViewSort);
foreach ($arViewsData as $arViews) {
$row =& $lAdmin_tab5->AddRow($arViews["PRODUCT_ID"], $arViews, '', '');
$name = "[" . $arViews["PRODUCT_ID"] . "] <a href=\"" . $arViews["DETAIL_PAGE_URL"] . "\">" . $arViews["NAME"] . "</a>";
if (floatVal($arViews["PRICE"]) <= 0) {
$name .= "<div class=\"dont_can_buy\">(" . GetMessage('BUYER_DONT_CAN_BUY') . ")</div>";
}
$name .= "<input type=\"hidden\" name=\"table_id\" value=\"" . $sTableID_tab5 . "\">";
// get set items
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arViews)) {
if (method_exists($productProvider, "GetSetItems")) {
$arSets = $productProvider::GetSetItems($arViews["PRODUCT_ID"], CSaleBasket::TYPE_SET);
if (!empty($arSets)) {
$name .= "<br/><a href=\"javascript:void(0);\" class=\"dashed-link show-set-link\" id=\"set_toggle_link_b3" . $arBasket["ID"] . "\" onclick=\"fToggleSetItems('b3" . $arBasket["ID"] . "', 'set_toggle_link_');\">" . GetMessage("BUYER_F_SHOW_SET") . "</a><br/>";
$name .= "<div class=\"set_item_b3" . $arBasket["ID"] . "\" style=\"display:none\">";
foreach ($arSets as $arSetData) {
foreach ($arSetData["ITEMS"] as $setItem) {
$name .= "<br/>[" . $setItem["ITEM_ID"] . "] <a style=\"font-style: italic\" href=" . $setItem["DETAIL_PAGE_URL"] . ">" . $setItem["NAME"] . "</a>";
}
}
$name .= "</div>";
}
}
}
$row->AddField("NAME", $name);
示例12: getProductByProps
array("ID" => $arItem["PRODUCT_ID"]),
false,
false,
$arSelect
);
if ($arElement = $dbRes->Fetch())
{
$bBasketUpdate = false;
$arPropsValues["CML2_LINK"] = $arElement["PROPERTY_CML2_LINK_VALUE"];
$newProductId = getProductByProps($arElement["IBLOCK_ID"], $arPropsValues);
if ($newProductId > 0)
{
if ($productProvider = CSaleBasket::GetProductProvider($arItem))
{
$arFieldsTmp = $productProvider::GetProductData(array(
"PRODUCT_ID" => $newProductId,
"QUANTITY" => $arItem['QUANTITY'],
"RENEWAL" => "N",
"USER_ID" => $USER->GetID(),
"SITE_ID" => SITE_ID,
"BASKET_ID" => $arItem['ID'],
"CHECK_QUANTITY" => "Y",
"CHECK_PRICE" => "Y",
"NOTES" => $arItem["NOTES"]
));
}
elseif (isset($arItem["CALLBACK_FUNC"]) && !empty($arItem["CALLBACK_FUNC"]))
{
示例13: Add
//.........这里部分代码省略.........
* //если не получается создать покупателя - то тут уж ничего не поделаешь
* if(!$FUSER_ID['ID']){
* echo "Error while creating SaleUser";
* die();
* }
* $FUSER_ID=$FUSER_ID['ID'];
* //теперь переменную $FUSER_ID можно использовать для добавления товаров в корзину пользователя с $userId.
*
*
* Смотрите также:
*
* <li><a href="/api_help/catalog/interface.php">Взаимодействие торгового каталога и магазина</a></li>
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalebasket/csalebasket__add.php
* @author Bitrix
*/
public static function Add($arFields)
{
global $DB, $APPLICATION;
if (isset($arFields["ID"])) {
unset($arFields["ID"]);
}
$isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N');
CSaleBasket::Init();
if (!CSaleBasket::CheckFields("ADD", $arFields)) {
return false;
}
if (!array_key_exists('IGNORE_CALLBACK_FUNC', $arFields) || 'Y' != $arFields['IGNORE_CALLBACK_FUNC']) {
if (array_key_exists("CALLBACK_FUNC", $arFields) && !empty($arFields["CALLBACK_FUNC"]) || array_key_exists("PRODUCT_PROVIDER_CLASS", $arFields) && !empty($arFields["PRODUCT_PROVIDER_CLASS"])) {
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => $arFields["MODULE"], "PRODUCT_PROVIDER_CLASS" => $arFields["PRODUCT_PROVIDER_CLASS"]))) {
$providerParams = array("PRODUCT_ID" => $arFields["PRODUCT_ID"], "QUANTITY" => $arFields["QUANTITY"], "RENEWAL" => $arFields["RENEWAL"], "USER_ID" => isset($arFields["USER_ID"]) ? $arFields["USER_ID"] : 0, "SITE_ID" => isset($arFields["LID"]) ? $arFields["LID"] : false);
if (isset($arFields['NOTES'])) {
$providerParams['NOTES'] = $arFields['NOTES'];
}
if (!$productProvider::GetProductData($providerParams)) {
return false;
}
} else {
if (!CSaleBasket::ExecuteCallbackFunction($arFields["CALLBACK_FUNC"], $arFields["MODULE"], $arFields["PRODUCT_ID"], $arFields["QUANTITY"], $arFields["RENEWAL"], $arFields["USER_ID"], $arFields["LID"])) {
return false;
}
}
}
}
if ($isOrderConverted != "Y") {
foreach (GetModuleEvents("sale", "OnBeforeBasketAdd", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array(&$arFields)) === false) {
return false;
}
}
}
$bFound = false;
$bEqAr = false;
//TODO: is order converted?
if ($isOrderConverted == "Y") {
/** @var \Bitrix\Sale\BasketItem $basketItem */
if (!($basketItem = \Bitrix\Sale\Compatible\BasketCompatibility::add($arFields))) {
$APPLICATION->ThrowException(Localization\Loc::getMessage('BT_MOD_SALE_BASKET_ERR_ID_ABSENT'), "BASKET_ITEM");
return false;
}
$ID = $basketItem->getId();
$arFields['QUANTITY'] = $basketItem->getQuantity();
示例14: 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;
}
示例15: UpdateBasketPrices
function UpdateBasketPrices($fuserID, $siteID)
{
$fuserID = (int) $fuserID;
if ($fuserID <= 0) {
return false;
}
$siteID = (string) $siteID;
if ($siteID == '') {
$siteID = SITE_ID;
}
$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()) {
$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', "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)) {
$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;
}