Post by MajorPain » Fri Sep 24, 2021 1:23 am

Not sure if this is possible, but thought I'd ask.

I have removed the invoice prefix so that I get standard 4 digit invoices.
On my previous website, I am up to about invoice #2850.
After installing Opencart it would start over at 0001.
Is there a way to jump the last invoice number up to 2850 so that invoice number continue in sequence?
eg. 2851, 2852, ...

Active Member

Posts

Joined
Mon Jul 09, 2018 9:05 am

Post by straightlight » Fri Sep 24, 2021 1:49 am

OC version. An Event trigger could easily accomplish this. If there are no extensions that can offer this kind of functionality, you could always create a new service request in the Commercial Support section of the forum, or contact me directly via the forum PM, to get this done as a custom job.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by MajorPain » Fri Sep 24, 2021 2:11 am

3.0.3.8

Active Member

Posts

Joined
Mon Jul 09, 2018 9:05 am

Post by thekrotek » Fri Sep 24, 2021 2:30 am

OC version doesn't matter here. Just change the auto increment value via DB. Use Google to find a solution, easy to do.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by MajorPain » Fri Sep 24, 2021 3:24 am

thekrotek wrote:
Fri Sep 24, 2021 2:30 am
OC version doesn't matter here. Just change the auto increment value via DB. Use Google to find a solution, easy to do.
I figured that was the way but looking at the oc_order table, order id is the only one auto incremented.
Looking at it I guess I would have to enable a_i for invoice and then I guess change it.
Nothing something I'm comfortable playing with on my own.

Active Member

Posts

Joined
Mon Jul 09, 2018 9:05 am

Post by straightlight » Fri Sep 24, 2021 3:30 am

MajorPain wrote:
Fri Sep 24, 2021 3:24 am
thekrotek wrote:
Fri Sep 24, 2021 2:30 am
OC version doesn't matter here. Just change the auto increment value via DB. Use Google to find a solution, easy to do.
I figured that was the way but looking at the oc_order table, order id is the only one auto incremented.
Looking at it I guess I would have to enable a_i for invoice and then I guess change it.
[Nothing something I'm comfortable playing with on my own.
Then, my previous reply regarding custom job would be the right course of action.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by MajorPain » Fri Sep 24, 2021 3:35 am

Just out of curiosity, if the database has the invoice_no as default 0, wouldn't changing that to say 2850 then start the first invoice at 2851?
Or am I reading that all wrong?

Active Member

Posts

Joined
Mon Jul 09, 2018 9:05 am

Post by straightlight » Fri Sep 24, 2021 4:55 am

MajorPain wrote:
Fri Sep 24, 2021 3:35 am
Just out of curiosity, if the database has the invoice_no as default 0, wouldn't changing that to say 2850 then start the first invoice at 2851?
Or am I reading that all wrong?
That would be incorrect. The default attribute is not a starting point, it is a default value from everything else than what hasn't been defined as a number during the action. Setting 2850 as default while no other number might be defined until a number gets defined in this field will create a conflict and may create confusion while analyzing the orders.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by ADD Creative » Fri Sep 24, 2021 5:26 am

If you already have orders with the invoice_no column set. Just change one of the numbers in the database. When you next create an invoice the highest number plus one will be used.

If you don't have any orders with invoice numbers, just change this line.
https://github.com/opencart/opencart/bl ... r.php#L420

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by straightlight » Fri Sep 24, 2021 6:19 am

Take note that if considering to change the invoice number on the database directly, you must also ensure to change the invoice number as well on the payment provider's end in order to capture the right results via their API.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by ADD Creative » Fri Sep 24, 2021 4:14 pm

straightlight wrote:
Fri Sep 24, 2021 6:19 am
Take note that if considering to change the invoice number on the database directly, you must also ensure to change the invoice number as well on the payment provider's end in order to capture the right results via their API.
No you don't. The invoice number is never sent to the payment provider. You are getting confused with the order ID.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by paulfeakins » Fri Sep 24, 2021 6:54 pm

It might not be what you need to do, but to set the Auto Increment value, it's done like this:

Code: Select all

ALTER TABLE oc_order AUTO_INCREMENT=100; 
https://www.w3schools.com/sql/sql_autoincrement.asp

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by straightlight » Fri Sep 24, 2021 7:28 pm

paulfeakins wrote:
Fri Sep 24, 2021 6:54 pm
It might not be what you need to do, but to set the Auto Increment value, it's done like this:

Code: Select all

ALTER TABLE oc_order AUTO_INCREMENT=100; 
https://www.w3schools.com/sql/sql_autoincrement.asp
By doing that, it will be auto-incremented by 100 but will not increment by one afterwards. It will keep increment by 100.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by TomOhio » Sat Dec 30, 2023 10:05 pm

Simply go into the oc_order table via phpmyadmin and change the highest "order_id" number to what you want as a starting point. While at it, you can also set the invoice number by changing the "invoice_no" field. Pretty straight forward actually.

Newbie

Posts

Joined
Thu Jan 27, 2022 9:07 pm
Who is online

Users browsing this forum: alanjones, Google [Bot] and 86 guests