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


PHP Order::setMathActionOnly方法代码示例

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


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

示例1: updateData


//.........这里部分代码省略.........
                         unset($tmp['BARCODE']);
                         $shippingItems[] = $tmp;
                     }
                 }
             } else {
                 $shippingItems[] = $tmp;
             }
         }
     }
     // DELETE FROM COLLECTION
     /** @var \Bitrix\Sale\ShipmentItem $shipmentItem */
     foreach ($shipmentItemCollection as $shipmentItem) {
         if (!array_key_exists($shipmentItem->getBasketCode(), $idsFromForm)) {
             /** @var Result $r */
             $r = $shipmentItem->delete();
             if (!$r->isSuccess()) {
                 $result->addErrors($r->getErrors());
             }
         }
         $shipmentItemStoreCollection = $shipmentItem->getShipmentItemStoreCollection();
         /** @var \Bitrix\Sale\ShipmentItemStore $shipmentItemStore */
         foreach ($shipmentItemStoreCollection as $shipmentItemStore) {
             $shipmentItemId = $shipmentItemStore->getId();
             if (!isset($idsFromForm[$shipmentItem->getBasketCode()]['BARCODE_IDS'][$shipmentItemId])) {
                 $delResult = $shipmentItemStore->delete();
                 if (!$delResult->isSuccess()) {
                     $result->addErrors($delResult->getErrors());
                 }
             }
         }
     }
     $isStartField = $shipmentItemCollection->isStartField();
     // SET DATA
     foreach ($shippingItems as $shippingItem) {
         if ((int) $shippingItem['ORDER_DELIVERY_BASKET_ID'] <= 0) {
             $basketCode = $shippingItem['BASKET_CODE'];
             /** @var \Bitrix\Sale\Order $order */
             $basketItem = $order->getBasket()->getItemByBasketCode($basketCode);
             /** @var \Bitrix\Sale\BasketItem $basketItem */
             $shipmentItem = $shipmentItemCollection->createItem($basketItem);
             if ($shipmentItem === null) {
                 $result->addError(new EntityError(Loc::getMessage('SALE_ORDER_SHIPMENT_BASKET_ERROR_ALREADY_SHIPPED')));
                 return $result;
             }
             unset($shippingItem['BARCODE']['ORDER_DELIVERY_BASKET_ID']);
         } else {
             $shipmentItem = $shipmentItemCollection->getItemById($shippingItem['ORDER_DELIVERY_BASKET_ID']);
             $basketItem = $shipmentItem->getBasketItem();
         }
         if ($shipmentItem->getQuantity() < $shippingItem['AMOUNT']) {
             $order->setMathActionOnly(true);
             $setFieldResult = $shipmentItem->setField('QUANTITY', $shippingItem['AMOUNT']);
             $order->setMathActionOnly(false);
             if (!$setFieldResult->isSuccess()) {
                 $result->addErrors($setFieldResult->getErrors());
             }
         }
         if (!empty($shippingItem['BARCODE']) && self::$useStoreControl) {
             $barcode = $shippingItem['BARCODE'];
             /** @var \Bitrix\Sale\ShipmentItemStoreCollection $shipmentItemStoreCollection */
             $shipmentItemStoreCollection = $shipmentItem->getShipmentItemStoreCollection();
             if (!$basketItem->isBarcodeMulti()) {
                 /** @var Result $r */
                 $r = $shipmentItemStoreCollection->setBarcodeQuantityFromArray($shipmentBasket[$basketItem->getId()]);
                 if (!$r->isSuccess()) {
                     $result->addErrors($r->getErrors());
                 }
             }
             if (isset($barcode['ID']) && intval($barcode['ID']) > 0) {
                 /** @var \Bitrix\Sale\ShipmentItemStore $shipmentItemStore */
                 if ($shipmentItemStore = $shipmentItemStoreCollection->getItemById($barcode['ID'])) {
                     unset($barcode['ID']);
                     $setFieldResult = $shipmentItemStore->setFields($barcode);
                     if (!$setFieldResult->isSuccess()) {
                         $result->addErrors($setFieldResult->getErrors());
                     }
                 }
             } else {
                 $shipmentItemStore = $shipmentItemStoreCollection->createItem($basketItem);
                 $setFieldResult = $shipmentItemStore->setFields($barcode);
                 if (!$setFieldResult->isSuccess()) {
                     $result->addErrors($setFieldResult->getErrors());
                 }
             }
         }
         $setFieldResult = $shipmentItem->setField('QUANTITY', $shippingItem['AMOUNT']);
         if (!$setFieldResult->isSuccess()) {
             $result->addErrors($setFieldResult->getErrors());
         }
     }
     if ($isStartField) {
         $hasMeaningfulFields = $shipmentItemCollection->hasMeaningfulField();
         /** @var Result $r */
         $r = $shipmentItemCollection->doFinalAction($hasMeaningfulFields);
         if (!$r->isSuccess()) {
             $result->addErrors($r->getErrors());
         }
     }
     return $result;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:101,代码来源:orderbasketshipment.php


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