cancel
Showing results for 
Search instead for 
Did you mean: 

How to make the order number with Prefix?

SOLVED

How to make the order number with Prefix?

Hi, I am KD I am a new magento developer. 

 

I just want to seek help about the requirements I need to do for a services e-commerce website.

I appreciate your help in advance.

 

1. How can I  make the order number from the default sequence to this sequence with Prefix? (Ex. ESO-50100)

2. How can I make the invoice number from the default sequence to this sequence with Prefix? (Ex.ESI-10100)

 

And for the last please see the photos on what I need to achieve on the admin customer page. Customer Admin ID.jpg

 

 

Thank you for your help ing advance,

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to make the order number with Prefix?

@kd_bansil

 

Go to your database from phpmyadmin,

Here _1 is used for store id after tablename.

 

Default Frontend store id is 1. if you have multi store then you have to set query for each store with table name like sequence_order_2 upto sequence_order_.*

 

Enter below query for table sequence_order_1 is used for default store. If you have multiple store you have to set tablename as per store id in below query.

 

This is only used for order placed from frontend.

 

sequence_order_1 is used for order id management in magento 2.

ALTER TABLE sequence_order_1 AUTO_INCREMENT=155555551;

 

Next order id is start from 155555551.

 

Below Query is defined for INVOICE, if you want to change invoice id

ALTER TABLE sequence_invoice_1 AUTO_INCREMENT=155555551;

 

For Shipment ALTER TABLE sequence_shipment_1 AUTO_INCREMENT=155555551;

 

To chnange prefix do changes in sale_sequence_profile

 

For more info please follow below link:

https://bsscommerce.com/blog/complete-tutorial-guide-change-order-number-magento-2/

Manish Mittal
https://www.manishmittal.com/

View solution in original post

4 REPLIES 4

Re: How to make the order number with Prefix?

@kd_bansil

 

Go to your database from phpmyadmin,

Here _1 is used for store id after tablename.

 

Default Frontend store id is 1. if you have multi store then you have to set query for each store with table name like sequence_order_2 upto sequence_order_.*

 

Enter below query for table sequence_order_1 is used for default store. If you have multiple store you have to set tablename as per store id in below query.

 

This is only used for order placed from frontend.

 

sequence_order_1 is used for order id management in magento 2.

ALTER TABLE sequence_order_1 AUTO_INCREMENT=155555551;

 

Next order id is start from 155555551.

 

Below Query is defined for INVOICE, if you want to change invoice id

ALTER TABLE sequence_invoice_1 AUTO_INCREMENT=155555551;

 

For Shipment ALTER TABLE sequence_shipment_1 AUTO_INCREMENT=155555551;

 

To chnange prefix do changes in sale_sequence_profile

 

For more info please follow below link:

https://bsscommerce.com/blog/complete-tutorial-guide-change-order-number-magento-2/

Manish Mittal
https://www.manishmittal.com/

Re: How to make the order number with Prefix?

Hello @kd_bansil,

 

You can customize it. In this article, we’ll provide you with some tips to change the default Magento 2 order number in the correct way, they are:

  • Manually make changes directly in database: use code and commands to edit order increment ID, order number starts and prefix
  • Install an extension

Tip 1: Make Changes to Order Number Directly in Database Magento 2

First of all, you need to open your PHP Admin database. Then find and open the table “sale_sequence_profile.”

This is the structure of table “sale_sequence_profile”: https://www.screencast.com/t/aPKgbO1zk1Lv

 Screenshot_5.png

After that, you can make changes to default order number on your Magento 2 website:

 

a. Change Order Increment ID
This is the guide to help you change the step between 2 continuous order numbers.

  • Step 1: Open Database and add the following SQL commands:
    UPDATE ‘sales_sequence_profile’ SET ‘step’ = X WHERE ‘meta_id’ = 5;
    Note: “meta_id” is gotten from table “sales_sequence_meta” 
    https://www.screencast.com/t/axV4TIMp
    sales_sequence_meta.png
  • Step 2: Replace ‘X’ by the order you wish to make
  • Step 3: Run the query

b. Change Order Number Prefix
Following this structure to add the prefix to the order number:

  • Step 1: Go to Database and add the following SQL commands:
    UPDATE ‘sales_sequence_profile’ SET ‘prefix’ = ‘X’ WHERE ‘meta_id’ = 5;
  • Step 2: replace “X” with the order prefix you want.
    Note: If you wish to disable prefix, remove the quotes and set x=NULL
  • Step 3: Run the query

c. Change Order Number Suffix

  • Step 1: Go to Database and add the following SQL commands:
    UPDATE ‘sales_sequence_profile’ SET ‘suffix’= ‘X’ WHERE ‘meta_id’ = 5;
  • Step 2: replace “X” with the order prefix you want.
    Note: If you wish to disable suffix, remove the quotes and set X=NULL
  • Step 3: Run the query

d. Change Order Number Start-value

  • Step 1: Go to Database and add the following SQL commands:
    UPDATE ‘sales_sequence_profile’ SET ‘start_value’= X WHERE ‘meta_id’ = 5;
  • Step 2: replace “X” with the number you wish to make.
  • Step 3: Run the query

e. Change Pad-length
The constant DEFAULT_PATTERN is set in: /vendor/magento/module-sales-sequence/Model/Sequence.php, line 22. 
https://www.screencast.com/t/wyYZUnYK

defaut-path-length.png
To avoid editing module core, you can change this in a custom module by creating etc/di.xml with the following contents:
https://www.screencast.com/t/CTWyM75tG3j

Screenshot_4.png
After setting, you will get a new custom order number like this:

order_number = prefix + ((sequence_value – start_value) * step + start_value) {padded to X digits} + suffix

For example, you set: – step = ‘10’’ – prefix = ‘Bss-’ – suffix = ‘-M2’ – start_value = ‘1’ – DEFAULT_PATTERN = “%s%’.03d%s”

And last sequence_value = 2 => next sequence_value = 3

Then next order number is Bss-021-M2

Note: sequence_value is gotten from table “sequence_order_1”

 

Tip 2: Use Magento 2 Custom Order Number extension
The damage of using code is that it directly intervenes in the database, which may cause harm to your website especially for those who do not get familiar with it. Hence, another tip to change order number simply safely is to use the support of a convenient extension. You can refer Magento 2 Custom Order Number extension. The extension is very user-friendly so admins can make changes to order number at ease. This module not only allows you to make a change to order number but also shipment, credit memo, and invoice number. One plus point is that you can edit the sale numberings individually for each store view.
https://www.screencast.com/t/J3BgwGFH

1.-Custom-order-number-config.png

 

--
If my answer is useful, please Accept as Solution & give Kudos

Re: How to make the order number with Prefix?

Hi @kd_bansil

 

To change the order sequence from default to the customized - you need to installed and configured the extension or you will required to do customization - as by default there is no functionality available

 

So here i am suggesting one extension , which helps you to change the invoice/order/shipping all kind of sequence : https://amasty.com/custom-order-number-for-magento-2.html

 

Hope it  helps !

if issue solved,Click Kudos & Accept as Solution

Re: How to make the order number with Prefix?

Thank you it helps a lot.