Forums / Managing Customers and Orders / Order number ID set as UUID

Order number ID set as UUID

Locked
Results 1 to 8 of 8
This thread is locked. New replies are disabled.
17 Aug 2008, 15:32
#1
xam avatar

xam

New Zenner

Join Date:
Apr 2008
Posts:
23
Plugin Contributions:
0

Order number ID set as UUID

Hi

I need help to set the order ID as an UUID ... of course I understand the Order ID is set as auto-increment and I shouldn't try to mess with it.

What I want is to insert an autogenerated UUID into the zencart_orders table

I have inserted an orders_uuid row into my DB

I have a code to generate an UUID (this is not my code)

<?php

$u=uuid();   // 0001-7f000001-478c8000-4801-47242987
echo $u;
echo "<br>";

function uuid($serverID=1)
{
    $t=explode(" ",microtime());
    return sprintf( '%04x-%08s-%08s-%04s-%04x%04x',
        $serverID,
        clientIPToHex(),
        substr("00000000".dechex($t[1]),-8),   // get 8HEX of unixtime
        substr("0000".dechex(round($t[0]*65536)),-4), // get 4HEX of microtime
        mt_rand(0,0xffff), mt_rand(0,0xffff));
}

function uuidDecode($uuid) {
    $rez=Array();
    $u=explode("-",$uuid);
    if(is_array($u)&&count($u)==5) {
        $rez=Array(
            'serverID'=>$u[0],
            'ip'=>clientIPFromHex($u[1]),
            'unixtime'=>hexdec($u[2]),
            'micro'=>(hexdec($u[3])/65536)
        );
    }
    return $rez;
}

function clientIPToHex($ip="") {
    $hex="";
    if($ip=="") $ip=getEnv("REMOTE_ADDR");
    $part=explode('.', $ip);
    for ($i=0; $i<=count($part)-1; $i++) {
        $hex.=substr("0".dechex($part[$i]),-2);
    }
    return $hex;
}

function clientIPFromHex($hex) {
    $ip="";
    if(strlen($hex)==8) {
        $ip.=hexdec(substr($hex,0,2)).".";
        $ip.=hexdec(substr($hex,2,2)).".";
        $ip.=hexdec(substr($hex,4,2)).".";
        $ip.=hexdec(substr($hex,6,2));
    }
    return $ip;
}

?>


I need to know what changes I need to do to checkout_process.php to insert the generated UUID into my DB

Then my customers will have a nice Order ID ...
and noone will be able to know how much I sell.

Thanx
18 Aug 2008, 09:47
#2
xam avatar

xam

New Zenner

Join Date:
Apr 2008
Posts:
23
Plugin Contributions:
0

Re: Order number ID set as UUID

Could you at least tell me what php page(s) send(s) orders data into table_orders ?
19 Aug 2008, 18:46
#3
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Posts:
31,500
Plugin Contributions:
4

Re: Order number ID set as UUID

Then my customers will have a nice Order ID ...
and no one will be able to know how much I sell.

If this is the only intended purpose

Look at setting the default order ID in admin > tools > store manager >Reset Current Order ID > read the instructions and you can set to most any value you want
20 Aug 2008, 02:43
#4
xam avatar

xam

New Zenner

Join Date:
Apr 2008
Posts:
23
Plugin Contributions:
0

Re: Order number ID set as UUID

I know that ... but then you still have an orderID based on the number of orders. What I want is an orderID based on time.

With a UUID you get an orderID looking like that :

5008bffd-48ab8422-a8e3-52e56706
5008bffd-48ab8438-b2f3-de805f05
5008bffd-48ab8450-88bd-1de10656

and you don't ever have to go reset your orderID.
20 Aug 2008, 04:43
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Order number ID set as UUID

You can alter the /includes/classes/order.php class to display a different order number to your customers.

Just remember that by doing that you will have broken all links to the order in the My Account area, the confirmation emails, all your admin order handling and order invoice printing, and lots more.

To make the change consistent throughout every aspect of your site is a complex custom programming task. Nevertheless, it can be done, with the right programming skill and lotsa time on your hands.
20 Aug 2008, 05:39
#6
xam avatar

xam

New Zenner

Join Date:
Apr 2008
Posts:
23
Plugin Contributions:
0

Re: Order number ID set as UUID

Is it your way to cheer me up DrByte ?
20 Aug 2008, 05:57
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Order number ID set as UUID

Xam:

Is it your way to cheer me up DrByte ?


lol ... just making sure you understand the impact and significance of what you're asking for :blush:
20 Aug 2008, 09:46
#8
xam avatar

xam

New Zenner

Join Date:
Apr 2008
Posts:
23
Plugin Contributions:
0

Re: Order number ID set as UUID

would it be easier to modify the order number in #checkoutsuccessordernumber and everywhere else it may appear ?

- first, to show it as a Hex number
- second, to add some other data to that number (Hex timestamp from date_purchased in table_orders + Hex of customer IP address)