How to add new item (product) into existing order programmatically in Magento 2












3















I have created one virtual product in my Magento2 website. Now, I want to add it programmatically to the existing customer orders on some occasions with its custom price and name.



Can someone please guide step by step to achieve this?



Thanks,










share|improve this question



























    3















    I have created one virtual product in my Magento2 website. Now, I want to add it programmatically to the existing customer orders on some occasions with its custom price and name.



    Can someone please guide step by step to achieve this?



    Thanks,










    share|improve this question

























      3












      3








      3








      I have created one virtual product in my Magento2 website. Now, I want to add it programmatically to the existing customer orders on some occasions with its custom price and name.



      Can someone please guide step by step to achieve this?



      Thanks,










      share|improve this question














      I have created one virtual product in my Magento2 website. Now, I want to add it programmatically to the existing customer orders on some occasions with its custom price and name.



      Can someone please guide step by step to achieve this?



      Thanks,







      sales-order magento-2.2.5 programmatically order-items






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 8 '18 at 6:26









      Patrick WPatrick W

      14112




      14112






















          2 Answers
          2






          active

          oldest

          votes


















          3














          After some goggling and with the help of some core modules I came up with following solution :



          /**
          * @var MagentoSalesApiOrderRepositoryInterface
          */
          protected $orderRepository;

          /**
          * @var MagentoCatalogApiProductRepositoryInterface
          */
          protected $productRepository;

          /**
          * @var MagentoQuoteApiDataCartItemInterfaceFactory
          */
          protected $cartItemFactory;

          /**
          * @var MagentoQuoteApiCartRepositoryInterface
          */
          protected $quoteRepository;

          /**
          * @var MagentoSalesModelOrderItemFactory
          */
          protected $orderItemFactory;

          public function __construct(
          MagentoBackendAppActionContext $context,
          MagentoSalesApiOrderRepositoryInterface $orderRepository,
          MagentoCatalogApiProductRepositoryInterface $productRepository,
          MagentoQuoteApiDataCartItemInterfaceFactory $cartItemFactory,
          MagentoQuoteApiCartRepositoryInterface $quoteRepository,
          MagentoSalesModelOrderItemFactory $orderItemFactory
          ) {
          parent::__construct($context);
          $this->productRepository = $productRepository;
          $this->orderRepository = $orderRepository;
          $this->cartItemFactory = $cartItemFactory;
          $this->quoteRepository = $quoteRepository;
          $this->orderItemFactory = $orderItemFactory;
          }

          public function execute()
          {
          $postData = $this->getRequest()->getPostValue();
          $productSku = 'your-product-sku'; // Static Virtual Product created. You may also use static ID.
          $product = $this->productRepository->get($productSku);
          $order = $this->orderRepository->get($postData['order_id']);
          $quote = $this->quoteRepository->get($order->getQuoteId());

          try {
          /* Add Quote Item Start */
          $quoteItem = $this->cartItemFactory->create();
          $quoteItem->setProduct($product);
          $quoteItem->setCustomPrice($postData['custom_price']);
          $quoteItem->setOriginalCustomPrice($postData['custom_price']);
          $quoteItem->getProduct()->setIsSuperMode(true);
          $quote->addItem($quoteItem);
          $quote->collectTotals()->save();
          /* Add Quote Item End */

          /* Add Order Item Start */
          $orderItem = $this->orderItemFactory->create();
          $orderItem
          ->setStoreId($order->getStoreId())
          ->setQuoteItemId($quoteItem->getId())
          ->setProductId($product->getId())
          ->setProductType($product->getTypeId())
          ->setName($product->getName())
          ->setSku($product->getSku())
          ->setQtyOrdered(1)
          ->setPrice($postData['custom_price'])
          ->setBasePrice($postData['custom_price'])
          ->setOriginalPrice($postData['custom_price'])
          ->setBaseOriginalPrice($postData['custom_price'])
          ->setPriceInclTax($postData['custom_price'])
          ->setBasePriceInclTax($postData['custom_price'])
          ->setRowTotal($postData['custom_price'])
          ->setBaseRowTotal($postData['custom_price'])
          ->setRowTotalInclTax($postData['custom_price'])
          ->setBaseRowTotalInclTax($postData['custom_price'])
          ->setWeight(1)
          ->setIsVirtual(1);
          $order->addItem($orderItem);
          /* Add Order Item End */

          /* Update relavant order totals Start */
          $order->setBaseGrandTotal($order->getBaseGrandTotal() + $postData['custom_price']);
          $order->setGrandTotal($order->getGrandTotal() + $postData['custom_price']);
          $order->setBaseSubtotal($order->getBaseSubtotal() + $postData['custom_price']);
          $order->setSubtotal($order->getSubtotal() + $postData['custom_price']);
          $order->setBaseSubtotalInclTax($order->getBaseSubtotalInclTax() + $postData['custom_price']);
          $order->setSubtotalInclTax($order->getSubtotalInclTax() + $postData['custom_price']);
          $order->setTotalItemCount($order->getTotalItemCount() + 1);
          $order->setTotalQtyOrdered($order->getTotalQtyOrdered() + 1);
          $this->orderRepository->save($order);
          /* Update relavant order totals End */
          }
          catch (Exception $e) {
          $this->messageManager->addError($e->getMessage());
          }
          }





          share|improve this answer

































            0














            As per as, Magento you cannot add a new item to an order after that order is placed before. You must have to add your item before it cart has been placed.






            share|improve this answer
























            • Hello @Amit, Many a times you will get these type of requirements in which you need to add virtual product to get some kind of additional fee into your order with custom price. I think this can be possible with custom programming.

              – Patrick W
              Oct 8 '18 at 9:48











            • every platform has it own limitation,.You have to build your logic of requirement according to it

              – Amit Bera
              Oct 8 '18 at 9:58











            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "479"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f245485%2fhow-to-add-new-item-product-into-existing-order-programmatically-in-magento-2%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            After some goggling and with the help of some core modules I came up with following solution :



            /**
            * @var MagentoSalesApiOrderRepositoryInterface
            */
            protected $orderRepository;

            /**
            * @var MagentoCatalogApiProductRepositoryInterface
            */
            protected $productRepository;

            /**
            * @var MagentoQuoteApiDataCartItemInterfaceFactory
            */
            protected $cartItemFactory;

            /**
            * @var MagentoQuoteApiCartRepositoryInterface
            */
            protected $quoteRepository;

            /**
            * @var MagentoSalesModelOrderItemFactory
            */
            protected $orderItemFactory;

            public function __construct(
            MagentoBackendAppActionContext $context,
            MagentoSalesApiOrderRepositoryInterface $orderRepository,
            MagentoCatalogApiProductRepositoryInterface $productRepository,
            MagentoQuoteApiDataCartItemInterfaceFactory $cartItemFactory,
            MagentoQuoteApiCartRepositoryInterface $quoteRepository,
            MagentoSalesModelOrderItemFactory $orderItemFactory
            ) {
            parent::__construct($context);
            $this->productRepository = $productRepository;
            $this->orderRepository = $orderRepository;
            $this->cartItemFactory = $cartItemFactory;
            $this->quoteRepository = $quoteRepository;
            $this->orderItemFactory = $orderItemFactory;
            }

            public function execute()
            {
            $postData = $this->getRequest()->getPostValue();
            $productSku = 'your-product-sku'; // Static Virtual Product created. You may also use static ID.
            $product = $this->productRepository->get($productSku);
            $order = $this->orderRepository->get($postData['order_id']);
            $quote = $this->quoteRepository->get($order->getQuoteId());

            try {
            /* Add Quote Item Start */
            $quoteItem = $this->cartItemFactory->create();
            $quoteItem->setProduct($product);
            $quoteItem->setCustomPrice($postData['custom_price']);
            $quoteItem->setOriginalCustomPrice($postData['custom_price']);
            $quoteItem->getProduct()->setIsSuperMode(true);
            $quote->addItem($quoteItem);
            $quote->collectTotals()->save();
            /* Add Quote Item End */

            /* Add Order Item Start */
            $orderItem = $this->orderItemFactory->create();
            $orderItem
            ->setStoreId($order->getStoreId())
            ->setQuoteItemId($quoteItem->getId())
            ->setProductId($product->getId())
            ->setProductType($product->getTypeId())
            ->setName($product->getName())
            ->setSku($product->getSku())
            ->setQtyOrdered(1)
            ->setPrice($postData['custom_price'])
            ->setBasePrice($postData['custom_price'])
            ->setOriginalPrice($postData['custom_price'])
            ->setBaseOriginalPrice($postData['custom_price'])
            ->setPriceInclTax($postData['custom_price'])
            ->setBasePriceInclTax($postData['custom_price'])
            ->setRowTotal($postData['custom_price'])
            ->setBaseRowTotal($postData['custom_price'])
            ->setRowTotalInclTax($postData['custom_price'])
            ->setBaseRowTotalInclTax($postData['custom_price'])
            ->setWeight(1)
            ->setIsVirtual(1);
            $order->addItem($orderItem);
            /* Add Order Item End */

            /* Update relavant order totals Start */
            $order->setBaseGrandTotal($order->getBaseGrandTotal() + $postData['custom_price']);
            $order->setGrandTotal($order->getGrandTotal() + $postData['custom_price']);
            $order->setBaseSubtotal($order->getBaseSubtotal() + $postData['custom_price']);
            $order->setSubtotal($order->getSubtotal() + $postData['custom_price']);
            $order->setBaseSubtotalInclTax($order->getBaseSubtotalInclTax() + $postData['custom_price']);
            $order->setSubtotalInclTax($order->getSubtotalInclTax() + $postData['custom_price']);
            $order->setTotalItemCount($order->getTotalItemCount() + 1);
            $order->setTotalQtyOrdered($order->getTotalQtyOrdered() + 1);
            $this->orderRepository->save($order);
            /* Update relavant order totals End */
            }
            catch (Exception $e) {
            $this->messageManager->addError($e->getMessage());
            }
            }





            share|improve this answer






























              3














              After some goggling and with the help of some core modules I came up with following solution :



              /**
              * @var MagentoSalesApiOrderRepositoryInterface
              */
              protected $orderRepository;

              /**
              * @var MagentoCatalogApiProductRepositoryInterface
              */
              protected $productRepository;

              /**
              * @var MagentoQuoteApiDataCartItemInterfaceFactory
              */
              protected $cartItemFactory;

              /**
              * @var MagentoQuoteApiCartRepositoryInterface
              */
              protected $quoteRepository;

              /**
              * @var MagentoSalesModelOrderItemFactory
              */
              protected $orderItemFactory;

              public function __construct(
              MagentoBackendAppActionContext $context,
              MagentoSalesApiOrderRepositoryInterface $orderRepository,
              MagentoCatalogApiProductRepositoryInterface $productRepository,
              MagentoQuoteApiDataCartItemInterfaceFactory $cartItemFactory,
              MagentoQuoteApiCartRepositoryInterface $quoteRepository,
              MagentoSalesModelOrderItemFactory $orderItemFactory
              ) {
              parent::__construct($context);
              $this->productRepository = $productRepository;
              $this->orderRepository = $orderRepository;
              $this->cartItemFactory = $cartItemFactory;
              $this->quoteRepository = $quoteRepository;
              $this->orderItemFactory = $orderItemFactory;
              }

              public function execute()
              {
              $postData = $this->getRequest()->getPostValue();
              $productSku = 'your-product-sku'; // Static Virtual Product created. You may also use static ID.
              $product = $this->productRepository->get($productSku);
              $order = $this->orderRepository->get($postData['order_id']);
              $quote = $this->quoteRepository->get($order->getQuoteId());

              try {
              /* Add Quote Item Start */
              $quoteItem = $this->cartItemFactory->create();
              $quoteItem->setProduct($product);
              $quoteItem->setCustomPrice($postData['custom_price']);
              $quoteItem->setOriginalCustomPrice($postData['custom_price']);
              $quoteItem->getProduct()->setIsSuperMode(true);
              $quote->addItem($quoteItem);
              $quote->collectTotals()->save();
              /* Add Quote Item End */

              /* Add Order Item Start */
              $orderItem = $this->orderItemFactory->create();
              $orderItem
              ->setStoreId($order->getStoreId())
              ->setQuoteItemId($quoteItem->getId())
              ->setProductId($product->getId())
              ->setProductType($product->getTypeId())
              ->setName($product->getName())
              ->setSku($product->getSku())
              ->setQtyOrdered(1)
              ->setPrice($postData['custom_price'])
              ->setBasePrice($postData['custom_price'])
              ->setOriginalPrice($postData['custom_price'])
              ->setBaseOriginalPrice($postData['custom_price'])
              ->setPriceInclTax($postData['custom_price'])
              ->setBasePriceInclTax($postData['custom_price'])
              ->setRowTotal($postData['custom_price'])
              ->setBaseRowTotal($postData['custom_price'])
              ->setRowTotalInclTax($postData['custom_price'])
              ->setBaseRowTotalInclTax($postData['custom_price'])
              ->setWeight(1)
              ->setIsVirtual(1);
              $order->addItem($orderItem);
              /* Add Order Item End */

              /* Update relavant order totals Start */
              $order->setBaseGrandTotal($order->getBaseGrandTotal() + $postData['custom_price']);
              $order->setGrandTotal($order->getGrandTotal() + $postData['custom_price']);
              $order->setBaseSubtotal($order->getBaseSubtotal() + $postData['custom_price']);
              $order->setSubtotal($order->getSubtotal() + $postData['custom_price']);
              $order->setBaseSubtotalInclTax($order->getBaseSubtotalInclTax() + $postData['custom_price']);
              $order->setSubtotalInclTax($order->getSubtotalInclTax() + $postData['custom_price']);
              $order->setTotalItemCount($order->getTotalItemCount() + 1);
              $order->setTotalQtyOrdered($order->getTotalQtyOrdered() + 1);
              $this->orderRepository->save($order);
              /* Update relavant order totals End */
              }
              catch (Exception $e) {
              $this->messageManager->addError($e->getMessage());
              }
              }





              share|improve this answer




























                3












                3








                3







                After some goggling and with the help of some core modules I came up with following solution :



                /**
                * @var MagentoSalesApiOrderRepositoryInterface
                */
                protected $orderRepository;

                /**
                * @var MagentoCatalogApiProductRepositoryInterface
                */
                protected $productRepository;

                /**
                * @var MagentoQuoteApiDataCartItemInterfaceFactory
                */
                protected $cartItemFactory;

                /**
                * @var MagentoQuoteApiCartRepositoryInterface
                */
                protected $quoteRepository;

                /**
                * @var MagentoSalesModelOrderItemFactory
                */
                protected $orderItemFactory;

                public function __construct(
                MagentoBackendAppActionContext $context,
                MagentoSalesApiOrderRepositoryInterface $orderRepository,
                MagentoCatalogApiProductRepositoryInterface $productRepository,
                MagentoQuoteApiDataCartItemInterfaceFactory $cartItemFactory,
                MagentoQuoteApiCartRepositoryInterface $quoteRepository,
                MagentoSalesModelOrderItemFactory $orderItemFactory
                ) {
                parent::__construct($context);
                $this->productRepository = $productRepository;
                $this->orderRepository = $orderRepository;
                $this->cartItemFactory = $cartItemFactory;
                $this->quoteRepository = $quoteRepository;
                $this->orderItemFactory = $orderItemFactory;
                }

                public function execute()
                {
                $postData = $this->getRequest()->getPostValue();
                $productSku = 'your-product-sku'; // Static Virtual Product created. You may also use static ID.
                $product = $this->productRepository->get($productSku);
                $order = $this->orderRepository->get($postData['order_id']);
                $quote = $this->quoteRepository->get($order->getQuoteId());

                try {
                /* Add Quote Item Start */
                $quoteItem = $this->cartItemFactory->create();
                $quoteItem->setProduct($product);
                $quoteItem->setCustomPrice($postData['custom_price']);
                $quoteItem->setOriginalCustomPrice($postData['custom_price']);
                $quoteItem->getProduct()->setIsSuperMode(true);
                $quote->addItem($quoteItem);
                $quote->collectTotals()->save();
                /* Add Quote Item End */

                /* Add Order Item Start */
                $orderItem = $this->orderItemFactory->create();
                $orderItem
                ->setStoreId($order->getStoreId())
                ->setQuoteItemId($quoteItem->getId())
                ->setProductId($product->getId())
                ->setProductType($product->getTypeId())
                ->setName($product->getName())
                ->setSku($product->getSku())
                ->setQtyOrdered(1)
                ->setPrice($postData['custom_price'])
                ->setBasePrice($postData['custom_price'])
                ->setOriginalPrice($postData['custom_price'])
                ->setBaseOriginalPrice($postData['custom_price'])
                ->setPriceInclTax($postData['custom_price'])
                ->setBasePriceInclTax($postData['custom_price'])
                ->setRowTotal($postData['custom_price'])
                ->setBaseRowTotal($postData['custom_price'])
                ->setRowTotalInclTax($postData['custom_price'])
                ->setBaseRowTotalInclTax($postData['custom_price'])
                ->setWeight(1)
                ->setIsVirtual(1);
                $order->addItem($orderItem);
                /* Add Order Item End */

                /* Update relavant order totals Start */
                $order->setBaseGrandTotal($order->getBaseGrandTotal() + $postData['custom_price']);
                $order->setGrandTotal($order->getGrandTotal() + $postData['custom_price']);
                $order->setBaseSubtotal($order->getBaseSubtotal() + $postData['custom_price']);
                $order->setSubtotal($order->getSubtotal() + $postData['custom_price']);
                $order->setBaseSubtotalInclTax($order->getBaseSubtotalInclTax() + $postData['custom_price']);
                $order->setSubtotalInclTax($order->getSubtotalInclTax() + $postData['custom_price']);
                $order->setTotalItemCount($order->getTotalItemCount() + 1);
                $order->setTotalQtyOrdered($order->getTotalQtyOrdered() + 1);
                $this->orderRepository->save($order);
                /* Update relavant order totals End */
                }
                catch (Exception $e) {
                $this->messageManager->addError($e->getMessage());
                }
                }





                share|improve this answer















                After some goggling and with the help of some core modules I came up with following solution :



                /**
                * @var MagentoSalesApiOrderRepositoryInterface
                */
                protected $orderRepository;

                /**
                * @var MagentoCatalogApiProductRepositoryInterface
                */
                protected $productRepository;

                /**
                * @var MagentoQuoteApiDataCartItemInterfaceFactory
                */
                protected $cartItemFactory;

                /**
                * @var MagentoQuoteApiCartRepositoryInterface
                */
                protected $quoteRepository;

                /**
                * @var MagentoSalesModelOrderItemFactory
                */
                protected $orderItemFactory;

                public function __construct(
                MagentoBackendAppActionContext $context,
                MagentoSalesApiOrderRepositoryInterface $orderRepository,
                MagentoCatalogApiProductRepositoryInterface $productRepository,
                MagentoQuoteApiDataCartItemInterfaceFactory $cartItemFactory,
                MagentoQuoteApiCartRepositoryInterface $quoteRepository,
                MagentoSalesModelOrderItemFactory $orderItemFactory
                ) {
                parent::__construct($context);
                $this->productRepository = $productRepository;
                $this->orderRepository = $orderRepository;
                $this->cartItemFactory = $cartItemFactory;
                $this->quoteRepository = $quoteRepository;
                $this->orderItemFactory = $orderItemFactory;
                }

                public function execute()
                {
                $postData = $this->getRequest()->getPostValue();
                $productSku = 'your-product-sku'; // Static Virtual Product created. You may also use static ID.
                $product = $this->productRepository->get($productSku);
                $order = $this->orderRepository->get($postData['order_id']);
                $quote = $this->quoteRepository->get($order->getQuoteId());

                try {
                /* Add Quote Item Start */
                $quoteItem = $this->cartItemFactory->create();
                $quoteItem->setProduct($product);
                $quoteItem->setCustomPrice($postData['custom_price']);
                $quoteItem->setOriginalCustomPrice($postData['custom_price']);
                $quoteItem->getProduct()->setIsSuperMode(true);
                $quote->addItem($quoteItem);
                $quote->collectTotals()->save();
                /* Add Quote Item End */

                /* Add Order Item Start */
                $orderItem = $this->orderItemFactory->create();
                $orderItem
                ->setStoreId($order->getStoreId())
                ->setQuoteItemId($quoteItem->getId())
                ->setProductId($product->getId())
                ->setProductType($product->getTypeId())
                ->setName($product->getName())
                ->setSku($product->getSku())
                ->setQtyOrdered(1)
                ->setPrice($postData['custom_price'])
                ->setBasePrice($postData['custom_price'])
                ->setOriginalPrice($postData['custom_price'])
                ->setBaseOriginalPrice($postData['custom_price'])
                ->setPriceInclTax($postData['custom_price'])
                ->setBasePriceInclTax($postData['custom_price'])
                ->setRowTotal($postData['custom_price'])
                ->setBaseRowTotal($postData['custom_price'])
                ->setRowTotalInclTax($postData['custom_price'])
                ->setBaseRowTotalInclTax($postData['custom_price'])
                ->setWeight(1)
                ->setIsVirtual(1);
                $order->addItem($orderItem);
                /* Add Order Item End */

                /* Update relavant order totals Start */
                $order->setBaseGrandTotal($order->getBaseGrandTotal() + $postData['custom_price']);
                $order->setGrandTotal($order->getGrandTotal() + $postData['custom_price']);
                $order->setBaseSubtotal($order->getBaseSubtotal() + $postData['custom_price']);
                $order->setSubtotal($order->getSubtotal() + $postData['custom_price']);
                $order->setBaseSubtotalInclTax($order->getBaseSubtotalInclTax() + $postData['custom_price']);
                $order->setSubtotalInclTax($order->getSubtotalInclTax() + $postData['custom_price']);
                $order->setTotalItemCount($order->getTotalItemCount() + 1);
                $order->setTotalQtyOrdered($order->getTotalQtyOrdered() + 1);
                $this->orderRepository->save($order);
                /* Update relavant order totals End */
                }
                catch (Exception $e) {
                $this->messageManager->addError($e->getMessage());
                }
                }






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 20 mins ago









                Teja Bhagavan Kollepara

                2,94841847




                2,94841847










                answered Oct 10 '18 at 6:14









                Patrick WPatrick W

                14112




                14112

























                    0














                    As per as, Magento you cannot add a new item to an order after that order is placed before. You must have to add your item before it cart has been placed.






                    share|improve this answer
























                    • Hello @Amit, Many a times you will get these type of requirements in which you need to add virtual product to get some kind of additional fee into your order with custom price. I think this can be possible with custom programming.

                      – Patrick W
                      Oct 8 '18 at 9:48











                    • every platform has it own limitation,.You have to build your logic of requirement according to it

                      – Amit Bera
                      Oct 8 '18 at 9:58
















                    0














                    As per as, Magento you cannot add a new item to an order after that order is placed before. You must have to add your item before it cart has been placed.






                    share|improve this answer
























                    • Hello @Amit, Many a times you will get these type of requirements in which you need to add virtual product to get some kind of additional fee into your order with custom price. I think this can be possible with custom programming.

                      – Patrick W
                      Oct 8 '18 at 9:48











                    • every platform has it own limitation,.You have to build your logic of requirement according to it

                      – Amit Bera
                      Oct 8 '18 at 9:58














                    0












                    0








                    0







                    As per as, Magento you cannot add a new item to an order after that order is placed before. You must have to add your item before it cart has been placed.






                    share|improve this answer













                    As per as, Magento you cannot add a new item to an order after that order is placed before. You must have to add your item before it cart has been placed.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Oct 8 '18 at 8:51









                    Amit BeraAmit Bera

                    58.2k1475174




                    58.2k1475174













                    • Hello @Amit, Many a times you will get these type of requirements in which you need to add virtual product to get some kind of additional fee into your order with custom price. I think this can be possible with custom programming.

                      – Patrick W
                      Oct 8 '18 at 9:48











                    • every platform has it own limitation,.You have to build your logic of requirement according to it

                      – Amit Bera
                      Oct 8 '18 at 9:58



















                    • Hello @Amit, Many a times you will get these type of requirements in which you need to add virtual product to get some kind of additional fee into your order with custom price. I think this can be possible with custom programming.

                      – Patrick W
                      Oct 8 '18 at 9:48











                    • every platform has it own limitation,.You have to build your logic of requirement according to it

                      – Amit Bera
                      Oct 8 '18 at 9:58

















                    Hello @Amit, Many a times you will get these type of requirements in which you need to add virtual product to get some kind of additional fee into your order with custom price. I think this can be possible with custom programming.

                    – Patrick W
                    Oct 8 '18 at 9:48





                    Hello @Amit, Many a times you will get these type of requirements in which you need to add virtual product to get some kind of additional fee into your order with custom price. I think this can be possible with custom programming.

                    – Patrick W
                    Oct 8 '18 at 9:48













                    every platform has it own limitation,.You have to build your logic of requirement according to it

                    – Amit Bera
                    Oct 8 '18 at 9:58





                    every platform has it own limitation,.You have to build your logic of requirement according to it

                    – Amit Bera
                    Oct 8 '18 at 9:58


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f245485%2fhow-to-add-new-item-product-into-existing-order-programmatically-in-magento-2%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    What other Star Trek series did the main TNG cast show up in?

                    Berlina muro

                    Berlina aerponto