(modification for the perl script / NOP Cart verion 4.4.0)
It is possible to have NOP Cart create a order/invoice nr for each order submitted (and processed by the Perl script). There are two different way's of doing this. Option one is the 'date trick' where the order number will be created based on the date & time of the order. Option two is a custom order number database that can be tweaked fully. Let's start with option 1:
*********************************
Order/Invoice Number - Option 1
*********************************
- Step 1 : Open your checkout.pl file in a Perl Script editor (e.g. PCE - free download at http://www.perlvision.com)
- Step 2 : Find the following line:
print MAIL "Order Date: $months[$month] $day, $year $hour:$min:$sec \n"; (line 506)
Below this line, copy & paste the following line:
print MAIL "Order Number: $OrdNum \n"; - Step 3 : Find the following line:
print CSVF "\""; (line 316)
Below this line, copy & paste the following lines:
print CSVF "$OrdNum";
print CSVF "\",\""; - Step 4 : Find the following line:
print MAIL "Order Date: $months[$month] $day, $year $hour:$min:$sec \n"; (line 259)
Below this line, copy & paste the following line:
print MAIL "Order Number: $OrdNum \n"; - Step 5 : Find the following line:
if( $mode eq "BOTH" || $mode eq "EMAIL") { (line 250)
Above this line, copy & paste the following line:
$OrdNum = timegm($sec,$min,$hour,$mday,$mon,$year,$wday,$yday);
*********************************
Order/Invoice Number - Option 2
*********************************
- Step 1 : Create a new txt (e.g. with Notepad) file and name it ordernbr.dat,
- Step 2 : initialize the ordernbr.dat file by entering 000000 as the first line,
- Step 3 : Save the ordernbr.dat file,
- Step 4 : Upload the ordernbr.dat file to your CGI-BIN directory and set file permissions to 766 (CHMOD 766).
(The ordernbr.dat file should be in the same directory as your checkout.pl script), - Step 5 : Open your checkout.pl file in a Perl Script editor (e.g. PCE - free download at http://www.perlvision.com)
- Step 6 : Find the following line:
print MAIL "Order Date: $months[$month] $day, $year $hour:$min:$sec \n"; (line 506)
Below this line, copy & paste the following line:
print MAIL "Order Number: $this_Nbr \n"; - Step 7 : Find the following line:
print CSVF "\""; (line 316)
Below this line, copy & paste the following lines:
print CSVF "$this_Nbr";
print CSVF "\",\""; - Step 8 : Find the following line:
print MAIL "Order Date: $months[$month] $day, $year $hour:$min:$sec \n"; (line 259)
Below this line, copy & paste the following line:
print MAIL "Order Number: $this_Nbr \n"; - Step 9 : Find the following line:
if( $mode eq "BOTH" || $mode eq "EMAIL") { (line 250)
Above this line, copy & paste the following code snipplet:
## BEGIN Custom Order Number
$orderNbr_Data = 'ordernbr.dat';
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
}
## END Custom Order Number
Option two creates an ordernumber based on the initial value as defined in the file order_nbr.dat. It increments the number with '1', writes the created order number on both e-mail confirmations (to you and to the customer) and finally it writes the order to the CSV file.
Good luck,
Steven
