本文整理匯總了PHP中CSaleBasket::ExecuteCallbackFunction方法的典型用法代碼示例。如果您正苦於以下問題:PHP CSaleBasket::ExecuteCallbackFunction方法的具體用法?PHP CSaleBasket::ExecuteCallbackFunction怎麽用?PHP CSaleBasket::ExecuteCallbackFunction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CSaleBasket
的用法示例。
在下文中一共展示了CSaleBasket::ExecuteCallbackFunction方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: checkQuantity
public function checkQuantity($arBasketItem, $desiredQuantity)
{
global $USER;
$arResult = array();
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasketItem)) {
$arFieldsTmp = $productProvider::GetProductData(array("PRODUCT_ID" => $arBasketItem["PRODUCT_ID"], "QUANTITY" => $desiredQuantity, "RENEWAL" => "N", "USER_ID" => $USER->GetID(), "SITE_ID" => SITE_ID, "BASKET_ID" => $arBasketItem["ID"], "CHECK_QUANTITY" => "Y", "CHECK_PRICE" => "N", "NOTES" => $arBasketItem["NOTES"]));
} elseif (isset($arBasketItem["CALLBACK_FUNC"]) && !empty($arBasketItem["CALLBACK_FUNC"])) {
$arFieldsTmp = CSaleBasket::ExecuteCallbackFunction($arBasketItem["CALLBACK_FUNC"], $arBasketItem["MODULE"], $arBasketItem["PRODUCT_ID"], $desiredQuantity, "N", $USER->GetID(), SITE_ID);
} else {
return $arResult;
}
if (empty($arFieldsTmp) || !isset($arFieldsTmp["QUANTITY"])) {
$arResult["ERROR"] = Loc::getMessage("SBB_PRODUCT_NOT_AVAILABLE", array("#PRODUCT#" => $arBasketItem["NAME"]));
} elseif ($desiredQuantity > doubleval($arFieldsTmp["QUANTITY"])) {
$arResult["ERROR"] = Loc::getMessage("SBB_PRODUCT_NOT_ENOUGH_QUANTITY", array("#PRODUCT#" => $arBasketItem["NAME"], "#NUMBER#" => $desiredQuantity));
}
return $arResult;
}
示例2: str_replace
if (strlen($arFields["ORDER_CALLBACK_FUNC"]) > 0) {
$arFields = CSaleBasket::ExecuteCallbackFunction($arFields["ORDER_CALLBACK_FUNC"], $arFields["MODULE"], $arFields["PRODUCT_ID"], $arFields["QUANTITY"]);
}
}
if (!$res) {
if ($ex = $APPLICATION->GetException()) {
$errorMessage .= $ex->GetString();
} else {
$errorMessage .= str_replace("#ID#", $arBasketList[$i][$j]["PRODUCT_ID"], GetMessage("SOE_ERROR_SAVE_ITEM")) . ". ";
}
}
}
}
foreach ($arOldBasketList as $key => $value) {
if (strlen($value["CANCEL_CALLBACK_FUNC"]) > 0) {
$arFields = CSaleBasket::ExecuteCallbackFunction($value["CANCEL_CALLBACK_FUNC"], $value["MODULE"], $value["PRODUCT_ID"], $value["QUANTITY"], true);
}
CSaleBasket::Delete($key);
}
}
if (strlen($errorMessage) <= 0) {
$arOldTaxList = array();
$dbTax = CSaleOrderTax::GetList(array("APPLY_ORDER" => "ASC"), array("ORDER_ID" => $ID), false, false, array("*"));
while ($arTax = $dbTax->Fetch()) {
$arOldTaxList[IntVal($arTax["ID"])] = "Y";
}
for ($i = 0; $i < count($arIDs); $i++) {
for ($j = 0; $j < count($arTaxList); $j++) {
$arFields = array("ORDER_ID" => $arIDs[$i], "TAX_NAME" => $arTaxList[$j]["TAX_NAME"], "VALUE" => $arTaxList[$j]["VALUE"], "VALUE_MONEY" => $arOrderTaxList[$i][$j]["VALUE_MONEY"], "APPLY_ORDER" => $arTaxList[$j]["APPLY_ORDER"], "IS_PERCENT" => "Y", "IS_IN_PRICE" => $arTaxList[$j]["IS_IN_PRICE"], "CODE" => $arTaxList[$j]["CODE"]);
$res = False;
if ($arTaxList[$j]["ID"] > 0) {
示例3: 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;
}
示例4: 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;
}
示例5: 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) {
//.........這裏部分代碼省略.........
示例6: Add
/**
* The function add viewed product
*
* @param array $arFields - params for add
* @return true false
*/
public static function Add($arFields)
{
global $DB;
global $USER;
global $APPLICATION;
foreach (GetModuleEvents("sale", "OnBeforeViewedAdd", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array(&$arFields)) === false) {
return false;
}
}
if (isset($arFields["ID"])) {
unset($arFields["ID"]);
}
$arFields["PRODUCT_ID"] = IntVal($arFields["PRODUCT_ID"]);
$arFields["USER_ID"] = IntVal($arFields["USER_ID"]);
$arFields["FUSER_ID"] = IntVal($arFields["FUSER_ID"]);
$arFields["IBLOCK_ID"] = IntVal($arFields["IBLOCK_ID"]);
if (strlen($arFields["CALLBACK_FUNC"]) <= 0) {
$arFields["CALLBACK_FUNC"] = "CatalogViewedProductCallback";
}
if (strlen($arFields["MODULE"]) <= 0) {
$arFields["MODULE"] = "catalog";
}
if (strlen($arFields["PRODUCT_PROVIDER_CLASS"]) <= 0 && $arFields["MODULE"] == "catalog") {
$arFields["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
}
if ($arFields["PRODUCT_ID"] <= 0) {
return false;
}
if (strlen($arFields["LID"]) <= 0) {
return false;
}
if (\Bitrix\Main\Loader::includeModule("catalog")) {
if (\Bitrix\Main\Config\Option::get("sale", "viewed_capability", "") == "Y") {
return \Bitrix\Catalog\CatalogViewedProductTable::refresh($arFields["PRODUCT_ID"], CSaleBasket::GetBasketUserID(), $arFields["LID"]);
}
}
$arFilter = array();
$arFilter["PRODUCT_ID"] = $arFields["PRODUCT_ID"];
if ($arFields["USER_ID"] > 0) {
$arFuserItems = CSaleUser::GetList(array("USER_ID" => $arFields["USER_ID"]));
$FUSER_ID = $arFuserItems["ID"];
} elseif (IntVal($arFields["FUSER_ID"]) > 0) {
$FUSER_ID = $arFields["FUSER_ID"];
} else {
$FUSER_ID = CSaleBasket::GetBasketUserID();
}
$arFilter["FUSER_ID"] = $FUSER_ID;
$arFields["FUSER_ID"] = $FUSER_ID;
$db_res = CSaleViewedProduct::GetList(array(), $arFilter, false, false, array('ID'));
if (!($arItems = $db_res->Fetch())) {
if (CModule::IncludeModule('catalog')) {
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arFields)) {
$arResultTmp = $productProvider::ViewProduct(array("PRODUCT_ID" => $arFields["PRODUCT_ID"], "USER_ID" => $arFields["USER_ID"], "SITE_ID" => $arFields["LID"]));
} else {
$arResultTmp = CSaleBasket::ExecuteCallbackFunction($arFields["CALLBACK_FUNC"], $arFields["MODULE"], $arFields["PRODUCT_ID"], $arFields["USER_ID"], $arFields["LID"]);
}
if ($arResultTmp && count($arResultTmp) > 0) {
$arFields = array_merge($arFields, $arResultTmp);
}
if (strlen($arFields["NAME"]) <= 0) {
return false;
}
$arInsert = $DB->PrepareInsert("b_sale_viewed_product", $arFields);
//chance deleted
$rnd = mt_rand(0, 1000);
if ($rnd < 100) {
$db_res = CSaleViewedProduct::GetList(array(), array("FUSER_ID" => $FUSER_ID), array("COUNT" => "ID"), false);
$arCount = $db_res->Fetch();
$viewedCount = COption::GetOptionString("sale", "viewed_count", "100");
if ($arCount["ID"] > IntVal($viewedCount)) {
$limit = $arCount["ID"] - $viewedCount + $viewedCount * 0.2;
CSaleViewedProduct::DeleteForUser($FUSER_ID, $limit);
}
}
$strSql = "INSERT INTO b_sale_viewed_product (" . $arInsert[0] . ", DATE_VISIT) VALUES(" . $arInsert[1] . ", " . $DB->GetNowFunction() . ")";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$ID = IntVal($DB->LastID());
}
} else {
$ID = IntVal($arItems["ID"]);
$arFields["DATE_VISIT"] = $DB->GetNowFunction();
$arInsert = $DB->PrepareInsert("b_sale_viewed_product", $arFields);
CSaleViewedProduct::Update($ID, $arFields);
}
foreach (GetModuleEvents("sale", "OnViewedAdd", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($arFields));
}
return $ID;
}
示例7: NextPayment
/**
* <p>Метод осуществляет продление подписки с кодом ID.</p> <p><b>Примечание</b>. Метод использует внутреннюю транзакцию. Если у вас используется <b>MySQL</b> и <b>InnoDB</b>, и ранее была открыта транзакция, то ее необходимо закрыть до подключения метода.</p>
*
*
*
*
* @param int $ID Код записи с информацией о продлении.
*
*
*
* @return bool <p>Метод возвращает <i>true</i> в случае успешного продления или <i>false</i>
* в случае ошибки.</p><br><br>
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalerecurring/csalerecurring.nextpayment.php
* @author Bitrix
*/
public static function NextPayment($ID)
{
global $DB;
global $USER;
$ID = IntVal($ID);
if ($ID <= 0)
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGR_NO_RECID"), "NO_RECORD_ID");
return False;
}
$arRecur = CSaleRecurring::GetByID($ID);
if (!$arRecur)
{
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("SKGR_NO_RECID1")), "NO_RECORD");
return False;
}
$arOrder = CSaleOrder::GetByID($arRecur["ORDER_ID"]);
if (!$arOrder)
{
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arRecur["ORDER_ID"], GetMessage("SKGR_NO_ORDER1")), "NO_ORDER");
return False;
}
$bSuccess = True;
$newOrderID = IntVal($arRecur["ORDER_ID"]);
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arRecur))
{
$arProduct = $productProvider::RecurringOrderProduct(array(
"PRODUCT_ID" => $arRecur["PRODUCT_ID"],
"USER_ID" => $arOrder["USER_ID"]
));
}
else
{
$arProduct = CSaleRecurring::ExecuteCallbackFunction(
$arRecur["CALLBACK_FUNC"],
$arRecur["MODULE"],
$arRecur["PRODUCT_ID"],
$arOrder["USER_ID"]
);
}
if (!$arProduct || !is_array($arProduct) || count($arProduct) <= 0)
{
CSaleRecurring::CancelRecurring($arRecur["ID"], "Y", "Product is not found");
/*
$arFields = array(
"CANCELED" => "Y",
"DATE_CANCELED" => Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL", LANG))),
"CANCELED_REASON" => "Product is not found"
);
CSaleRecurring::Update($arRecur["ID"], $arFields);
*/
//CSaleRecurring::Delete($arRecur["ID"]);
return True;
}
if ($arProduct["WITHOUT_ORDER"] == "Y" || $arRecur["SUCCESS_PAYMENT"] == "Y")
{
$baseSiteCurrency = CSaleLang::GetLangCurrency($arOrder["LID"]);
$productPrice = roundEx(CCurrencyRates::ConvertCurrency($arProduct["PRICE"], $arProduct["CURRENCY"], $baseSiteCurrency), SALE_VALUE_PRECISION);
// Delivery
$deliveryPrice = 0;
$deliveryID = 0;
$arOrder["DELIVERY_ID"] = IntVal($arOrder["DELIVERY_ID"]);
if ($arOrder["DELIVERY_ID"] > 0)
{
$deliveryLocation = 0;
$dbOrderPropValues = CSaleOrderPropsValue::GetList(
array(),
array(
"ORDER_ID" => $arRecur["ORDER_ID"],
"PROP_IS_LOCATION" => "Y"
),
//.........這裏部分代碼省略.........
示例8: array
$propertyIterator = CIBlockElement::GetProperty($element['IBLOCK_ID'], $element['ID'], array(), array('ID' => $sku['SKU_PROPERTY_ID']));
if ($property = $propertyIterator->Fetch()) {
$parentId = (int) $property['VALUE'];
}
unset($property, $propertyIterator);
}
}
if (!empty($element) && $parentId > 0) {
$bBasketUpdate = false;
$arPropsValues["CML2_LINK"] = $parentId;
$newProductId = getProductByProps($element['IBLOCK_ID'], $arPropsValues, true);
if (!empty($newProductId)) {
if ($productProvider = CSaleBasket::GetProductProvider($arItem)) {
$arFieldsTmp = $productProvider::GetProductData(array("PRODUCT_ID" => $newProductId['ID'], "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"])) {
$arFieldsTmp = CSaleBasket::ExecuteCallbackFunction($arItem["CALLBACK_FUNC"], $arItem["MODULE"], $newProductId['ID'], $arItem['QUANTITY'], "N", $USER->GetID(), SITE_ID);
}
if (!empty($arFieldsTmp) && is_array($arFieldsTmp)) {
$arFields = array('PRODUCT_ID' => $newProductId['ID'], 'PRODUCT_PRICE_ID' => $arFieldsTmp["PRODUCT_PRICE_ID"], 'PRICE' => $arFieldsTmp["PRICE"], 'CURRENCY' => $arFieldsTmp["CURRENCY"], 'QUANTITY' => $arFieldsTmp['QUANTITY'], 'WEIGHT' => $arFieldsTmp['WEIGHT']);
$arProps = array();
if (strpos($newProductId['XML_ID'], '#') === false) {
$parentIterator = \Bitrix\Iblock\ElementTable::getList(array('select' => array('ID', 'XML_ID'), 'filter' => array('ID' => $parentId)));
if ($parentProduct = $parentIterator->fetch()) {
$newProductId['XML_ID'] = $parentProduct['XML_ID'] . '#' . $newProductId['XML_ID'];
}
unset($parentProduct, $parentIterator);
}
$arFields["PRODUCT_XML_ID"] = $newProductId['XML_ID'];
$propertyIterator = \Bitrix\Iblock\PropertyTable::getList(array('select' => array('ID', 'CODE'), 'filter' => array('IBLOCK_ID' => $newProductId['IBLOCK_ID'], '!ID' => $sku['SKU_PROPERTY_ID'])));
while ($property = $propertyIterator->fetch()) {
$property['CODE'] = (string) $property['CODE'];
示例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: deliverShipment
/**
* @param Shipment $shipment
* @return Result
* @throws NotSupportedException
*/
public static function deliverShipment(Shipment $shipment)
{
global $APPLICATION;
$result = new Result();
$needDeliver = $shipment->needDeliver();
if ($needDeliver === null || $needDeliver === false && $shipment->getId() <= 0) {
return $result;
}
$resultList = array();
$shipmentItemCollection = $shipment->getShipmentItemCollection();
$basketList = static::getBasketFromShipmentItemCollection($shipmentItemCollection);
$basketProviderMap = static::createProviderBasketMap($basketList, array('ORDER_ID', 'USER_ID', 'QUANTITY', 'PAID'));
$basketProviderList = static::redistributeToProviders($basketProviderMap);
if (!empty($basketProviderList)) {
foreach ($basketProviderList as $provider => $providerBasketItemList) {
if ($provider instanceof Provider) {
throw new NotSupportedException('provider not supported');
} elseif ($provider && array_key_exists("IBXSaleProductProvider", class_implements($provider))) {
foreach ($providerBasketItemList as $providerBasketItem) {
if ($providerBasketItem['BASKET_ITEM']->isBundleParent()) {
continue;
}
if (!$providerBasketItem['BASKET_ITEM']->isEmptyItem()) {
$data = array("PRODUCT_ID" => $providerBasketItem["PRODUCT_ID"], "USER_ID" => $providerBasketItem["USER_ID"], "PAID" => $providerBasketItem["PAID"], "ORDER_ID" => $providerBasketItem["ORDER_ID"], "BASKET_ID" => $providerBasketItem['BASKET_ID']);
$APPLICATION->ResetException();
$resultProductData = $provider::DeliverProduct($data);
if ($ex = $APPLICATION->GetException()) {
$result->addError(new ResultError($ex->GetString(), $ex->GetID()));
}
if (!empty($resultProductData) && is_array($resultProductData)) {
$resultProductData['ORDER_ID'] = $providerBasketItem['ORDER_ID'];
}
} else {
$resultProductData = true;
}
$resultList[$providerBasketItem['BASKET_CODE']] = $resultProductData;
}
} else {
foreach ($providerBasketItemList as $providerBasketItem) {
$resultProductData = \CSaleBasket::ExecuteCallbackFunction($providerBasketItem['CALLBACK_FUNC'], $providerBasketItem['MODULE'], $providerBasketItem['PRODUCT_ID'], $providerBasketItem['USER_ID'], $providerBasketItem["PAID"], $providerBasketItem['ORDER_ID'], $providerBasketItem["QUANTITY"]);
$basketCode = $providerBasketItem['BASKET_ITEM']->getBasketCode();
if (!empty($resultProductData) && is_array($resultProductData)) {
$resultProductData['ORDER_ID'] = $providerBasketItem['ORDER_ID'];
}
$resultList[$basketCode] = $resultProductData;
}
}
}
if (!empty($resultList) && is_array($resultList)) {
foreach ($resultList as $basketCode => $resultData) {
if ($resultData && !empty($resultData) && is_array($resultData)) {
$resultData["REMAINING_ATTEMPTS"] = defined("SALE_PROC_REC_ATTEMPTS") ? SALE_PROC_REC_ATTEMPTS : 3;
$resultData["SUCCESS_PAYMENT"] = "Y";
// TODO: recurringID
/*
if ($recurringID > 0)
\CSaleRecurring::Update($recurringID, $resultData);
else
\CSaleRecurring::Add($resultData);
*/
}
/*
elseif ($recurringID > 0)
{
\CSaleRecurring::Delete($recurringID);
}
*/
}
}
}
if (!empty($resultList)) {
$result->setData($resultList);
}
return $result;
}
示例11: IntVal
}
$viewedMessage = '';
$basketMessage = '';
$viewedError = '';
$basketError = '';
//ACTIONS
//viewed
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'viewed_apply' && IntVal($_REQUEST["viewed_id"]) > 0 && strlen($_REQUEST["viewed_lid"]) > 0 && $saleModulePermissions >= "W") {
$PRODUCT_ID = IntVal($_REQUEST["viewed_id"]);
$LID = trim($_REQUEST["viewed_lid"]);
if (CModule::IncludeModule("catalog")) {
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => "catalog", "PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider"))) {
$arViews = $productProvider::GetProductData(array("PRODUCT_ID" => $PRODUCT_ID, "QUANTITY" => 1, "RENEWAL" => "N", "SITE_ID" => $LID));
} else {
$arViews = CSaleBasket::ExecuteCallbackFunction('CatalogBasketCallback', 'catalog', $PRODUCT_ID, 1, $LID);
}
if (count($arViews) <= 0) {
$viewedError = GetMessage('BUYER_VIEWED_ERROR_PRODUCT_FAIL');
$viewedMessage = "";
} else {
$dbProduct = CIBlockElement::GetList(array(), array("ID" => $PRODUCT_ID), false, false, array('ID', 'NAME', "XML_ID", "IBLOCK_EXTERNAL_ID"));
$arProduct = $dbProduct->Fetch();
$arViews['NAME'] = $arProduct["NAME"];
$arViews['PRODUCT_ID'] = $arProduct["ID"];
$arViews['MODULE'] = "catalog";
$arViews["LID"] = $LID;
}
} else {
$dbViewsList = CSaleViewedProduct::GetList(array(), array("FUSER_ID" => $arFuserItems["ID"], "PRODUCT_ID" => $PRODUCT_ID), false, false);
$arViews = $dbViewsList->Fetch();
示例12: Add
//.........這裏部分代碼省略.........
* Смотрите также:
*
* <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();
} else {
$boolProps = !empty($arFields["PROPS"]) && is_array($arFields["PROPS"]);
// check if this item is already in the basket
$arDuplicateFilter = array("FUSER_ID" => $arFields["FUSER_ID"], "PRODUCT_ID" => $arFields["PRODUCT_ID"], "LID" => $arFields["LID"], "ORDER_ID" => "NULL");
if (!(isset($arFields["TYPE"]) && $arFields["TYPE"] == CSaleBasket::TYPE_SET)) {
if (isset($arFields["SET_PARENT_ID"])) {
$arDuplicateFilter["SET_PARENT_ID"] = $arFields["SET_PARENT_ID"];
} else {
$arDuplicateFilter["SET_PARENT_ID"] = "NULL";
示例13: 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;
}
示例14: OrderCanceled
function OrderCanceled($orderID, $bCancel)
{
global $DB;
$orderID = IntVal($orderID);
if ($orderID <= 0) {
return False;
}
$bCancel = $bCancel ? True : False;
$arOrder = CSaleOrder::GetByID($orderID);
if ($arOrder) {
$dbBasketList = CSaleBasket::GetList(array("NAME" => "ASC"), array("ORDER_ID" => $orderID));
while ($arBasket = $dbBasketList->Fetch()) {
if (strlen($arBasket["CANCEL_CALLBACK_FUNC"]) > 0 && strlen($arBasket["PRODUCT_PROVIDER_CLASS"]) <= 0) {
$arFields = CSaleBasket::ExecuteCallbackFunction($arBasket["CANCEL_CALLBACK_FUNC"], $arBasket["MODULE"], $arBasket["PRODUCT_ID"], $arBasket["QUANTITY"], $bCancel);
}
}
}
}