I am creating shipments programmatically for an order. The order has 3 shipments, I need each shipment to go to a different address.
The order has same product in qty 3. So each item(qty:1) needs to go to a different address but I am unable to change the address for the shipment. Here's what I've tried so far -
$shippingAddressId = $this->order->getShippingAddress()->getId(); $address = $this->addressRepository->get($shippingAddressId); $anotherAddress = $this->addressRepository->get(6); $address->setCountryId($anotherAddress->getCountryId()); $address->setRegion($anotherAddress->getRegion()); $address->setPostcode($anotherAddress->getPostcode()); $address->setStreet($anotherAddress->getStreet()); $address->setCity($anotherAddress->getCity()); $address->save(); $shipment->setShippingAddressId($shippingAddressId); return;