0

Magento\Sales\Model\Order\ShipmentRepository how can i check the shipping method in this repository?

0

You can not get shipping Method Info from Magento\Sales\Model\Order\ShipmentRepository. You have to use Magento\Sales\Api\OrderRepositoryInterface.

You can get Order id from ShipmentRepository and after that Get Order Shipping methof information using OrderRepositoryInterface::get($orderId)

Code

        $id = 1;
    /**
     * $this->shipmentRepository instead of \Magento\Sales\Model\Order\ShipmentRepository
     */
    $shipment =$this->shipmentRepository->get($id);
    $orderId = $shipment->getOrderId();
    if($orderId){
        /**
         * $this->orderRepository instance of \Magento\Sales\Api\OrderRepositoryInterface
         */
        $order = $this->orderRepository->get($orderId);
        $shippingDescription = $order->getShippingDescription();
        $order->getShippingMethod();
        $order->getShippingAddress()->getShippingMethod();
    }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.