Ejemplo n.º 1
0
 /**
  * @param \Bitrix\Sale\Shipment $shipment
  * @throws Main\NotSupportedException
  */
 public static function setShipmentByDefaultValues(&$shipment)
 {
     /** @var \Bitrix\Sale\ShipmentCollection $shipmentCollection */
     $shipmentCollection = $shipment->getCollection();
     $systemShipment = $shipmentCollection->getSystemShipment();
     $systemShipmentItemCollection = $systemShipment->getShipmentItemCollection();
     /** @var \Bitrix\Sale\ShipmentItemCollection $shipmentItemCollection */
     $shipmentItemCollection = $shipment->getShipmentItemCollection();
     /** @var \Bitrix\Sale\ShipmentItem $systemShipmentItem */
     foreach ($systemShipmentItemCollection as $systemShipmentItem) {
         if ($systemShipmentItem->getQuantity() <= 0) {
             continue;
         }
         $basketItem = $systemShipmentItem->getBasketItem();
         $shipmentItem = $shipmentItemCollection->createItem($basketItem);
         $shipmentItem->setField('QUANTITY', $systemShipmentItem->getQuantity());
     }
     $shipment->setField('CUSTOM_PRICE_DELIVERY', 'N');
     $shipment->setField('DELIVERY_ID', $systemShipment->getField('DELIVERY_ID'));
     $shipment->setField('COMPANY_ID', $systemShipment->getField('COMPANY_ID'));
     $shipment->setField('DELIVERY_NAME', $systemShipment->getField('DELIVERY_NAME'));
     $shipment->setExtraServices($systemShipment->getExtraServices());
     $shipment->setStoreId($systemShipment->getStoreId());
     $price = \Bitrix\Sale\Helpers\Admin\Blocks\OrderShipment::getDeliveryPrice($shipment);
     $shipment->setField('BASE_PRICE_DELIVERY', $price);
 }
Ejemplo n.º 2
0
 /**
  * @internal
  * @param Shipment $parentShipment
  * @param Shipment $childShipment
  * @return Result
  * @throws Main\ArgumentOutOfRangeException
  */
 public function cloneShipment(Shipment $parentShipment, Shipment $childShipment)
 {
     foreach (static::getClonedFields() as $fieldName) {
         /** @var Result $r */
         $childShipment->setFieldNoDemand($fieldName, $parentShipment->getField($fieldName));
     }
     $childShipment->setExtraServices($parentShipment->getExtraServices());
     $childShipment->setStoreId($parentShipment->getStoreId());
     return new Result();
 }