X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (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!

carpeperdiem 02-10-2007 05:43 AM

Re: Order ID Random Incrementation...
 
Quote:

Originally Posted by wank3r
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 ?

You should bookmark THIS THREAD - titled, "A List of things asked a million times..."

It is the very first thread in the FAQ forum.

Johny1 03-07-2007 03:16 AM

Re: Order ID Random Incrementation...
 
Works great!!! Thanks

MMANOR 03-14-2007 09:02 AM

Re: Order ID Random Incrementation...
 
Good Afternoon Everyone,

I was going through this thread and this is exactly something I would like to do as well. But instead of advancing the order number by a set value, I was hoping to have the system create a random number between 1000000 and 9999999. So I was thinking of something like this

mt_srand ((double)microtime() * 1000000);
$reference_number = "1";
$reference_number .= mt_rand (1000000,9999999);

Would this work with X-cart? I am trying to figure out, based on all of the topic replies where I should fit this in.

Please help. Thank you.

carpeperdiem 03-14-2007 09:08 AM

Re: Order ID Random Incrementation...
 
But what will make it a unique number? This will require the database to know the numbers already used, then a call to the db to see if it's avail, then a write to the db to log a used number. Can you do this? I don't know how. But it's a good idea if it can be easily done.

Reed 03-14-2007 04:37 PM

Re: Order ID Random Incrementation...
 
Works in 4.1.5 after changing the code that mffowler refered to! Excellent quick mod that should be used by all stores. Thanks!

qinwubi 07-09-2007 08:49 AM

Re: Order ID Random Incrementation...
 
works like a charm, thanks!

SystemSkins 11-17-2007 05:21 AM

Re: Order ID Random Incrementation...
 
Why would someone want a mod like this? Just to appear to the customer that you are doing high volume? Do you feel this would be benificial if your customers thought you did more volume than you really did? Do you think you would loose repeat business just because your web order number is low? I mean everyone has to start somewhere right?

From a quickbooks standpoint does x-cart download into your quickbooks in a sequential number by "1" with this mod or with your "random gaped number"? Without getting involved or knowing alot about this mod, I can just hear my accountant now, "Wheres the missing numbers?" This wouldn't raise a red flag for audits?

drudden 11-17-2007 07:32 AM

Re: Order ID Random Incrementation...
 
Customers want to do business with a reputable company. If they appear to be the only person buying from you, they may start wondering why they are your only customer. You can't assume a customer will be understanding and give you the benefit of the doubt just because you are a new business starting up.

In addition, with sequential order numbers your competitor can easily find out how much volume you are doing if they wanted to.

You may want to use the random mod during the startup of your store. After you get a steady inflow of sales, you can change it back. Your accountant should understand as long as you can account for everything.

SystemSkins 11-17-2007 07:44 AM

Re: Order ID Random Incrementation...
 
Quote:

Originally Posted by drudden
In addition, with sequential order numbers your competitor can easily find out how much volume you are doing if they wanted to.


LOL that is exactly what I did. I figured out that my competitor does on average 280 orders per day based on "secret shopping" from them in 2 week increments over a 2 month period. Now that I seen this thread I have my doubts that their volume is that much. However it actually could be according to thier "About our company" stating the size of their facility and equipment that they have.


Is there a way to see what your actual order number would be had you not of used the random order number?

If I launch my site using the random number generator and after 6 months I have an order number of 1283. Is there a way to see that that is actually order number 398?

I'm more than likely going to install this mod before launch.

carpeperdiem 11-17-2007 02:21 PM

Re: Order ID Random Incrementation...
 
Amazon.com uses random order IDs.

The order # for the cart doesn't have to be anything more than a reference number. Your accounting software software can (should?) be sequential, but it really doesn't matter, if you can generate a report...

You can set the randomizer to small numbers or large numbers... doesn't really matter, if the purpose is simply "reference numbers" -- but check with your state or country trade office if you want to be certain. In the US, sequential reference numbers for orders is not law. It may be law in some countries.

mffowler 11-17-2007 05:17 PM

Re: Order ID Random Incrementation...
 
Quote:

Originally Posted by carpeperdiem
But what will make it a unique number?

Actually, computers can't generate a true random number as any deterministic method would necessitate that it is not 'random' by definition. But for most intensive purposes, you can create a 'psuedo random' number.

Someone mentioned Amazon order numbers and I thought I would have a go at recreating their randomness and pattern of 3-7-7 digits.
Code:

<?php

// Range of numbers

// Minimum number
$min = "1000000";

// Maximum number
$max = "9999999";

echo "105-".
mt_rand($min, $max);
echo "-".
mt_rand($min, $max);
?>

That will spit out an Amazon-esque Order ID. Note, I said 'Order ID' which is what Amazon refers to an order as. Most certainly they would have a unique internal ordering system.

As for testing a used number, well this code snippet uses 14 unique numbers. The possibility for creating a duplicate number with this spread is like 22,876,792,454,961:1 and I don't think it would warrant any test to see if the number was previously generated. You have better odds winning multiple powerball lottos...

- Mike

stevep 10-10-2008 10:08 AM

Re: Order ID Random Incrementation...
 
works fine for me.

nice on many thanks.

seaCOAST 02-02-2009 12:31 PM

Re: Order ID Random Incrementation...
 
Does anyone know if this works in v4.2.0?

I'm trying it, but it's not working for me.

seaCOAST 02-05-2009 02:15 AM

Re: Order ID Random Incrementation...
 
If anyone is still interested in this thread...

This mod does work on v4.2.0

For some reason, it took a few orders for it to start working. I'm not sure why. Perhaps a cache thing.

JRC 04-21-2009 08:38 AM

Re: Order ID Random Incrementation...
 
Quote:

Originally Posted by seaCOAST
If anyone is still interested in this thread...

This mod does work on v4.2.0

For some reason, it took a few orders for it to start working. I'm not sure why. Perhaps a cache thing.



FYI: I noted the same issue when I recently upgrade to v4.1.12 (the first 5 or so orders incremented by exacly 1, then it started working). Seems like a caching issue could make testing a little frustrating at first.

steve.thompson 05-21-2009 02:42 PM

Re: Order ID Random Incrementation...
 
I've just installed this mod in 4.2.1 and it started working on the next order.

Steve.

alphastara 05-26-2009 02:30 AM

Re: Order ID Random Incrementation...
 
Good to see my mod is still going strong in 4.2 :)

