X-Cart: shopping cart software

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

alphastara 10-13-2006 10:02 PM

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.

Jerrad 10-14-2006 02:39 AM

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!

mffowler 10-14-2006 10:00 AM

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

jasonroy 10-19-2006 09:34 AM

Re: Order ID Random Incrementation...
 
works awesome in 4.1.x

just what I was looking for

alphastara 10-23-2006 08:01 PM

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.

mffowler 10-24-2006 06:08 AM

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

ryan c. 11-24-2006 02:51 PM

Re: Order ID Random Incrementation...
 
works great thanks!

carpeperdiem 11-24-2006 04:54 PM

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.

EXRN 12-13-2006 09:51 PM

Re: Order ID Random Incrementation...
 
Just what I was looking for! It works great!

Thanks,
David

wank3r 02-10-2007 04:57 AM

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!


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

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