Unique Order/Invoice Number Mod

Completed modifications to the NOP Shopping Cart. Additions, modifications, and more.

Moderators: Koibito, Stefko, Randy, Rosey

How about PHP ?

Postby CBS » Thu Nov 20, 2003 9:21 pm

What would the PHP mod be?
Any Ideas?
Always bear in mind that your own resolution
to success is more important than any one thing
CBS
 
Posts: 7
Joined: Thu Nov 20, 2003 8:33 pm
Location: Tampa Florida USA

Postby tydye » Tue Dec 16, 2003 2:45 am

I'm experiencing a problem with the date in the emails from my checkout.pl. When I use Steven Nyland's 'date trick' I get an error:
Undefined subroutine &main::timegm called at checkout.pl line 254, chunk 1.
Which is this line: $OrdNum = timegm($sec,$min,$hour,$mday,$mon,$year,$wday,$yday);

So I used WebRecka's 'SIMPLE METHOD' and rearranged the vars to:
$OrdNum=qq~$year$hour$min$day$month~;
and I get this:
Order Date: December 15, 103 14:45:13
Order Number: 1031445131511

The year shows as 103 in both fields and the month in the Order Number is one off.
$year$hour$min$sec$day$month
103 14 45 13 15 11

The year in both and the order number month are wrong no matter which var arrangement I use.

I see the month also appears incorrect in the reply from krismcewan;
Order Date: August 27, 2003 12:04:42
Order Number: 20031204277-6

If you ignore the -6 (created by the order number database) the year prints correctly but unless I'm mistaken the last 7 should be an 8 (August=the 8th month)
$year$hour$min$day$month
2003 12 04 27 7

I've tried the original checkout.pl and I get the year as 2003 but I would really like to use this order number mod. Has anyone else noticed this? Any ideas?

Thanks,
jlaw
tydye
 
Posts: 6
Joined: Wed May 14, 2003 12:19 am
Location: US

Postby tydye » Tue Dec 16, 2003 5:51 am

I figured out that when I put a # before this line by WebRecka;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
the year comes out okay but the month in the Order Number (the last 2 numbers) is still one off.

#($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);