srise 12-22-2009 02:40 PM

Re: Order ID Random Incrementation...
 
I just wanted to report that this mod works in 4.3.0 too.

cart.php is a bit different, but the line of code that needs to be added can be inserted at line 950.

MBA 03-24-2010 09:33 AM

Re: Order ID Random Incrementation... 4.3.1
 
In 4.3.1 it seems to be the same as the instructions for 4.1.x:

Find:

$smarty->assign("orderids", $orderids); $smarty->assign("main","order_message"); $location[] = array(func_get_langvar_by_name("lbl_order_processe d"), "");

Replace with:

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

That is working for us.

seaCOAST 12-18-2010 10:22 AM

Re: Order ID Random Incrementation...
 
Any chance this could be upgraded for v4.4.1?

I had trouble finding the code.

Thanks.

JDAM1 02-15-2011 10:36 AM

Re: Order ID Random Incrementation...
 
SeaCoast, I had a problem as well looking for the code in cart.php. I ended up following post #11 from carpeperdiem. It may not jump in increments, but you can at least start with a 3, 4 or 5 digit order number.

Sylvain 05-18-2011 08:42 PM

Re: Order ID Random Incrementation...
 
I would love to have something that work for 4.4.3

Sylvain 05-18-2011 09:01 PM

Re: Order ID Random Incrementation...
 
I got to work with 4.4.3 In 4.4.x the code that handles the "order_message" mode processing is located in the "<xcart_dir>/include/checkout_init.php".

On line 511 change:
$location[] = array(func_get_langvar_by_name('lbl_order_processe d'), '');

for:

include $xcart_dir."/include/increment.php";
$location[] = array(func_get_langvar_by_name("lbl_order_processe d"), '');

And Create a new file called 'increment.php' in /yourxcartdirhere/include/ containing:

<?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); ?>

neaisha 07-11-2011 12:58 PM

Re: Order ID Random Incrementation...
 
Quote:

Originally Posted by Sylvain
I got to work with 4.4.3 In 4.4.x the code that handles the "order_message" mode processing is located in the "<xcart_dir>/include/checkout_init.php".

On line 511 change:
$location[] = array(func_get_langvar_by_name('lbl_order_processe d'), '');

for:

include $xcart_dir."/include/increment.php";
$location[] = array(func_get_langvar_by_name("lbl_order_processe d"), '');




$location[] = include $xcart_dir . '/include/increment.php';
array(func_get_langvar_by_name('lbl_order_processe d'), '');

^works instead of...

include $xcart_dir."/include/increment.php";
$location[] = array(func_get_langvar_by_name("lbl_order_processe d"), '');

steakbbq 11-27-2012 06:04 PM

Re: Order ID Random Incrementation...
 
Anyone know if this works in 4.5?

Thanks

carpeperdiem 01-03-2013 08:17 AM

Re: Order ID Random Incrementation...
 
Quote:

Originally Posted by steakbbq
Anyone know if this works in 4.5?

Thanks


Works perfectly in 4.5.4 as contributed by neaisha in post #34

PHP Code:

$location[] = include $xcart_dir '/include/increment.php';
array(
func_get_langvar_by_name('lbl_order_processed'), ''); 


seaCOAST 05-12-2013 06:36 PM

Re: Order ID Random Incrementation...
 
Tried this in v4.5.5 and it's not working. No errors, but it's still not working. I cleared the cache and tried 6 test orders. No change. :(

seaCOAST 05-15-2013 06:46 AM

Re: Order ID Random Incrementation...
 
If anyone is interested...

The above code DOES work! Apparently, I needed to complete an order for it to start taking effect.

Just thought I'd give an update. ;)

acidon 08-29-2013 08:34 AM

Re: Order ID Random Incrementation...
 
I am trying to implement this in 4.6.0.

I noticed there are 2 instances of:

Code:

$location[] = array(func_get_langvar_by_name('lbl_order_processed'), '');

in checkout_init.php, second appears to refer to "invoice page (order confirmation page) for amazon order details widget"... should I change it too?

acidon 11-27-2016 02:01 PM

Re: Order ID Random Incrementation...
 
Works in 4.7.6 :-)


All times are GMT -8. The time now is 06:55 AM.

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