/** * @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); }
protected function getDefaultDeliveryPriceAction() { $formData = isset($this->request["formData"]) ? $this->request["formData"] : array(); $formData['ID'] = $formData['order_id']; $order = $this->getOrder($formData); $result = Admin\Blocks\OrderShipment::updateData($order, $formData['SHIPMENT']); $data = $result->getData(); /** @var \Bitrix\Sale\Shipment $shipment */ $shipment = array_shift($data['SHIPMENT']); $deliveryPrice = Admin\Blocks\OrderShipment::getDeliveryPrice($shipment); $this->addResultData("RESULT", array("CUSTOM_PRICE" => $deliveryPrice)); }