How to generate an invoice for a manually created order

Al Burns asked on October 28, 2020 11:43

Hi. How can I manually trigger the "Generate Invoice" action, or generate the invoice, for an order I have manually created using the API?

Recent Answers


Dmitry Bastron answered on October 29, 2020 00:20

Hi Al,

The following code should do the trick:

ShoppingCartInfo sci = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderId);
string orderInvoice = ShoppingCartInfoProvider.GetOrderInvoice(sci);

The code is taken from \CMS\CMSModules\Ecommerce\Pages\Tools\Orders\Order_Edit_Invoice.aspx.cs which is a page you see in CMS admin.

0 votesVote for this answer Mark as a Correct answer

Al Burns answered on October 29, 2020 12:46

Hi Dmitry, thanks for your reply.

My issue was more around ensuring the invoice was visible on the invoice tab for an order completed manually without having to click the "Generate Invoice" button.

I managed to figure it out by manually creating a shopping cart and calling the ShoppingCartInfoProvider.SetOrder method with the 2nd parameter set to true.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.