Can S-Mart generate order numbers?

greenspun.com : LUSENET : S-Mart Shopping Cart : One Thread

Some of our customes would rather fax us their CC details than email them to us, but we had difficulty in tying up these faxes with the email orders. Is it possible to generate an order numbet that they could quote on their fax?

Many thanks

-- Rufus Biggs (rufus.biggs@m-audio.co.uk), May 04, 2000

Answers

Sure is, I just added this feature to S-Mart for someone. Step 1: Add this to smart.cfg: $order_num_file = "order_number.dat"; Be sure to make a one line file that only contains a number, such as 1000, with out a carriage return at the end. Then name the one line file "order_number.dat". Step 2: In S-Mart.cgi (or whatever you renamed the main CGI file) go to the buy_items2 routine and make it look like this: sub buy_items2 { &check_required; #open order number file open (NUMBER, "$order_num_file"); #read in contents of order number file $num = ; #close order number file close (NUMBER); &print_header; if ($useverify eq '1' && ($cardtype eq 'visa' || $cardtype eq 'mastercard' || $cardtype eq 'novus' || $cardtype eq 'amex')) { &CC_Verify; } if ($usetrack eq 1) { &track_order; } &send_order; &send_verify; print "You have successfully ordered the following:
\n"; print "Your order number is: # $num
\n"; print "Please write this number down for later reference.

\n"; &list_items; print "

\n"; if ($usetrack eq 1) { my($sys) = "mv $reffile $basepath/$orderdir/$storename- $orderid"; system($sys); print "$trackurlTrack your order
"; } unlink($reffile); &print_footer; #increase the order number $num++; #open order number file open (NUMBER, ">$order_num_file"); #print contents of $num to order number file print NUMBER "$num"; #close order number file close (NUMBER); } This reads the old order number, prints the new order number on the "Thanks for ordering" page, adds one to the number and stores the order number to the file for the next customer to use. Step 3: Near the top of the main CGI file add this line: my $num = 0; I usually set values to zero for error detection purposes, so if the order number is ZERO one day you know something is wrong with opening the order_number.dat file. Step 4: In the sections of S-Mart.cgi that print the emails add this if you want the number to be printed in the message: print MAIL "Your order number is: # $num \n\n"; Just paste it where the message is to appear in the email. Step 5: Upload the revised S-Mart.cgi and order_number.dat to the same directory. I set order_number.dat to 777 so there would be no problems reading and writing to it. One final note: To restart the order number counter, just change the number in the .DAT file and upload it. I hope this helps. Good luck.

-- Jeremy Wall (cs_freak@pacbell.net), May 11, 2000.

Seeing as how the message board destroyed the code I gave in my response I posted the formatted (readable) answer at http://home.pacbell.net/jhw1701/add_order_number.txt

-- Jeremy Wall (cs_freak@pacbell.net), May 11, 2000.

Moderation questions? read the FAQ