Order Number

  • Posts: 48
  • Thank you received: 3
3 months 1 week ago #362619

-- url of the page with the problem -- : demoisellegol.fr
-- HikaShop version -- : 5.1.0
-- Joomla version -- : 5.1.2
-- PHP version -- : 8.1

Hi
how can set my order numbers to a random 8 digit number ?

thanks

Please Log in or Create an account to join the conversation.

  • Posts: 4747
  • Thank you received: 644
  • MODERATOR
3 months 1 week ago #362625

Hello,

In Component => HikaShop => Configuration, then Main tab, and finally Order part, you will find an input to define your order number, learn more in our documentation .

Regards

Last edit: 3 months 1 week ago by Philip.

Please Log in or Create an account to join the conversation.

  • Posts: 48
  • Thank you received: 3
3 months 1 week ago #362629

I know where to change the code
I dont know the code

can you tell me what should i exactly put in that field for desired order number ?

Please Log in or Create an account to join the conversation.

  • Posts: 48
  • Thank you received: 3
3 months 1 week ago #362630

I managed to do what i want by reading the documentation

my problem is i want the orders IDs be a 5 digit RANDOM number not sequential

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 months 1 week ago #362634

Hi,

In that case, you need to develop a joomla plugin of the group "hikashop" and implement in it the event onBeforeOrderNumberGenerate(&$order, &$order_number)

It's quite simple with PHP's rand function ( www.php.net/manual/en/function.rand.php ):

function onBeforeOrderNumberGenerate(&$order, &$order_number){
 $order_number = rand(10000, 99999);
}
Note that this code doesn't check if an order already exists with the randomly selected number. If you want to add that check, it's possible. You'll need to run a MySQL query on the hikashop_order table.

Please Log in or Create an account to join the conversation.

Time to create page: 0.062 seconds
Powered by Kunena Forum