Change Order ID

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
After inserting an order NopCommerce shows the Order.ID to the user. But I am integrating NopCommerce to our ERP system, thus inserting an order in our system via webservice and after inserting our system does return an ID. Now I want to save and show this ID in NopCommerce. Is there a way to insert my Id in Oder.ID column?
7 years ago
MbProg wrote:
After inserting an order NopCommerce shows the Order.ID to the user. But I am integrating NopCommerce to our ERP system, thus inserting an order in our system via webservice and after inserting our system does return an ID. Now I want to save and show this ID in NopCommerce. Is there a way to insert my Id in Oder.ID column?


Order.ID is primary key field and it is auto incremented.
I think you can use OrderGuid for doing this things.
7 years ago
MbProg wrote:
After inserting an order NopCommerce shows the Order.ID to the user. But I am integrating NopCommerce to our ERP system, thus inserting an order in our system via webservice and after inserting our system does return an ID. Now I want to save and show this ID in NopCommerce. Is there a way to insert my Id in Oder.ID column?



Mr. Sohel's suggestion is the right way but after that if you want to insert your Id to Order Table Id(OrderId) then, first you need to make "IDENTITY_INSERT" ON.

The query is something like

_dbContext.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[Order] ON INSERT INTO [dbo].[Order]("+
                                  "[Id],"+
                                  "[OrderGuid]")" +
                                  "VALUES('" + Convert.ToInt32(order.OrderId) + "',"+
                                  "'" + new Guid(order.OrderGuid) + "')");


  _dbContext.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[Order] OFF");

Please remember the Id field also PK so the duplicate value will not be inserted.
7 years ago
sohel wrote:
After inserting an order NopCommerce shows the Order.ID to the user. But I am integrating NopCommerce to our ERP system, thus inserting an order in our system via webservice and after inserting our system does return an ID. Now I want to save and show this ID in NopCommerce. Is there a way to insert my Id in Oder.ID column?

Order.ID is primary key field and it is auto incremented.
I think you can use OrderGuid for doing this things.

But OrderGuid is a uniqueIdentifier. The id that I want to insert is an integer. I cannot insert an integer in the GUID? Or do you mean that I should use some kind of regular expression and read my ID from a custom GUID i.e. id ffffffff-ffff-ffff-ffff-ffff[id]?
7 years ago
In the upcoming version 3.90 you can use custom order numbers (number or string)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.