Post by eighteenhk » Fri Mar 15, 2019 4:07 pm

Hello Everyone.

May I ask how to change the id? I already know I can add prefix, but I want the order id become either the date or random.
For example: Order time: 2019-03-15 16:05:23 Order ID: 2019031516052301 etc...
If this is impossible, can I make it randomly? I don't want the customer know how many orders of my store. Thanks!! :)

Newbie

Posts

Joined
Thu Feb 14, 2019 10:11 pm

Post by thekrotek » Fri Mar 15, 2019 4:09 pm

You don't change order_id and you can't make it random.

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 eighteenhk » Fri Mar 15, 2019 5:34 pm

thekrotek wrote:
Fri Mar 15, 2019 4:09 pm
You don't change order_id and you can't make it random.
so it is impossible to hide my order number from customer?
How about the invoice number?

Newbie

Posts

Joined
Thu Feb 14, 2019 10:11 pm

Post by paulfeakins » Fri Mar 15, 2019 6:54 pm

eighteenhk wrote:
Fri Mar 15, 2019 5:34 pm
How about the invoice number?
You should be able to make something different appear on the confirmation emails by editing that template.

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 thekrotek » Fri Mar 15, 2019 7:09 pm

eighteenhk wrote:
Fri Mar 15, 2019 5:34 pm
How about the invoice number?
By default, invoice number is just some prefix plus order ID. You can hide it though.

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 kestas » Sat Mar 16, 2019 3:55 am

thekrotek wrote:
Fri Mar 15, 2019 7:09 pm
eighteenhk wrote:
Fri Mar 15, 2019 5:34 pm
How about the invoice number?
By default, invoice number is just some prefix plus order ID. You can hide it though.
It is not by default.
By default you generating invoice number. So, invoice number can be just sequentially generated + some prefix which you set on your shop settings. And invoice number can be different than order number.

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by kestas » Sat Mar 16, 2019 4:00 am

eighteenhk wrote:
Fri Mar 15, 2019 4:07 pm
Hello Everyone.

May I ask how to change the id? I already know I can add prefix, but I want the order id become either the date or random.
For example: Order time: 2019-03-15 16:05:23 Order ID: 2019031516052301 etc...
If this is impossible, can I make it randomly? I don't want the customer know how many orders of my store. Thanks!! :)
If you want to show for your customers some "high" order ID number you can edit the last your order in your phpMyadmin by changing order id to some "high" number. The next orders will show sequentially higher order number. Randomly order_id cannot be generated.

Edited. The better way... do not edit real order. For this you need to make "fake" order by yourself and edit order_id on this one in your phpMyadmin table "order". Before you edit it, you must make backup of your database in case if something goes wrong.
Last edited by kestas on Tue Mar 19, 2019 3:16 pm, edited 1 time in total.

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Active Member

Posts

Joined
Sat Apr 12, 2014 10:18 pm


Post by OSWorX » Mon Mar 18, 2019 8:18 pm

I am a bit surprised of some answers here!

Just to clarify: order_id is only the internally generated database table (entry) id.
Is sequential and cannot be changed.
Ot better it can be changed, but that makes no sense at all.

Why has this number be a int(eger)?
As said, is simply the internal id for the database.

Is this id further used?
Yes, at every call of the order (back- and frontend as well as in the order email).

What is the Invoice number?
A custom defined string (letters and numbers).
Can have a prefix (defined in the system settings) or can have some custom output (as done by some invoice extensions).
Some of these extensions (as mine also) allow you to define the output as you want (or need, e.g. in case you need a special number for your bookkeeping software).

Which all at least means, if you do not want to share your order_id, simply use something else.
Simply create an extension which hide all order_id(s) and replace them with your fantasy number/logic/whatelse.

But beware, the moment you want to allow your customers to have access to their order history (e.g. via customer account and/or order confirmation email), you will have troubles .. because no real order_id is used.

If you really want to go this way, you have to 'translate' internally also those fantasy numbers .. otherwise your shop is broken.

Decide however you want and simply create the working extension for it (or hire someone if you are not able to do so).

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by thekrotek » Mon Mar 18, 2019 8:52 pm

Short version: you don't change order ID.

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 OSWorX » Mon Mar 18, 2019 11:52 pm

thekrotek wrote:
Mon Mar 18, 2019 8:52 pm
Short version: you don't change order ID.
Shortest: maybe.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by Anonymous: » Wed Feb 17, 2021 6:31 am

Step - 1 : open file : admin\controller\sale\order.php line 227

A - find this line

Code: Select all

foreach ($results as $result) { 
after add following 3 lines code

Code: Select all

$order_no = str_replace("-","",$result['date_added']);
$order_no = str_replace(":","",$order_no);
$order_no = str_replace(" ","-",$order_no);
B - find this line

Code: Select all

'view'          => $this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $result['order_id'] . $url, true),
after or before add following code

Code: Select all

'order_no'      => $order_no."-".$result['order_id'],
Step - 2 : open file : admin\view\template\sale\order_list.twig line 227

find this line :

Code: Select all

<td class="text-right">{{ order.order_id }}</td>
replace

Code: Select all

<td class="text-right">{{ order.order_no }}</td>
Image

Newbie

Posts

Joined
Sat Sep 12, 2020 9:52 pm

Post by JimDrew » Fri Aug 06, 2021 3:57 am

The above is a good solution because it just replaces the displayed order_id with a new variable (order_no), which is generated from the date/time and order_id itself. However, this only works in the Admin side when showing orders - it does not change what is shown for the Order ID when doing the Print Shipping List or Print Invoice functions. Also, the customer still sees the original order ID when getting their email receipt and also when viewing the order history. It seems that since this uses the [date_added] field from the database that it would be simple enough to add similar code to various files to provide the same virtual order ID throughout the system (all while retaining the original order_id from the database). Anyone know what files are required to be changed for email receipt and account history?

New member

Posts

Joined
Wed Nov 21, 2018 1:08 am
Who is online

Users browsing this forum: Adminas99999, Semrush [Bot] and 130 guests