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


PHP CSaleBasket::DeductBasketProduct方法代码示例

本文整理汇总了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"]);
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:basket.php

示例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"]);
             }
         }
     }
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:75,代码来源:basket.php


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