Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Order ID Random Incrementation...

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 10-13-2006, 10:02 PM
 
alphastara alphastara is offline
 

Advanced Member
  
Join Date: Jul 2005
Posts: 39
 

Default Order ID Random Incrementation...

Here's a good solution which a few people may be interested in. If you don't like the way X-Cart increments your order ID's by 1, eg. If you want customers to think your shop is processing more orders than just a couple since their last order...Here is a solution I threw together just now...it increments the next order ID to be randomly between 8 and 30 orders higher than current order ID, simply change the '8' and the '30' to change the random range in increment.php...:

Create a new file called 'increment.php' in /yourxcartdirhere/include/ containing:
Code:
<?php # # This randomly increments the orderid each time an order is made... # Simply call it once an order has been made; include $xcart_dir."/include/increment.php"; # Uses this idea - db_query("ALTER TABLE xcart_orders AUTO_INCREMENT = xxxxxx"); # $advanceBy = rand(8, 30); $NewNumber = $orderids + $advanceBy; $FD_InsertQuery = "ALTER TABLE xcart_orders AUTO_INCREMENT = $NewNumber"; db_query($FD_InsertQuery); ?>

In /yourxcartdirhere/cart.php at line 803 find this:
Code:
elseif ($mode=="order_message") { $smarty->assign("main","order_message"); $location[] = array(func_get_langvar_by_name("lbl_order_processed"), "");

replace it with this:
Code:
elseif ($mode=="order_message") { $smarty->assign("main","order_message"); include $xcart_dir."/include/increment.php"; $location[] = array(func_get_langvar_by_name("lbl_order_processed"), "");

NOTE: This has been tested on 4.0.19 ONLY, not sure if it's the same for other versions, can't see why not.
__________________
Alphastara | New Age Products
www.alphastara.com.au
V: 4.1.6 + AOM
Reply With Quote

The following user thanks alphastara for this useful post:
Phoenix Tech (07-17-2011)
  #2  
Old 10-14-2006, 02:39 AM
 
Jerrad Jerrad is offline
 

X-Adept
  
Join Date: Nov 2004
Location: The Netherlands
Posts: 484
 

Default Re: Order ID Random Incrementation...

Thanks for this nice mod, which also works great in version 4.0.12 !
In my cart.php I found the code that must be replaced at line 709 and it had one extra line, which I didn't replace with the new code.

Code:
elseif ($mode=="order_message") { $smarty->assign("main","order_message"); $smarty->assign("mode","order_message"); include $xcart_dir."/include/increment.php"; $location[] = array(func_get_langvar_by_name("lbl_order_processed"), "");

Thanks again!
__________________
X-Cart 4.0.12
Heavy modified with paid, free and forum mods.
PHP 5.2.5 | MYSQL 5.0.51a
Reply With Quote
  #3  
Old 10-14-2006, 10:00 AM
 
mffowler mffowler is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Melbourne, Australia
Posts: 811
 

Default Re: Order ID Random Incrementation...

In 4.1.x, you need to change:

Code:
$smarty->assign("orderids", $orderids); $smarty->assign("main","order_message"); $location[] = array(func_get_langvar_by_name("lbl_order_processed"), "");

To:

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

Just tested and works like a charm! Many large scale sellers (like Amazon) have completely random order numbers. A lot of backend order management apps. collect web order #'s and also have order id's. Thus, random customer side order numbers don't really affect any legal or business issue. It does certainly make it easier that the orders are at least greater in number though... in XC's backend.

- Mike
__________________
4.1.9
Reply With Quote
  #4  
Old 10-19-2006, 09:34 AM
  jasonroy's Avatar 
jasonroy jasonroy is offline
 

Senior Member
  
Join Date: Sep 2006
Location: Tualatin, Oregon
Posts: 147
 

Default Re: Order ID Random Incrementation...

works awesome in 4.1.x

just what I was looking for
__________________
rjroffroad.com
x-cart 4.1.3
+ez checkout
+remember anonymous carts
Reply With Quote
  #5  
Old 10-23-2006, 08:01 PM
 
alphastara alphastara is offline
 

Advanced Member
  
Join Date: Jul 2005
Posts: 39
 

Default Re: Order ID Random Incrementation...

I've had my mod return two orders in 1 number increments (eg. 272, 273), not sure what could have caused it to not perform its operation correctly? It has worked normally since, just thought i would mention it, just one of those things i guess.
__________________
Alphastara | New Age Products
www.alphastara.com.au
V: 4.1.6 + AOM
Reply With Quote
  #6  
Old 10-24-2006, 06:08 AM
 
mffowler mffowler is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Melbourne, Australia
Posts: 811
 

Default Re: Order ID Random Incrementation...

I noticed that in situations where the payment was pending or failed. The fixed order uses a subsequent number. But, in unique orders the numbers grow as you set them.

- Mike
__________________
4.1.9
Reply With Quote
  #7  
Old 11-24-2006, 02:51 PM
 
ryan c. ryan c. is offline
 

Advanced Member
  
Join Date: Sep 2002
Posts: 58
 

Default Re: Order ID Random Incrementation...

works great thanks!
__________________
Version 4.1.8
Reply With Quote
  #8  
Old 11-24-2006, 04:54 PM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Order ID Random Incrementation...

This mod works great for me in 4.1.3

I had to do a test order to move the counter up one increment, then it started the randomizing on subsequent orders (I guess it had to teach the database where it was...)

Very useful mod.
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #9  
Old 12-13-2006, 09:51 PM
 
EXRN EXRN is offline
 

Newbie
  
Join Date: Aug 2006
Posts: 8
 

Default Re: Order ID Random Incrementation...

Just what I was looking for! It works great!

Thanks,
David
__________________
EXRN, Inc
xcart v4.1 [Linux]
Reply With Quote
  #10  
Old 02-10-2007, 04:57 AM
  wank3r's Avatar 
wank3r wank3r is offline
 

eXpert
  
Join Date: Aug 2006
Posts: 291
 

Default Re: Order ID Random Incrementation...

I read every post in this thread and was wondering how and where to just increase the order ID from my currently xx to xxxx ?

I really don't have the need for autoincrementing between orders, just a simple way of increasing my current number to something higher.

The reason for this is that I need a seperate range of order ID's as I'm currently sharing a payment gateway and we need to split our orders into seperate ranges to be able to differentiate between our shops

Also I've just tested the script above and I have used the variables 8000 and 8010 but for some reason the change didn't show up on the next order but the second. The second order was incrementet to 8027 ???

Thanks in advance!
__________________
Powered by X-Cart Gold: 4.4.4/4.4.5
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:09 PM.

   

 
X-Cart forums © 2001-2020