當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。