$OrdNum=qq~$year$hour$min$sec$day$month~;
if( $mode eq "BOTH" || $mode eq "EMAIL") {

Produces this:
Order Date: December 15, 2003 21:34:59
Order Number: 20032134591511

Thanks,
jlaw
tydye
 
Posts: 6
Joined: Wed May 14, 2003 12:19 am
Location: US

Postby stb » Wed May 12, 2004 9:10 pm

Nobody ever seemed to write about how to make the php version. Is someone able?
Kind regards
stb
 
Posts: 6
Joined: Wed May 12, 2004 3:45 pm
Location: Denmark

Postby kavalier » Sun Aug 22, 2004 12:25 am

In response to the year and month issues that tydye has had...

Check out the link below:

http://perl.about.com/library/weekly/aa051601a.htm

The page explains the localtime() function and why the numbers are off. It also gives some info on how to fix the problem.
kavalier
 
Posts: 12
Joined: Fri Aug 20, 2004 6:50 am

Can't get it to work.

Postby Twig » Thu Aug 18, 2005 1:28 pm

Hi Everone.

I tried this modification.
I don't know what i am doing wrong but it seams that the changes I made in the checkout.pl file did nothing at all.
Everything still works but still no order number.
I am a real novice so any help will be much appreciated.

Thanks
Twig
 
Posts: 11
Joined: Thu Aug 04, 2005 5:20 am

PHP Verion

Postby PyRoAcIdK » Mon Jul 09, 2007 4:07 am

THIS IS FOR THE PHP VERSION OF CHECKOUT <checkout.php>

This script will generate an incremental number based on the previous number +1.

You will need to create a text file called orders.txt with the number 0 to start with.

orders.txt NEEDS to be CHMOD 777

Above:
//##############################################################
//#FUNCTION: doFormError

Place:
//##############################################################
//#FUNCTION: OrderNum #
//#RETURNS: $ordernum #
//#PURPOSE: Generate an order number, 1 higher than last #
//##############################################################

$filename = "orders.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
$ordernum = ($contents + 1);
$handle = fopen($filename, w);
fwrite($handle, $ordernum);
fclose($handle);

$displayordernum = str_pad($ordernum, 6, "0",STR_PAD_LEFT);

Under:

$strMessageBody .= "Order Date: $today \n";
$strMessageBody .= " \n";

Place:

$strMessageBody .= "Order Number: $displayordernum \n";
$strMessageBody .= " \n";

Under:

fputs($CSVF, "$today");
fputs($CSVF, "\",\"");

Place:

fputs($CSVF, "$ordernum");
fputs($CSVF, "\",\"");

On our output page, under:
echo "<h2>Thank you. Your order has been received.</h2>";

Place:

echo "Order Number: <b> $displayordernum </b>";


You number will look like 000028.
PyRoAcIdK
WebMaster
 
Posts: 2
Joined: Thu Jul 05, 2007 5:17 pm

Re: Unique Order/Invoice Number Mod

Postby jmlwsk » Fri Mar 05, 2010 7:41 pm

I tried method 2 for putting unique order numbers into the emails and csvf. I was also able to add 3 letters inf front of the number to identify between my orders and orders for my associate. Not a problem, just add them inside the quotes but before the $ on the print command lines.

I found a minor glitch with the way the function inputs the number from the dat file though. It's not recognizing the 0 as an integer and drops it every time, which means that it will only auto increment 1-9 and start back at 1 again. I tested by initializing the dat file with a value of 090909. When I placed a trial order it auto incremented back to one. Any ideas on how to fix this??
jmlwsk
WebMaster
 
Posts: 6
Joined: Tue Feb 23, 2010 6:49 pm
Location: Toledo, Ohio

Re: Unique Order/Invoice Number Mod

Postby opa » Tue Jul 27, 2010 10:10 am

i use this code in nopcart 4.40 itself
to generate order numbers.
Works for about 5 years without problems.

I use the first part as the date off order en second part is the order nummer it self.

Look like this:
20100726-12345
Date 26 July 2010 invoice 12345

you can also use
2010July26-12345

It very flexible code.

Code: Select all
# Place the following just above the E-Mail Message text
# Open "$orderNbr_Data" (ordernbr.dat) and read the Order Number ($last_Nbr)
# assigned to the previous Customer .

if (open(SEQUENCE, "<$orderNbr_Data")) { # Open file for reading (output)
@lines = <SEQUENCE>; # Read first line
close(SEQUENCE); # Close file
@nbr_Info = split(/\|/, $lines[0]); # Separate variables
$last_Nbr = $nbr_Info[0]; # Read variable
}

if (defined $last_Nbr) {
$this_Nbr = $last_Nbr + 1; # Increment Order Nbr by 1
open(SEQUENCE, ">$orderNbr_Data"); # Open the file for writing (input)
print SEQUENCE "$this_Nbr\n"; # Write to file
close(SEQUENCE); # Close the file
}

Voor hulp in de Nederlandse taal alleen voor de nopcart.js of checkout.pl
opa
WebMaster
 
Posts: 135
Joined: Tue Jan 10, 2006 4:17 pm
Location: Netherlands

Re: Unique Order/Invoice Number Mod

Postby epipeinfo » Tue Nov 02, 2010 11:45 am

Thanks :D :D
epipeinfo
WebMaster
 
Posts: 1
Joined: Tue Nov 02, 2010 11:42 am

Re: Unique Order/Invoice Number Mod

Postby opa » Sat Feb 12, 2011 4:00 pm

Working on a MOD
that show a online and printable invoice HTML page.
Go from manage page to checkout page and after final the costumer see there invoice page.
( 3 stage ordering )

Costumer have a automatic generated online invoice ( more flexible and neater as a email ).
The page / function is working fine except,
i getting stuck with the invoice number show in HTML page.

HELP:
Like to show the invoice number in the HTML invoice page
Anyone have a idea how to read the invoice file to show the number in HTML page?
Voor hulp in de Nederlandse taal alleen voor de nopcart.js of checkout.pl
opa
WebMaster
 
Posts: 135
Joined: Tue Jan 10, 2006 4:17 pm
Location: Netherlands

Re: Unique Order/Invoice Number Mod

Postby Histographik » Thu Feb 17, 2011 9:32 am

Randomising Order Numbers

I have found that sequential order numbers are risky and open to manipulation. As an alternative, a random order number is much easier to manage.
In my business records i just associate the random OrderID with a date and an email address - producing a unique code to identify customers.

Perl Script Random Order Number

Code: Select all
$range = some value;
$minimum = some value;
$randnum = int(rand($range)) + $minimum;
$orderid = "$randnum";


the reasonably unpredictable $orderid value can then be referred to easily and placed in HTML/email documents

Just a thought :idea:
Histographik
WebMaster
 
Posts: 18
Joined: Sun Mar 14, 2010 2:40 am
Location: Hong Kong

Re: Unique Order/Invoice Number Mod

Postby opa » Fri Feb 18, 2011 12:41 pm

Thanks,
using ordernumber and HTML invoice in the email script itself, is working for some time.
HTML page inside the email script it self,
for me is not able to deleted the order cookie.
So when user click again and again and again, send multible orders.
( some byers do this )

Therefore,
like to change this by using a standard HTML page outside the email script.
( faster when multiple users send orders )
The HTML page can deleted the order cookie easy way ( i notice while testing )

But this HTML page outside email script, show No invoice number :(
Voor hulp in de Nederlandse taal alleen voor de nopcart.js of checkout.pl
opa
WebMaster
 
Posts: 135
Joined: Tue Jan 10, 2006 4:17 pm
Location: Netherlands

Previous

Return to Modifications

Who is online

Users browsing this forum: No registered users and 0 guests

cron