本文整理汇总了PHP中CSaleBasket::Update方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleBasket::Update方法的具体用法?PHP CSaleBasket::Update怎么用?PHP CSaleBasket::Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleBasket
的用法示例。
在下文中一共展示了CSaleBasket::Update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OrderDeduction
//.........这里部分代码省略.........
if ($ex = $GLOBALS["APPLICATION"]->GetException()) {
$arResult["ERROR"]["MESSAGE"] = $ex->GetString();
$arResult["ERROR"]["CODE"] = $ex->GetID();
}
if (!$bRealDeductionAllowed) {
break;
}
}
}
//real deduction
if ($bRealDeductionAllowed) {
$bProductsDeductedSuccessfully = true;
$arDeductedItems = array();
foreach ($arItems as $arItem) {
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arItem)) {
$arItem["FIELDS"]["EMULATE"] = "N";
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::DeductProduct", array("fields" => $arItem["FIELDS"]), "OD10");
}
//finally real deduction
$res = $productProvider::DeductProduct($arItem["FIELDS"]);
if ($res["RESULT"]) {
$arDeductedItems[] = $arItem;
if (!$bReturn && $storesCount > 0) {
if ($bAutoDeduction) {
$arStoreBarcodeFields = array("BASKET_ID" => $arItem["ID"], "BARCODE" => "", "STORE_ID" => array_pop(array_keys($res["STORES"])), "QUANTITY" => $arItem["QUANTITY"], "CREATED_BY" => intval($GLOBALS["USER"]->GetID()) > 0 ? IntVal($GLOBALS["USER"]->GetID()) : "", "MODIFIED_BY" => intval($GLOBALS["USER"]->GetID()) > 0 ? IntVal($GLOBALS["USER"]->GetID()) : "");
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call CSaleStoreBarcode::Add (auto deduction = true)", array("arStoreBarcodeFields" => $arStoreBarcodeFields), "OD11");
}
CSaleStoreBarcode::Add($arStoreBarcodeFields);
}
// else
// {
// foreach ($arStoreBarcodeOrderFormData as $id => $arRecord)
// {
// $arStoreBarcodeFields = array(
// "BASKET_ID" => $arRecord["ID"],
// "BARCODE" => ($arItem["BARCODE_MULTI"] == "Y") ? $arRecord["BARCODE"] : "",
// "STORE_ID" => $arRecord["STORE_ID"],
// "QUANTITY" => $arRecord["QUANTITY"],
// "CREATED_BY" => ((intval($GLOBALS["USER"]->GetID())>0) ? IntVal($GLOBALS["USER"]->GetID()) : ""),
// "MODIFIED_BY" => ((intval($GLOBALS["USER"]->GetID())>0) ? IntVal($GLOBALS["USER"]->GetID()) : "")
// );
// if (defined("SALE_DEBUG") && SALE_DEBUG)
// CSaleHelper::WriteToLog("Call CSaleStoreBarcode::Add", array("arStoreBarcodeFields" => $arStoreBarcodeFields), "OD11");
// CSaleStoreBarcode::Add($arStoreBarcodeFields);
// }
// }
}
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::DeductProduct - Success (DEDUCTED = Y)", array(), "OD11");
}
CSaleBasket::Update($arItem["ID"], array("DEDUCTED" => "Y"));
//CSaleOrder::AddOrderHistory
} else {
CSaleBasket::Update($arItem["ID"], array("DEDUCTED" => "N"));
$bProductsDeductedSuccessfully = false;
if ($ex = $GLOBALS["APPLICATION"]->GetException()) {
$arResult["ERROR"]["MESSAGE"] = $ex->GetString();
$arResult["ERROR"]["CODE"] = $ex->GetID();
}
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::DeductProduct - Error (DEDUCTED = N)", array(), "OD12");
}
break;
}
}
}
if ($bProductsDeductedSuccessfully) {
$arResult["RESULT"] = true;
} else {
$arFields = array();
foreach ($arDeductedItems as $arItem) {
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arItem)) {
if ($storesCount > 0) {
$arFields = array("PRODUCT_ID" => $arItem["PRODUCT_ID"], "QUANTITY" => $arItem["QUANTITY"], "UNDO_DEDUCTION" => "Y", "EMULATE" => "N", "PRODUCT_RESERVED" => $arItem["FIELDS"]["PRODUCT_RESERVED"], "STORE_DATA" => $arItem["FIELDS"]["STORE_DATA"]);
} else {
$arFields = array("PRODUCT_ID" => $arItem["PRODUCT_ID"], "QUANTITY" => $arItem["QUANTITY"], "UNDO_DEDUCTION" => "Y", "PRODUCT_RESERVED" => $arItem["FIELDS"]["PRODUCT_RESERVED"], "EMULATE" => "N");
}
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::DeductProduct - Revert deduction", array("storesCount" => $storesCount, "arFields" => $arFields), "OD13");
}
$res = $productProvider::DeductProduct($arFields);
if ($res["RESULT"]) {
CSaleBasket::Update($arItem["ID"], array("DEDUCTED" => "N"));
}
}
}
$arResult["RESULT"] = false;
}
} else {
$arResult["RESULT"] = false;
}
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("OrderDeduction - result", array("arResult" => $arResult), "OD14");
}
return $arResult;
}
示例2: nodeHandler
function nodeHandler(CDataXML $value)
{
$value = $value->GetArray();
$value = $value[GetMessage("CC_BSC1_DOCUMENT")];
if ($value["#"][GetMessage("CC_BSC1_OPERATION")][0]["#"] == GetMessage("CC_BSC1_ORDER")) {
$orderId = IntVal($value["#"][GetMessage("CC_BSC1_NUMBER")][0]["#"]);
$arOrder = array();
$arItem = array();
$arOrder["AMOUNT"] = $value["#"][GetMessage("CC_BSC1_SUMM")][0]["#"];
$arOrder["AMOUNT"] = str_replace($SumFormat, ".", $arOrder["AMOUNT"]);
$arOrder["COMMENT"] = $value["#"][GetMessage("CC_BSC1_COMMENT")][0]["#"];
foreach ($value["#"][GetMessage("CC_BSC1_REK_VALUES")][0]["#"][GetMessage("CC_BSC1_REK_VALUE")] as $val) {
$arOrder["TRAITS"][$val["#"][GetMessage("CC_BSC1_NAME")][0]["#"]] = $val["#"][GetMessage("CC_BSC1_VALUE")][0]["#"];
}
$taxValue = 0;
$taxValueTmp = 0;
$taxName = "";
if (is_array($value["#"][GetMessage("CC_BSC1_ITEMS")][0]["#"][GetMessage("CC_BSC1_ITEM")])) {
foreach ($value["#"][GetMessage("CC_BSC1_ITEMS")][0]["#"][GetMessage("CC_BSC1_ITEM")] as $val) {
$val = $val["#"];
$productID = $val[GetMessage("CC_BSC1_ID")][0]["#"];
$bGood = false;
$discountPrice = "";
$priceAll = str_replace($SumFormat, ".", $val[GetMessage("CC_BSC1_SUMM")][0]["#"]);
$priceone = str_replace($SumFormat, ".", $val[GetMessage("CC_BSC1_PRICE_PER_UNIT")][0]["#"]);
$quantity = str_replace($QuantityFormat, ".", $val[GetMessage("CC_BSC1_QUANTITY")][0]["#"]);
$price = $priceAll / $quantity;
if ($priceone != $price) {
$discountPrice = $priceone - $price;
}
//DISCOUNTS!
$arItem[$productID] = array("NAME" => $val[GetMessage("CC_BSC1_NAME")][0]["#"], "PRICE" => $price, "QUANTITY" => $quantity, "DISCOUNT_PRICE" => $discountPrice);
if (is_array($val[GetMessage("CC_BSC1_PROPS_ITEMS")][0]["#"][GetMessage("CC_BSC1_PROP_ITEM")])) {
foreach ($val[GetMessage("CC_BSC1_PROPS_ITEMS")][0]["#"][GetMessage("CC_BSC1_PROP_ITEM")] as $val1) {
$arItem[$productID]["ATTRIBUTES"][$val1["#"][GetMessage("CC_BSC1_NAME")][0]["#"]] = $val1["#"][GetMessage("CC_BSC1_VALUE")][0]["#"];
}
}
if (is_array($val[GetMessage("CC_BSC1_REK_VALUES")][0]["#"][GetMessage("CC_BSC1_REK_VALUE")])) {
foreach ($val[GetMessage("CC_BSC1_REK_VALUES")][0]["#"][GetMessage("CC_BSC1_REK_VALUE")] as $val1) {
if ($val1["#"][GetMessage("CC_BSC1_NAME")][0]["#"] == GetMessage("CC_BSC1_ITEM_TYPE")) {
$arItem[$productID]["TYPE"] = $val1["#"][GetMessage("CC_BSC1_VALUE")][0]["#"];
}
}
}
if (strlen($value["#"][GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_NAME")][0]["#"]) > 0) {
$taxValueTmp = $val[GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_TAX_VALUE")][0]["#"];
$arItem[$productID]["VAT_RATE"] = $taxValueTmp / 100;
if (IntVal($taxValueTmp) > IntVal($taxValue)) {
$taxName = $val[GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_NAME")][0]["#"];
$taxValue = $taxValueTmp;
}
}
}
}
if (IntVal($taxValue) > 0) {
$price = str_replace($SumFormat, ".", $value["#"][GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_SUMM")][0]["#"]);
$arOrder["TAX"] = array("NAME" => $taxName, "VALUE" => $taxValue, "IS_IN_PRICE" => $value["#"][GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_IN_PRICE")][0]["#"] == "true" ? "Y" : "N", "VALUE_MONEY" => $price);
}
$arOrder["items"] = $arItem;
$v = $arOrder;
if ($orderInfo = CSaleOrder::GetByID($orderId)) {
if ($orderInfo["PAYED"] != "Y" && $orderInfo["ALLOW_DELIVERY"] != "Y" && $orderInfo["STATUS_ID"] != "F") {
$dbOrderTax = CSaleOrderTax::GetList(array(), array("ORDER_ID" => $orderId), false, false, array("ID", "TAX_NAME", "VALUE", "VALUE_MONEY", "CODE", "IS_IN_PRICE"));
$bTaxFound = false;
if ($arOrderTax = $dbOrderTax->Fetch()) {
$bTaxFound = true;
if (IntVal($arOrderTax["VALUE_MONEY"]) != IntVal($v["TAX"]["VALUE_MONEY"]) || IntVal($arOrderTax["VALUE"]) != IntVal($v["TAX"]["VALUE"]) || $arOrderTax["IS_IN_PRICE"] != $v["TAX"]["IS_IN_PRICE"]) {
if (IntVal($v["TAX"]["VALUE"]) > 0) {
$arFields = array("TAX_NAME" => $v["TAX"]["NAME"], "ORDER_ID" => $orderId, "VALUE" => $v["TAX"]["VALUE"], "IS_PERCENT" => "Y", "IS_IN_PRICE" => $v["TAX"]["IS_IN_PRICE"], "VALUE_MONEY" => $v["TAX"]["VALUE_MONEY"], "CODE" => "VAT1C", "APPLY_ORDER" => "100");
CSaleOrderTax::Update($arOrderTax["ID"], $arFields);
CSaleOrder::Update($orderId, array("TAX_VALUE" => $v["TAX"]["VALUE_MONEY"]));
} else {
CSaleOrderTax::Delete($arOrderTax["ID"]);
CSaleOrder::Update($orderId, array("TAX_VALUE" => 0));
}
}
}
if (!$bTaxFound) {
if (IntVal($v["TAX"]["VALUE"]) > 0) {
$arFields = array("TAX_NAME" => $v["TAX"]["NAME"], "ORDER_ID" => $orderId, "VALUE" => $v["TAX"]["VALUE"], "IS_PERCENT" => "Y", "IS_IN_PRICE" => $v["TAX"]["IS_IN_PRICE"], "VALUE_MONEY" => $v["TAX"]["VALUE_MONEY"]);
CSaleOrderTax::Add($arFields);
CSaleOrder::Update($orderId, array("TAX_VALUE" => $v["TAX"]["VALUE_MONEY"]));
}
}
$dbBasket = CSaleBasket::GetList(array("NAME" => "ASC"), array("ORDER_ID" => $orderId));
$basketSum = 0;
while ($arBasket = $dbBasket->Fetch()) {
$arFields = array();
if (!empty($v["items"][$arBasket["PRODUCT_XML_ID"]])) {
if ($arBasket["QUANTITY"] != $v["items"][$arBasket["PRODUCT_XML_ID"]]["QUANTITY"]) {
$arFields["QUANTITY"] = $v["items"][$arBasket["PRODUCT_XML_ID"]]["QUANTITY"];
}
if ($arBasket["PRICE"] != $v["items"][$arBasket["PRODUCT_XML_ID"]]["PRICE"]) {
$arFields["PRICE"] = $v["items"][$arBasket["PRODUCT_XML_ID"]]["PRICE"];
}
if ($arBasket["VAT_RATE"] != $v["items"][$arBasket["PRODUCT_XML_ID"]]["VAT_RATE"]) {
$arFields["VAT_RATE"] = $v["items"][$arBasket["PRODUCT_XML_ID"]]["VAT_RATE"];
}
if ($arBasket["DISCOUNT_PRICE"] != $v["items"][$arBasket["PRODUCT_XML_ID"]]["DISCOUNT_PRICE"]) {
$arFields["DISCOUNT_PRICE"] = $v["items"][$arBasket["PRODUCT_XML_ID"]]["DISCOUNT_PRICE"];
//.........这里部分代码省略.........
示例3: array
}
}
}
if (!empty($arProductIDs) && Loader::includeModule('catalog')) {
$rsProducts = CCatalogProduct::GetList(array(), array('ID' => array_keys($arProductIDs)), false, false, $arSelect);
while ($arProduct = $rsProducts->Fetch()) {
if (array_key_exists($arProduct['ID'], $arProductIDs)) {
$key = $arProductIDs[$arProduct['ID']];
if ($arNewQuantity[$arProduct['ID']] > $arProduct['QUANTITY'] && 'Y' == $arProduct['QUANTITY_TRACE'] && 'N' == $arProduct['CAN_BUY_ZERO']) {
$arNewQuantity[$arProduct['ID']] = $arProduct['QUANTITY'];
$productLimit .= GetMessage("STOF_WARNING_LIMIT_PRODUCT") . " " . $arShoppingCart[$key]["NAME"] . "<br>";
}
if ($arNewQuantity[$arProduct['ID']] != $arShoppingCart[$key]['QUANTITY']) {
$arShoppingCart[$key]['QUANTITY'] = $arNewQuantity[$arProduct['ID']];
$arFields = array("QUANTITY" => $arNewQuantity[$arProduct['ID']], 'TYPE' => $arShoppingCart[$key]['TYPE'], 'SET_PARENT_ID' => $arShoppingCart[$key]['SET_PARENT_ID']);
CSaleBasket::Update($arShoppingCart[$key]["ID"], $arFields);
}
}
}
}
}
}
$arBasketItems = CSaleOrder::DoCalculateOrder(SITE_ID, $currentUserId, $arShoppingCart, $PERSON_TYPE, $arPropValues, $DELIVERY_ID, $PAYSYSTEM_ID, array(), $arErrors, $arWarnings);
if ((!empty($arErrors) || !empty($arWarnings)) && strlen($_REQUEST["AJAX_CALL"]) > 0 && !isset($_POST["BasketRefresh"])) {
foreach ($arErrors as $val) {
$errorMessage .= $val["TEXT"] . "<br>";
}
foreach ($arWarnings as $val) {
$errorMessage .= $val["TEXT"] . "<br>";
}
$arErrors = array();
示例4: intval
//foreach ($allproducts as $product) {
$product = intval($_REQUEST["productid"]);
//$product = intval($_POST["add2basket"]);
//проверим
$res = CIBlockElement::GetByID($product);
if ($ar_res = $res->GetNext()) {
$arProps = array();
$PRODUCT = $ar_res;
$ar_res = CPrice::GetBasePrice($PRODUCT[ID]);
$price = $ar_res["PRICE"];
if (intval($price) == 0) {
$price = 0;
$arFields = array("PRODUCT_ID" => $PRODUCT[ID], "QUANTITY" => $quantity, "PRODUCT_XML_ID" => $PRODUCT[ID], "PRICE" => $price, "CURRENCY" => "RUB", "LID" => "s1", "NAME" => $PRODUCT[NAME]);
$basket_id = CSaleBasket::Add($arFields);
$arItem = CSaleBasket::GetByID($basket_id);
if ($arItem["QUANTITY"] != $quantity) {
$arFields = array("QUANTITY" => $arItem["QUANTITY"] + $quantity);
CSaleBasket::Update($basket_id, $arFields);
}
} else {
$basket_id = Add2BasketByProductID($product, $quantity);
}
}
}
break;
case "update":
$arFields = array("QUANTITY" => $_REQUEST["quantity"]);
CSaleBasket::Update($_REQUEST["id"], $arFields);
break;
}
$APPLICATION->IncludeComponent("bitrix:sale.basket.basket.small", "hiding_basket", array("PATH_TO_BASKET" => "/personal/basket.php", "PATH_TO_ORDER" => "/personal/order.php", "SHOW_DELAY" => "Y", "SHOW_NOTAVAIL" => "Y", "SHOW_SUBSCRIBE" => "Y"), false);
示例5: intval
// if action is performed
if (strlen($_REQUEST[$arParams["ACTION_VARIABLE"]]) > 0) {
$id = intval($_REQUEST["id"]);
if ($id > 0) {
$dbBasketItems = CSaleBasket::GetList(array(), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL", "ID" => $id), false, false, array('ID', 'DELAY', 'CAN_BUY', 'SET_PARENT_ID', 'TYPE'));
$arItem = $dbBasketItems->Fetch();
if ($arItem && !CSaleBasketHelper::isSetItem($arItem)) {
if ($_REQUEST[$arParams["ACTION_VARIABLE"]] == "delete" && in_array("DELETE", $arParams["COLUMNS_LIST"])) {
CSaleBasket::Delete($arItem["ID"]);
} elseif ($_REQUEST[$arParams["ACTION_VARIABLE"]] == "delay" && in_array("DELAY", $arParams["COLUMNS_LIST"])) {
if ($arItem["DELAY"] == "N" && $arItem["CAN_BUY"] == "Y") {
CSaleBasket::Update($arItem["ID"], array("DELAY" => "Y"));
}
} elseif ($_REQUEST[$arParams["ACTION_VARIABLE"]] == "add" && in_array("DELAY", $arParams["COLUMNS_LIST"])) {
if ($arItem["DELAY"] == "Y" && $arItem["CAN_BUY"] == "Y") {
CSaleBasket::Update($arItem["ID"], array("DELAY" => "N"));
}
}
unset($_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]);
}
}
LocalRedirect($APPLICATION->GetCurPage());
} else {
if (isset($_REQUEST["COUPON"])) {
$_REQUEST["coupon"] = $_REQUEST["COUPON"];
}
$arRes = $this->recalculateBasket($_REQUEST);
foreach ($arRes as $key => $value) {
$arResult[$key] = $value;
}
unset($_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]);
示例6: array
}
}
$index += 1;
}
//dd($USER_DESCRIPTION);
$arFields = array("LID" => "s1", "PERSON_TYPE_ID" => 1, "PAYED" => "N", "CANCELED" => "N", "STATUS_ID" => "N", "PRICE" => $totalSum, "CURRENCY" => "UAH", "USER_ID" => IntVal($USER->GetID()), "PAY_SYSTEM_ID" => 1, "PRICE_DELIVERY" => 1, "DELIVERY_ID" => 1, "DISCOUNT_VALUE" => 0.0, "TAX_VALUE" => 0.0, "USER_DESCRIPTION" => $USER_DESCRIPTION);
$ORDER_ID = CSaleOrder::Add($arFields);
if ($ORDER_ID) {
global $USER;
$arEventFields = array("EMAIL" => $USER->GetEmail(), "ORDER_ID" => $ORDER_ID, "PRICE" => $_GET['totalSum']);
CEvent::SendImmediate("SALE_NEW_ORDER_SEST", "s1", $arEventFields);
//привязал корзину к заказу
CSaleBasket::OrderBasket($ORDER_ID, 0, SITE_ID);
//$_SESSION["SALE_USER_ID"]
foreach ($arrCleanProducts as $key => $value) {
$res = CSaleBasket::Update($value->elementBaskId, array('QUANTITY' => $value->quantity, 'PRICE' => $value->oneSum));
}
} else {
//dd(bad);
}
}
}
?>
<?php
//Подгрузка брендов
示例7: 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;
}
示例8: Add
//.........这里部分代码省略.........
}
if (isset($arProp)) {
unset($arProp);
}
}
$dbProp = CSaleBasket::GetPropsList(array(), array("BASKET_ID" => $res["ID"]), false, false, array('NAME', 'VALUE', 'CODE'));
while ($arProp = $dbProp->Fetch()) {
if ('' != $arProp["VALUE"]) {
$propID = '';
if ('' != $arProp["CODE"]) {
$propID = $arProp["CODE"];
} elseif ('' != $arProp["NAME"]) {
$propID = $arProp["NAME"];
}
if ('' == $propID) {
continue;
}
$arPropsOld[$propID] = $arProp["VALUE"];
}
}
$bEqAr = false;
if (count($arPropsCur) == count($arPropsOld)) {
$bEqAr = true;
foreach ($arPropsCur as $key => $val) {
if (!array_key_exists($key, $arPropsOld) || $arPropsOld[$key] != $val) {
$bEqAr = false;
break;
}
}
}
if ($bEqAr) {
$ID = $res["ID"];
$arFields["QUANTITY"] += $res["QUANTITY"];
CSaleBasket::Update($ID, $arFields);
$bFound = true;
continue;
}
}
}
}
if (!$bFound) {
//TODO: is order converted?
if ($isOrderConverted != "Y") {
$arInsert = $DB->PrepareInsert("b_sale_basket", $arFields);
$strSql = "INSERT INTO b_sale_basket(" . $arInsert[0] . ", DATE_INSERT, DATE_UPDATE) VALUES(" . $arInsert[1] . ", " . $DB->GetNowFunction() . ", " . $DB->GetNowFunction() . ")";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$ID = intval($DB->LastID());
$boolOrder = false;
if (isset($arFields['ORDER_ID'])) {
$boolOrder = 0 < (int) $arFields['ORDER_ID'];
}
if (!$boolOrder && !CSaleBasketHelper::isSetItem($arFields)) {
$siteID = isset($arFields["LID"]) ? $arFields["LID"] : SITE_ID;
$_SESSION["SALE_BASKET_NUM_PRODUCTS"][$siteID]++;
}
if ($boolProps) {
foreach ($arFields["PROPS"] as &$prop) {
if ('' != $prop["NAME"]) {
$arInsert = $DB->PrepareInsert("b_sale_basket_props", $prop);
$strSql = "INSERT INTO b_sale_basket_props(BASKET_ID, " . $arInsert[0] . ") VALUES(" . $ID . ", " . $arInsert[1] . ")";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
}
if (isset($prop)) {
unset($prop);
}
示例9: array
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule("sale");
if (isset($_GET['delete_from_basket'])) {
CSaleBasket::Delete(intval($_GET['delete_from_basket']));
}
if (isset($_GET['update_basket_item']) && isset($_GET['basket_item_quantity'])) {
CSaleBasket::Update(intval($_GET['update_basket_item']), array("QUANTITY" => intval($_GET['basket_item_quantity'])));
}
$APPLICATION->IncludeComponent("bitrix:sale.basket.basket", "ajax", array("COLUMNS_LIST" => array(0 => "TYPE"), "PATH_TO_ORDER" => "/personal/order.php", "HIDE_COUPON" => "N", "PRICE_VAT_SHOW_VALUE" => "N", "COUNT_DISCOUNT_4_ALL_QUANTITY" => "N", "USE_PREPAYMENT" => "N", "QUANTITY_FLOAT" => "N", "SET_TITLE" => "Y", "ACTION_VARIABLE" => "action", "OFFERS_PROPS" => ""), false);
示例10: UpdateBasketPrices
function UpdateBasketPrices($fuserID, $siteID)
{
$fuserID = (int) $fuserID;
if ($fuserID <= 0) {
return false;
}
$siteID = (string) $siteID;
if ($siteID == '') {
$siteID = SITE_ID;
}
$isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N');
DiscountCouponsManager::clearApply(false);
$basketItems = array();
/*
if (!empty($arBasketItems) && is_array($arBasketItems))
{
foreach ($arBasketItems as &$basketItemData)
{
if (array_key_exists('MEASURE_RATIO', $basketItemData))
{
$basketItemQuantity = floatval($basketItemData['QUANTITY']);
$basketItemRatio = floatval($basketItemData['MEASURE_RATIO']);
$mod = roundEx(($basketItemQuantity / $basketItemRatio - intval($basketItemQuantity / $basketItemRatio)), 6);
if ($mod !== 0)
{
$basketItemData['QUANTITY'] = ceil(ceil($basketItemQuantity) / $basketItemRatio)* $basketItemRatio;
CSaleBasket::Update($basketItemData['ID'], array('QUANTITY' => $basketItemData['QUANTITY']));
}
}
}
unset($basketItemData);
}
*/
$dbBasketItems = CSaleBasket::GetList(array("ALL_PRICE" => "DESC"), array("FUSER_ID" => $fuserID, "LID" => $siteID, "ORDER_ID" => "NULL", "SUBSCRIBE" => "N"), false, false, array("ID", "MODULE", "PRODUCT_ID", "QUANTITY", "CALLBACK_FUNC", "PRODUCT_PROVIDER_CLASS", "CAN_BUY", "DELAY", "NOTES", "TYPE", "SET_PARENT_ID"));
while ($arItem = $dbBasketItems->Fetch()) {
$basketItems[] = $arItem;
}
if (!empty($basketItems) && is_array($basketItems)) {
$basketItems = getRatio($basketItems);
foreach ($basketItems as $basketItem) {
$fields = array();
$basketItem['CALLBACK_FUNC'] = (string) $basketItem['CALLBACK_FUNC'];
$basketItem['PRODUCT_PROVIDER_CLASS'] = (string) $basketItem['PRODUCT_PROVIDER_CLASS'];
if (strval(trim($basketItem['PRODUCT_PROVIDER_CLASS'])) !== '' || strval(trim($basketItem['CALLBACK_FUNC'])) !== '') {
$basketItem['MODULE'] = (string) $basketItem['MODULE'];
$basketItem['PRODUCT_ID'] = (int) $basketItem['PRODUCT_ID'];
$basketItem['QUANTITY'] = (double) $basketItem['QUANTITY'];
if ($productProvider = CSaleBasket::GetProductProvider($basketItem)) {
$fields = $productProvider::GetProductData(array("PRODUCT_ID" => $basketItem["PRODUCT_ID"], "QUANTITY" => $basketItem["QUANTITY"], "RENEWAL" => "N", "CHECK_COUPONS" => 'Y' == $basketItem['CAN_BUY'] && 'N' == $basketItem['DELAY'] ? 'Y' : 'N', "CHECK_DISCOUNT" => CSaleBasketHelper::isSetItem($basketItem) ? 'N' : 'Y', "BASKET_ID" => $basketItem["ID"], "NOTES" => $basketItem["NOTES"]));
} else {
$fields = CSaleBasket::ExecuteCallbackFunction($basketItem["CALLBACK_FUNC"], $basketItem["MODULE"], $basketItem["PRODUCT_ID"], $basketItem["QUANTITY"], "N");
}
if (!empty($fields) && is_array($fields)) {
if ($isOrderConverted == 'Y' && $basketItem['DELAY'] == 'N') {
if (!Sale\Compatible\DiscountCompatibility::isInited()) {
Sale\Compatible\DiscountCompatibility::init();
}
if (Sale\Compatible\DiscountCompatibility::usedByClient()) {
Sale\Compatible\DiscountCompatibility::setBasketItemData($basketItem['ID'], $fields);
}
}
$fields['CAN_BUY'] = 'Y';
$fields['TYPE'] = (int) $basketItem['TYPE'];
$fields['SET_PARENT_ID'] = (int) $basketItem['SET_PARENT_ID'];
} else {
$fields = array('CAN_BUY' => 'N');
}
}
if (array_key_exists('MEASURE_RATIO', $basketItem)) {
$basketItemQuantity = floatval($basketItem['QUANTITY']);
$basketItemRatio = floatval($basketItem['MEASURE_RATIO']);
$mod = roundEx($basketItemQuantity / $basketItemRatio - intval($basketItemQuantity / $basketItemRatio), 6);
if ($mod != 0) {
$fields['QUANTITY'] = floor(ceil($basketItemQuantity) / $basketItemRatio) * $basketItemRatio;
}
}
if (!empty($fields) && is_array($fields)) {
CSaleBasket::Update($basketItem['ID'], $fields);
}
}
}
return true;
}
示例11: DoubleVal
$quantityCatalog = $arParams['QUANTITY_FLOAT'] == 'Y' ? DoubleVal($arElement["CATALOG_QUANTITY"]) : IntVal($arElement["CATALOG_QUANTITY"]);
if ($quantityUser > $quantityCatalog) {
$arShoppingCart[$key]["LIMIT_QUANTITY"] = "Y";
$productLimit = GetMessage("STOF_WARNING_LIMIT_PRODUCT") . " " . $val["NAME"] . "<br>";
$val["QUANTITY"] = $quantityCatalog;
$quantityUser = $quantityCatalog;
} else {
$val["QUANTITY"] = $quantityUser;
}
}
$val["QUANTITY"] = $quantityUser;
$arShoppingCart[$key] = $val;
if ($arShoppingCart["QUANTITY"] != $quantityUser && in_array("QUANTITY", $arParams["COLUMNS_LIST"]) && $quantityUser > 0) {
$arFields = array();
$arFields["QUANTITY"] = $quantityUser;
CSaleBasket::Update($val["ID"], $arFields);
}
}
}
}
$arBasketItems = CSaleOrder::DoCalculateOrder(SITE_ID, $USER->GetID(), $arShoppingCart, $PERSON_TYPE, $arPropValues, $DELIVERY_ID, $PAYSYSTEM_ID, array(), $arErrors, $arWarnings);
if ((count($arErrors) > 0 || count($arWarnings) > 0) && strlen($_REQUEST["AJAX_CALL"]) > 0 && !isset($_POST["BasketRefresh"])) {
foreach ($arErrors as $val) {
$errorMessage .= $val["TEXT"] . "<br>";
}
foreach ($arWarnings as $val) {
$errorMessage .= $val["TEXT"] . "<br>";
}
$arErrors = array();
$arWarnings = array();
$DELIVERY_ID = "";
示例12: recalculateBasket
public function recalculateBasket($arPost)
{
global $USER;
$arRes = array();
if ($this->hideCoupon != "Y")
{
if (isset($arPost["coupon"]) && !empty($arPost["coupon"]))
{
$arRes["VALID_COUPON"] = CCatalogDiscountCoupon::SetCoupon($arPost["coupon"]);
}
if (!isset($arRes["VALID_COUPON"]) || (isset($arRes["VALID_COUPON"]) && $arRes["VALID_COUPON"] === false))
{
CCatalogDiscountCoupon::ClearCoupon();
}
}
$arTmpItems = array();
$dbItems = CSaleBasket::GetList(
array("PRICE" => "DESC"),
array(
"FUSER_ID" => CSaleBasket::GetBasketUserID(),
"LID" => SITE_ID,
"ORDER_ID" => "NULL"
),
false,
false,
array(
"ID", "NAME", "PRODUCT_PROVIDER_CLASS", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID",
"QUANTITY", "DELAY", "CAN_BUY", "CURRENCY", "SUBSCRIBE", "TYPE", "SET_PARENT_ID", "NOTES"
)
);
while ($arItem = $dbItems->Fetch())
{
if (CSaleBasketHelper::isSetItem($arItem))
continue;
$arTmpItems[] = $arItem;
}
if (!empty($arTmpItems) && CModule::IncludeModule("catalog"))
$arTmpItems = getRatio($arTmpItems);
foreach ($arTmpItems as $arItem)
{
$isFloatQuantity = ((isset($arItem["MEASURE_RATIO"]) && floatval($arItem["MEASURE_RATIO"]) > 0 && $arItem["MEASURE_RATIO"] != 1)
|| $this->quantityFloat == "Y") ? true : false;
if (!isset($arPost["QUANTITY_".$arItem["ID"]]) || floatval($arPost["QUANTITY_".$arItem["ID"]]) <= 0)
{
$quantityTmp = ($isFloatQuantity === true) ? floatval($arItem["QUANTITY"]) : intval($arItem["QUANTITY"]);
}
else
{
$quantityTmp = ($isFloatQuantity === true) ? floatval($arPost["QUANTITY_".$arItem["ID"]]) : intval($arPost["QUANTITY_".$arItem["ID"]]);
}
$deleteTmp = ($arPost["DELETE_".$arItem["ID"]] == "Y") ? "Y" : "N";
$delayTmp = ($arPost["DELAY_".$arItem["ID"]] == "Y") ? "Y" : "N";
if ($arItem["CAN_BUY"] == "Y")
{
$res = $this->checkQuantity($arItem, $quantityTmp);
if (!empty($res))
$arRes["WARNING_MESSAGE"][] = $res["ERROR"];
}
if ($deleteTmp == "Y" && in_array("DELETE", $this->columns))
{
if ($arItem["SUBSCRIBE"] == "Y" && is_array($_SESSION["NOTIFY_PRODUCT"][$USER->GetID()]))
unset($_SESSION["NOTIFY_PRODUCT"][$USER->GetID()][$arItem["PRODUCT_ID"]]);
CSaleBasket::Delete($arItem["ID"]);
}
elseif ($arItem["DELAY"] == "N" && $arItem["CAN_BUY"] == "Y")
{
unset($arFields);
$arFields = array();
if (in_array("QUANTITY", $this->columns))
$arFields["QUANTITY"] = $quantityTmp;
if (in_array("DELAY", $this->columns))
$arFields["DELAY"] = $delayTmp;
if (count($arFields) > 0
&&
($arItem["QUANTITY"] != $arFields["QUANTITY"] && in_array("QUANTITY", $this->columns)
|| $arItem["DELAY"] != $arFields["DELAY"] && in_array("DELAY", $this->columns))
)
CSaleBasket::Update($arItem["ID"], $arFields);
}
elseif ($arItem["DELAY"] == "Y" && $arItem["CAN_BUY"] == "Y")
{
unset($arFields);
$arFields = array();
if (in_array("DELAY", $this->columns))
$arFields["DELAY"] = $delayTmp;
//.........这里部分代码省略.........
示例13: __fGetUserShoppingCart
private static function __fGetUserShoppingCart($arProduct, $LID, $recalcOrder)
{
if (!CModule::IncludeModule('sale')) {
return false;
}
$arOrderProductPrice = array();
foreach ($arProduct as $key => $val) {
//$arSortNum[] = $val['PRICE_DEFAULT'];
$arProduct[$key]["PRODUCT_ID"] = intval($val["PRODUCT_ID"]);
$arProduct[$key]["TABLE_ROW_ID"] = $key;
}
//if (count($arProduct) > 0 && count($arSortNum) > 0)
// array_multisort($arSortNum, SORT_DESC, $arProduct);
$i = 0;
foreach ($arProduct as $key => $val) {
$val["QUANTITY"] = abs(str_replace(",", ".", $val["QUANTITY"]));
$val["QUANTITY_DEFAULT"] = $val["QUANTITY"];
$val["PRICE"] = str_replace(",", ".", $val["PRICE"]);
// Y is used when custom price was set in the admin form
if ($val["CALLBACK_FUNC"] == "Y") {
$val["CALLBACK_FUNC"] = false;
$val["CUSTOM_PRICE"] = "Y";
if (isset($val["BASKET_ID"]) || intval($val["BASKET_ID"]) > 0) {
CSaleBasket::Update($val["BASKET_ID"], array("CUSTOM_PRICE" => "Y"));
}
//$val["DISCOUNT_PRICE"] = $val["PRICE_DEFAULT"] - $val["PRICE"];
}
$arOrderProductPrice[$i] = $val;
$arOrderProductPrice[$i]["TABLE_ROW_ID"] = $val["TABLE_ROW_ID"];
$arOrderProductPrice[$i]["PRODUCT_ID"] = intval($val["PRODUCT_ID"]);
$arOrderProductPrice[$i]["NAME"] = htmlspecialcharsback($val["NAME"]);
$arOrderProductPrice[$i]["LID"] = $LID;
$arOrderProductPrice[$i]["CAN_BUY"] = "Y";
if (!isset($val["BASKET_ID"]) || $val["BASKET_ID"] == "") {
/*if ($val["CALLBACK_FUNC"] == "Y")
{
$arOrderProductPrice[$i]["CALLBACK_FUNC"] = '';
$arOrderProductPrice[$i]["DISCOUNT_PRICE"] = 0;
}*/
} else {
$arOrderProductPrice[$i]["ID"] = intval($val["BASKET_ID"]);
if ($recalcOrder != "Y" && $arOrderProductPrice[$i]["CALLBACK_FUNC"] != false) {
unset($arOrderProductPrice[$i]["CALLBACK_FUNC"]);
}
$arNewProps = array();
if (is_array($val["PROPS"])) {
foreach ($val["PROPS"] as $k => $v) {
if ($v["NAME"] != "" and $v["VALUE"] != "") {
$arNewProps[$k] = $v;
}
}
} else {
$arNewProps = array("NAME" => "", "VALUE" => "", "CODE" => "", "SORT" => "");
}
$arOrderProductPrice[$i]["PROPS"] = $arNewProps;
}
$i++;
}
//endforeach $arProduct
return $arOrderProductPrice;
}
示例14: 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);
}
}
}
示例15: GetMessage
exit;
}
} else {
if (isset($_REQUEST['basket_apply']) && isset($_REQUEST['BASKET_ID'])) {
$basketError = GetMessage('BUYER_BASKET_MESS_NULL');
}
}
break;
case "delay_y":
case "delay_n":
$arFields["DELAY"] = $_REQUEST['action'] == "delay_y" ? "Y" : "N";
if (is_array($arID[$LID])) {
foreach ($arID[$LID] as $PRODUCT_ID) {
$dbBasketEl = \Bitrix\Sale\Internals\BasketTable::getList(array('filter' => array("LID" => $LID, "FUSER_ID" => $arFields["FUSER_ID"], "PRODUCT_ID" => $PRODUCT_ID, "ORDER_ID" => "NULL"), 'select' => array('ID')));
$arBasketEl = $dbBasketEl->fetch();
if (!CSaleBasket::Update($arBasketEl["ID"], $arFields)) {
$basketError = GetMessage('BUYER_BASKET_ADD_ERROR');
}
}
//end foreach
}
break;
case "delete_basket":
if (is_array($arID[$LID])) {
foreach ($arID[$LID] as $PRODUCT_ID) {
$dbBasketEl = \Bitrix\Sale\Internals\BasketTable::getList(array('filter' => array("LID" => $LID, "FUSER_ID" => $arFields["FUSER_ID"], "PRODUCT_ID" => $PRODUCT_ID, "ORDER_ID" => "NULL"), 'select' => array('ID')));
$arBasketEl = $dbBasketEl->fetch();
CSaleBasket::Delete($arBasketEl["ID"]);
}
}
break;