<?php
use Magento\Framework\App\Bootstrap;
require 'app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$now = new \DateTime();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$InvoiceService = $objectManager->create('\Magento\Sales\Model\Service\InvoiceService');
$transaction = $objectManager->create('\Magento\Framework\DB\Transaction');
$loadorder = $objectManager->create('\Magento\Sales\Api\Data\OrderInterfaceFactory')->create();
$order = $loadorder->loadByIncrementId('000001619');
$invoice = $InvoiceService->prepareInvoice($order);
$invoice->register();
$invoice->save();
$transactionSave = $transaction->addObject($invoice)->addObject($invoice->getOrder());
$invoice->getOrder()->setIsInProcess(true);
$transactionSave->save();
$order->addStatusHistoryComment(__('Invoice has been created #%1.', $invoice->getId()))->setIsCustomerNotified(true)->save();
?>
use Magento\Framework\App\Bootstrap;
require 'app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$now = new \DateTime();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$InvoiceService = $objectManager->create('\Magento\Sales\Model\Service\InvoiceService');
$transaction = $objectManager->create('\Magento\Framework\DB\Transaction');
$loadorder = $objectManager->create('\Magento\Sales\Api\Data\OrderInterfaceFactory')->create();
$order = $loadorder->loadByIncrementId('000001619');
$invoice = $InvoiceService->prepareInvoice($order);
$invoice->register();
$invoice->save();
$transactionSave = $transaction->addObject($invoice)->addObject($invoice->getOrder());
$invoice->getOrder()->setIsInProcess(true);
$transactionSave->save();
$order->addStatusHistoryComment(__('Invoice has been created #%1.', $invoice->getId()))->setIsCustomerNotified(true)->save();
?>
This extension generates the invoice automatically on order creation
ReplyDeletehttps://webpanda-solutions.com/auto-invoice-shipment.html
Thank you for sharing such useful information. I really enjoyed while reading your article and it is good to know the latest updates. Do post more. And also read about Magento 2 Development Company
ReplyDeleteSure!
DeleteThank you
Hats off to your presence of mind..I really enjoyed reading your blog. I really appreciate your information which you shared with us.
ReplyDeleteInvoices Apps