Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2008
    Posts
    23
    Plugin Contributions
    0

    Default 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)

    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

  2. #2
    Join Date
    Apr 2008
    Posts
    23
    Plugin Contributions
    0

    Default Re: Order number ID set as UUID

    Could you at least tell me what php page(s) send(s) orders data into table_orders ?

  3. #3
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default 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
    Zen-Venom Get Bitten

  4. #4
    Join Date
    Apr 2008
    Posts
    23
    Plugin Contributions
    0

    Default 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.

  5. #5
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default 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.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Apr 2008
    Posts
    23
    Plugin Contributions
    0

    Default Re: Order number ID set as UUID

    Is it your way to cheer me up DrByte ?

  7. #7
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Order number ID set as UUID

    Quote Originally Posted by Xam View Post
    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
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Apr 2008
    Posts
    23
    Plugin Contributions
    0

    Default 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)

 

 

Similar Threads

  1. v154 Set next order number
    By adb34 in forum General Questions
    Replies: 5
    Last Post: 27 Jul 2015, 11:22 AM
  2. v151 'Set next order number' - is this stored anywhere?
    By simon1066 in forum Customization from the Admin
    Replies: 6
    Last Post: 30 Oct 2014, 07:05 PM
  3. start from say order number #1215 rather than order number 1
    By vandiermen in forum Managing Customers and Orders
    Replies: 4
    Last Post: 18 Mar 2009, 02:07 PM
  4. Set Default Order Number Above 1?
    By Rydel in forum Customization from the Admin
    Replies: 2
    Last Post: 15 Mar 2007, 08:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg