本文整理汇总了PHP中CSaleBasket::DeductBasketProduct方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleBasket::DeductBasketProduct方法的具体用法?PHP CSaleBasket::DeductBasketProduct怎么用?PHP CSaleBasket::DeductBasketProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleBasket
的用法示例。
在下文中一共展示了CSaleBasket::DeductBasketProduct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DoChangeProductQuantity
/**
* Changes product quantity in the catalog.
* Used in the DoSaveOrderBasket to actualize basket items quantity
* after some operations with the order are made in the order_new form
*
* Depending on the state of the order (reserved/deducted)
* and the state of the product (reserved/deducted) calls appropriate provider methods
*
* If the quantity is 0 and CHECK_QUANTITY is N, this method is used only to call OrderProduct method to actualize coupon data
*
* @param array $arBasketItem - basket item data array
* @param int $deltaQuantity - quantity to be changed. Can be zero, in this case CHECK_QUANTITY should be N
* @param bool $isOrderReserved - order reservation flag
* @param bool $isOrderDeducted - order deduction flag
* @param array $arStoreBarcodeOrderFormData - array of barcode and stores from order_new form to be used for deduction
* @param array $arAdditionalParams - user id, site id, check_quantity flag
* @return bool
*/
public static function DoChangeProductQuantity($arBasketItem, $deltaQuantity, $isOrderReserved = false, $isOrderDeducted = false, $arStoreBarcodeOrderFormData = array(), $arAdditionalParams = array())
{
global $APPLICATION;
if (!array_key_exists("CHECK_QUANTITY", $arAdditionalParams) || $arAdditionalParams["CHECK_QUANTITY"] != "N") {
$arAdditionalParams["CHECK_QUANTITY"] = "Y";
}
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("DoChangeProductQuantity - Started", array("arBasketItem" => $arBasketItem, "deltaQuantity" => $deltaQuantity, "isOrderReserved" => intval($isOrderReserved), "isOrderDeducted" => intval($isOrderDeducted), "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData, "checkQuantity" => $arAdditionalParams["CHECK_QUANTITY"]), "DCPQ1");
}
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasketItem)) {
$productProvider::OrderProduct(array("PRODUCT_ID" => $arBasketItem["PRODUCT_ID"], "QUANTITY" => $deltaQuantity <= 0 ? $arBasketItem['QUANTITY'] : $deltaQuantity, "RENEWAL" => "N", "USER_ID" => $arAdditionalParams["USER_ID"], "SITE_ID" => $arAdditionalParams["SITE_ID"], "CHECK_QUANTITY" => $arAdditionalParams["CHECK_QUANTITY"], "BASKET_ID" => $arBasketItem['ID']));
if ($deltaQuantity == 0 && $arAdditionalParams["CHECK_QUANTITY"] == 'N') {
return true;
}
if ($isOrderDeducted) {
$quantityPreviouslyLeftToReserve = $arBasketItem["RESERVED"] == "Y" ? floatval($arBasketItem["RESERVE_QUANTITY"]) : 0;
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity, "quantityPreviouslyLeftToReserve" => $quantityPreviouslyLeftToReserve, "isOrderDeducted" => $isOrderDeducted), "DCPQ2");
}
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity + $quantityPreviouslyLeftToReserve, $isOrderDeducted);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], Loc::getMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::DeductBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity, "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData), "DCPQ3");
}
$arDeductResult = CSaleBasket::DeductBasketProduct($arBasketItem["ID"], $deltaQuantity, $arStoreBarcodeOrderFormData);
if (array_key_exists("ERROR", $arDeductResult)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], Loc::getMessage("SKGB_DEDUCT_ERROR", array("#MESSAGE#" => $arDeductResult["ERROR"]["MESSAGE"])));
$APPLICATION->ThrowException(Loc::getMessage("SKGB_DEDUCT_ERROR", array("#MESSAGE#" => $arDeductResult["ERROR"]["MESSAGE"])), "DEDUCTION_ERROR");
return false;
}
} else {
if ($isOrderReserved && !$isOrderDeducted) {
if ($arBasketItem["RESERVED"] == "Y") {
$quantityPreviouslyLeftToReserve = floatval($arBasketItem["RESERVE_QUANTITY"]);
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity, "quantityPreviouslyLeftToReserve" => $quantityPreviouslyLeftToReserve), "DCPQ4");
}
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity + $quantityPreviouslyLeftToReserve);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], Loc::getMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
} else {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity), "DCPQ5");
}
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], Loc::getMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
}
} else {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity), "DCPQ6");
}
if ($arBasketItem["RESERVED"] == "Y") {
$quantityPreviouslyLeftToReserve = floatval($arBasketItem["RESERVE_QUANTITY"]);
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity + $quantityPreviouslyLeftToReserve);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], Loc::getMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
}
}
}
} else {
if ($deltaQuantity < 0) {
CSaleBasket::ExecuteCallbackFunction($arBasketItem["CANCEL_CALLBACK_FUNC"], $arBasketItem["MODULE"], $arBasketItem["PRODUCT_ID"], abs($deltaQuantity), true);
} else {
if ($deltaQuantity > 0) {
CSaleBasket::ExecuteCallbackFunction($arBasketItem["ORDER_CALLBACK_FUNC"], $arBasketItem["MODULE"], $arBasketItem["PRODUCT_ID"], $deltaQuantity, "N", $arAdditionalParams["USER_ID"], $arAdditionalParams["SITE_ID"]);
} else {
if ($deltaQuantity == 0) {
CSaleBasket::ExecuteCallbackFunction($arBasketItem["ORDER_CALLBACK_FUNC"], $arBasketItem["MODULE"], $arBasketItem["PRODUCT_ID"], $arBasketItem['QUANTITY'], "N", $arAdditionalParams["USER_ID"], $arAdditionalParams["SITE_ID"]);
}
}
}
//.........这里部分代码省略.........
示例2: DoChangeProductQuantity
public static function DoChangeProductQuantity($arBasketItem, $deltaQuantity, $isOrderReserved = false, $isOrderDeducted = false, $arStoreBarcodeOrderFormData = array(), $arAdditionalParams = array())
{
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("DoChangeProductQuantity - Started", array("arBasketItem" => $arBasketItem, "deltaQuantity" => $deltaQuantity, "isOrderReserved" => intval($isOrderReserved), "isOrderDeducted" => intval($isOrderDeducted), "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData), "DCPQ1");
}
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasketItem)) {
if ($isOrderReserved && $isOrderDeducted) {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::DeductBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity, "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData), "DCPQ2");
}
$arDeductResult = CSaleBasket::DeductBasketProduct($arBasketItem["ID"], $deltaQuantity, $arStoreBarcodeOrderFormData);
if (array_key_exists("ERROR", $arDeductResult)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], GetMessage("SKGB_DEDUCT_ERROR", array("#MESSAGE#" => $arDeductResult["ERROR"]["MESSAGE"])));
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGB_DEDUCT_ERROR", array("#MESSAGE#" => $arDeductResult["ERROR"]["MESSAGE"])), "DEDUCTION_ERROR");
return false;
}
} else {
if (!$isOrderReserved && $isOrderDeducted) {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::DeductBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity, "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData), "DCPQ3");
}
$arDeductResult = CSaleBasket::DeductBasketProduct($arBasketItem["ID"], $deltaQuantity, $arStoreBarcodeOrderFormData);
if (array_key_exists("ERROR", $arDeductResult)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], GetMessage("SKGB_DEDUCT_ERROR", array("#MESSAGE#" => $arDeductResult["ERROR"]["MESSAGE"])));
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGB_DEDUCT_ERROR", array("#MESSAGE#" => $arDeductResult["ERROR"]["MESSAGE"])), "DEDUCTION_ERROR");
return false;
}
} else {
if ($isOrderReserved && !$isOrderDeducted) {
if ($arBasketItem["RESERVED"] == "Y") {
$quantityPreviouslyLeftToReserve = DoubleVal($arBasketItem["RESERVE_QUANTITY"]);
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity, "quantityPreviouslyLeftToReserve" => $quantityPreviouslyLeftToReserve), "DCPQ4");
}
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity + $quantityPreviouslyLeftToReserve);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], GetMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
} else {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity), "DCPQ5");
}
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], GetMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
}
} else {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity), "DCPQ6");
}
if ($arBasketItem["RESERVED"] == "Y") {
$quantityPreviouslyLeftToReserve = DoubleVal($arBasketItem["RESERVE_QUANTITY"]);
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity + $quantityPreviouslyLeftToReserve);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], GetMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
}
}
}
}
} else {
if ($deltaQuantity < 0) {
CSaleBasket::ExecuteCallbackFunction($arBasketItem["CANCEL_CALLBACK_FUNC"], $arBasketItem["MODULE"], $arBasketItem["PRODUCT_ID"], $deltaQuantity, true);
} else {
if ($deltaQuantity > 0) {
CSaleBasket::ExecuteCallbackFunction($arBasketItem["ORDER_CALLBACK_FUNC"], $arBasketItem["MODULE"], $arBasketItem["PRODUCT_ID"], $deltaQuantity, "N", $arAdditionalParams["USER_ID"], $arAdditionalParams["SITE_ID"]);
}
}
}
}