Welcome, Guest. Please login or register.
Login with username, password and session length


It's a release candidate! VirtueMart 2.0 RC - the next generation VirtueMart - is available! Read more....

  Advanced search

247038 Posts in 67506 Topics- by 258314 Members - Latest Member: aniketana
Pages: 1 [2] 3   Go Down
Print
Author Topic: how to - change order_id  (Read 34491 times)
mobik
Newbie
*
Posts: 1


« Reply #15 on: May 23, 2007, 09:01:59 AM »

Hi,
and what about to modify function get_order_id() to:

function get_order_id() {
   $datestring = date('ymd')."-".date('His');
   $randstring ="";
   rand();
      for($i=0;$i<4;$i++){
         $randstring.=rand(0,9);
      }     
return $datestring."-".$randstring;
}

Logged
Rico Suave
Full Member
***
Posts: 223


WWW
« Reply #16 on: May 25, 2007, 02:46:52 AM »

be my guest, try to figure out a way...
Logged

baburas
Newbie
*
Posts: 1


« Reply #17 on: June 02, 2007, 14:28:31 PM »

I wrote a small bash script which is executed once a day through a cron job.
The script changes the autoincrement value to a number containing the actual date.

cron job:
0  0  *  *  *   cron_daily_orderid.sh

cron_daily_orderid.sh:

#!/bin/bash
ORDERID=$(date +%y%m%d0001)
SQLCOMMAND="ALTER TABLE jos_vm_orders AUTO_INCREMENT=$ORDERID"
/usr/local/bin/mysql -u db_username --password=db_password -e "$SQLCOMMAND" db_name


order_id looks like: 706020001
Logged
Rico Suave
Full Member
***
Posts: 223


WWW
« Reply #18 on: June 03, 2007, 09:59:16 AM »

and that is working good?

no weird errors?
Logged

Rickie
Newbie
*
Posts: 5


« Reply #19 on: August 02, 2007, 03:05:55 AM »

Here's a PHP version that works fine for me. Date looks like "2007123001" (where 123 is the day of the year)

Code:
#!/usr/local/bin/php
<?php

$dbh
=mysql_connect ("localhost""..............""..............") or die (mysql_error());
mysql_select_db ("..............");

$new_orderid strftime("%Y%j001"time());

$qry 'ALTER TABLE jos_vm_orders AUTO_INCREMENT='.$new_orderid;
$res mysql_query($qry) or die (mysql_error());

mysql_close($dbh);

?>

Logged
Rico Suave
Full Member
***
Posts: 223


WWW
« Reply #20 on: August 02, 2007, 06:18:50 AM »

how does the final result look like (orderid) ? still incremental +1 ?
Logged

Rickie
Newbie
*
Posts: 5


« Reply #21 on: August 03, 2007, 01:54:25 AM »

OrderId looks like xxxxyyyzzz (2007123001)

xxxx= year (2007)
yyy= day of the year (maximum 365)
zzz= order number (is set to 001 each day = 999 orders a day possible)

Cheers
Logged
Rico Suave
Full Member
***
Posts: 223


WWW
« Reply #22 on: August 04, 2007, 12:45:29 PM »

so still incremental...its no good for me then (competitor use...)
Logged

zacwin
Newbie
*
Posts: 1


« Reply #23 on: September 25, 2007, 13:37:02 PM »

Here's a PHP version that works fine for me. Date looks like "2007123001" (where 123 is the day of the year)

Code:
#!/usr/local/bin/php
<?php

$dbh
=mysql_connect ("localhost""..............""..............") or die (mysql_error());
mysql_select_db ("..............");

$new_orderid strftime("%Y%j001"time());

$qry 'ALTER TABLE jos_vm_orders AUTO_INCREMENT='.$new_orderid;
$res mysql_query($qry) or die (mysql_error());

mysql_close($dbh);

?>


Where do I put this PHP code to produce the order id that you described?
Logged
Rico Suave
Full Member
***
Posts: 223


WWW
« Reply #24 on: September 26, 2007, 03:42:21 AM »

its a script...you need a cronjob to run it daily I think
Logged

happyshopper
Newbie
*
Posts: 8


« Reply #25 on: October 25, 2007, 15:10:15 PM »

after some time to find here any solution i wrote it self:

question:
----
how it is possible to change the given "order_id" (not "order_number" !!)
would nice to have a unique 10-bit number, a combine with random
generated bits and time-stamp

answer in 5 steps:
----
Step 1: you have to change your "xx_vm_orders" tab self by hand e.g. with phpmyadmin
- alter "order_id" -> autoincrement to "order_id" -> blank

Step 2: insert my script in "ps_checkout.php" on place your choice
          (..\administrator\components\com_virtuemart\classes)
Code:
/**************************************************************************
** name: get_order_id()
** created by: sten
** description:  Create an order id by using 5 random number
**               and the current unix timestamp.
** parameters:
** returns: unique order_id
***************************************************************************/
function get_order_id() {

/* Generated a unique order id */
$stri="";
srand();
  for($i=0;$i<5;$i++)
  {
    $stri.=rand(0,9);
  }
$order_id = $stri + (string)time();
return($order_id);
}
Step 3: insert followed script after "$order_number = $this->get_order_number();"
Code:
/* Set the order id */
$order_id = $this->get_order_id();
Step 4: search $q = "INSERT INTO #__{vm}_orders "; and alter this complete section in:
Code:
/* Insert the main order information */
$q = "INSERT INTO #__{vm}_orders ";
$q .= "(order_id, user_id, vendor_id, order_number, user_info_id, ";
$q .= "ship_method_id, order_total, order_subtotal, order_tax, order_shipping, ";
$q .= "order_shipping_tax,  order_discount, coupon_discount,order_currency, order_status, cdate, ";
$q .= "mdate,customer_note,ip_address) ";
$q .= "VALUES (";
$q .= "'" . $order_id . "', ";
$q .= "'" . $auth["user_id"] . "', ";
$q .= $ps_vendor_id . ", ";
$q .= "'" . $order_number . "', '";
$q .= $d["ship_to_info_id"] . "', '";
Thats all, finish
you will have a 10-bit order_id liike this: 1135854683
she will given unique



I see this was lasted edited by Soeren on Oct 10, 2007. Does that mean it has been updated and is working now?
Logged
Rico Suave
Full Member
***
Posts: 223


WWW
« Reply #26 on: October 28, 2007, 07:25:06 AM »

did your try it yet?
Logged

happyshopper
Newbie
*
Posts: 8


« Reply #27 on: October 28, 2007, 08:33:09 AM »

I tried it, but I get a blank screen when completing the order and it does not finish the order.
Logged
Rico Suave
Full Member
***
Posts: 223


WWW
« Reply #28 on: November 15, 2007, 10:56:22 AM »

hmmm I wont use this then Sad
Logged

davee
Newbie
*
Posts: 1


« Reply #29 on: November 18, 2007, 07:46:10 AM »

Hi!

Any new solution for the random order id?

thanks.
Logged
Pages: 1 [2] 3   Go Up
Print
Jump to: