While creating order programmatically, I just want to set tax and discount which was applied for the order.

And If the order was used multiple shipping address feature, then how can I set multiple shipping address while creating it. However billing address can be set as follows:

$orderData = [
                        'currency_id'  => 'USD',
                        'email'        => $ordValue[0],
                        'billing_address' =>[
                            'firstname'    => $ordValue[15], //address Details
                            'lastname'     => $ordValue[16],
                            'street' => $ordValue[17],
                            'city' => $ordValue[18],
                            'country_id' => $ordValue[19],
                            'region_id' => $ordValue[20],
                            'region' => $ordValue[20],
                            'postcode' => $ordValue[21],
                            'telephone' => $ordValue[22],
                            'fax' => $ordValue[23],
                            'save_in_address_book' => 1

And it can be added into the quote as


If anybody knows, please post our solution which would be really helpful to me.


1 Answer 1


I tried applying all these things during the order creation. But that was not taken as the quote will ready to convert as order. Anyway after creating the order we will get the order id. Using the id we will load the order and set the tax and discount amount as following:

$orderId = $order->getRealOrderId();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$orderInfo = $objectManager->create('\Magento\Sales\Model\Order')->load($orderId);

$shippingAmount = 15;//$ordValue[27];
$discountAmount = 12;//$ordValue[34];



However, I'm unable to find the solution for setting up the multiple shipping address for order.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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