X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Order ID Random Incrementation... (https://forum.x-cart.com/showthread.php?t=25789)

mffowler 11-17-2007 05:17 PM

Re: Order ID Random Incrementation...
 
Quote:

Originally Posted by carpeperdiem
But what will make it a unique number?

Actually, computers can't generate a true random number as any deterministic method would necessitate that it is not 'random' by definition. But for most intensive purposes, you can create a 'psuedo random' number.

Someone mentioned Amazon order numbers and I thought I would have a go at recreating their randomness and pattern of 3-7-7 digits.
Code:

<?php

// Range of numbers

// Minimum number
$min = "1000000";

// Maximum number
$max = "9999999";

echo "105-".
mt_rand($min, $max);
echo "-".
mt_rand($min, $max);
?>

That will spit out an Amazon-esque Order ID. Note, I said 'Order ID' which is what Amazon refers to an order as. Most certainly they would have a unique internal ordering system.

As for testing a used number, well this code snippet uses 14 unique numbers. The possibility for creating a duplicate number with this spread is like 22,876,792,454,961:1 and I don't think it would warrant any test to see if the number was previously generated. You have better odds winning multiple powerball lottos...

- Mike

stevep 10-10-2008 10:08 AM

Re: Order ID Random Incrementation...
 
works fine for me.

nice on many thanks.

seaCOAST 02-02-2009 12:31 PM

Re: Order ID Random Incrementation...
 
Does anyone know if this works in v4.2.0?

I'm trying it, but it's not working for me.

seaCOAST 02-05-2009 02:15 AM

Re: Order ID Random Incrementation...
 
If anyone is still interested in this thread...

This mod does work on v4.2.0

For some reason, it took a few orders for it to start working. I'm not sure why. Perhaps a cache thing.

JRC 04-21-2009 08:38 AM

Re: Order ID Random Incrementation...
 
Quote:

Originally Posted by seaCOAST
If anyone is still interested in this thread...

This mod does work on v4.2.0

For some reason, it took a few orders for it to start working. I'm not sure why. Perhaps a cache thing.



FYI: I noted the same issue when I recently upgrade to v4.1.12 (the first 5 or so orders incremented by exacly 1, then it started working). Seems like a caching issue could make testing a little frustrating at first.

steve.thompson 05-21-2009 02:42 PM

Re: Order ID Random Incrementation...
 
I've just installed this mod in 4.2.1 and it started working on the next order.

Steve.

alphastara 05-26-2009 02:30 AM

Re: Order ID Random Incrementation...
 
Good to see my mod is still going strong in 4.2 :)

srise 12-22-2009 02:40 PM

Re: Order ID Random Incrementation...
 
I just wanted to report that this mod works in 4.3.0 too.

cart.php is a bit different, but the line of code that needs to be added can be inserted at line 950.

MBA 03-24-2010 09:33 AM

Re: Order ID Random Incrementation... 4.3.1
 
In 4.3.1 it seems to be the same as the instructions for 4.1.x:

Find:

$smarty->assign("orderids", $orderids); $smarty->assign("main","order_message"); $location[] = array(func_get_langvar_by_name("lbl_order_processe d"), "");

Replace with:

$smarty->assign("orderids", $orderids); $smarty->assign("main","order_message"); include $xcart_dir."/include/increment.php"; $location[] = array(func_get_langvar_by_name("lbl_order_processe d"), "");

That is working for us.

seaCOAST 12-18-2010 10:22 AM

Re: Order ID Random Incrementation...
 
Any chance this could be upgraded for v4.4.1?

I had trouble finding the code.

Thanks.


All times are GMT -8. The time now is 11:58 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.