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


PHP Provider::tryReserveShipmentItem方法代码示例

本文整理汇总了PHP中Provider::tryReserveShipmentItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Provider::tryReserveShipmentItem方法的具体用法?PHP Provider::tryReserveShipmentItem怎么用?PHP Provider::tryReserveShipmentItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Provider的用法示例。


在下文中一共展示了Provider::tryReserveShipmentItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tryReserve

 /**
  * @throws Main\ArgumentOutOfRangeException
  * @throws Main\NotSupportedException
  * @throws \Exception
  */
 public function tryReserve()
 {
     return Provider::tryReserveShipmentItem($this);
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:9,代码来源:shipmentitem.php

示例2: syncQuantityAfterModify

 /**
  * @internal
  *
  * @param BasketItem $basketItem
  * @param $value
  * @param $oldValue
  *
  * @return Result
  */
 public function syncQuantityAfterModify(BasketItem $basketItem, $value = null, $oldValue = null)
 {
     $result = new Result();
     $shipmentItemCollection = $this->getShipmentItemCollection();
     $shipmentItem = $shipmentItemCollection->getItemByBasketCode($basketItem->getBasketCode());
     if ($shipmentItem === null) {
         if ($value == 0) {
             return new Result();
         }
         $shipmentItem = $shipmentItemCollection->createItem($basketItem);
     }
     $deltaQuantity = $value - $oldValue;
     if ($deltaQuantity > 0) {
         $shipmentItem->setFieldNoDemand("QUANTITY", $shipmentItem->getField("QUANTITY") + $deltaQuantity);
         if ($this->needReservation()) {
             Provider::tryReserveShipmentItem($shipmentItem);
         }
     } else {
         if (floatval($shipmentItem->getField("QUANTITY")) <= 0) {
             return new Result();
         }
         if ($value != 0 && $shipmentItem->getField("QUANTITY") < -$deltaQuantity) {
             $result = new Result();
             $result->addError(new ResultError(str_replace(array("#NAME#", "#QUANTITY#", "#DELTA_QUANTITY#"), array($basketItem->getField("NAME"), $shipmentItem->getField("QUANTITY"), abs($deltaQuantity)), Loc::getMessage('SALE_SHIPMENT_SYSTEM_QUANTITY_ERROR')), 'SALE_SHIPMENT_SYSTEM_QUANTITY_ERROR'));
             return $result;
         }
         if ($value > 0) {
             $shipmentItem->setFieldNoDemand("QUANTITY", $shipmentItem->getField("QUANTITY") + $deltaQuantity);
             if ($this->needReservation()) {
                 Provider::tryReserveShipmentItem($shipmentItem);
             }
         } else {
             $shipmentItem->setFieldNoDemand("QUANTITY", 0);
         }
     }
     return $result;
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:46,代码来源:shipment.php

示例3: onBasketModify

 /**
  * @param $action
  * @param BasketItem $basketItem
  * @param null $name
  * @param null $oldValue
  * @param null $value
  */
 public function onBasketModify($action, BasketItem $basketItem, $name = null, $oldValue = null, $value = null)
 {
     switch ($action) {
         case "UPDATE":
             if ($name == "QUANTITY") {
                 /** @var ShipmentItemCollection $collection */
                 $collection = $this->getCollection();
                 $shipment = $collection->getShipment();
                 if ($shipment->isShipped() != "Y") {
                     return true;
                 }
                 if ($basketItem->getBasketCode() != $this->getBasketCode()) {
                     return true;
                 }
                 $quantity = $value - $oldValue;
                 if ($quantity != 0) {
                     $result = Provider::tryReserveShipmentItem($this);
                 }
                 if (!empty($result) && is_array($result)) {
                     $this->setField('RESERVED_QUANTITY', $result['QUANTITY']);
                     if ($quantity > 0) {
                         if ($this->getQuantity() != $this->getReservedQuantity()) {
                             /** @var ShipmentItemCollection $shipmentItemCollection */
                             $shipmentItemCollection = $this->getCollection();
                             /** @var Shipment $shipment */
                             $shipment = $shipmentItemCollection->getShipment();
                             $shipment->setMark();
                         }
                     }
                 }
             }
             //change quantity
             break;
         case "DELETE":
             // unreserve
             break;
     }
 }
开发者ID:Satariall,项目名称:izurit,代码行数:45,代码来源:shipmentitem.php


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