------------ File: tncengine.cgi (web_store.cgi), in the main section. elsif ($form_data{'print_order_form_button'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "$sc_order_lib_path"); &display_printable_order_form; exit; } ------------ File: web_store_order_lib.pl Subroutine: display_printable_order_form ############################################################ # # subroutine: display_printable_order_form # Usage: # &display_printable_order_form() # # Parameters: # None. This takes input from the form # variables of the previously displayed # order form # # Output: # The HTML for displaying the shipping, discount, # and sales tax calculations for the cart. The ascii # text version of this is returned appended to # $text_of_cart. # # The $text_of_cart along with the form fields that # the user submitted will be emailed and/or logged # to a file depending on variables in the setup file. # ############################################################ sub display_printable_order_form { local($subtotal, $total_quantity, $total_measured_quantity, $text_of_cart, $required_fields_filled_in); # # First, we output the header of # the processing of the order # print qq! The Notgrass Company - Printable Order Form
Print this page and mail it with payment to:
The Notgrass Company
370 S. Lowe Ave., Suite A
PMB 211
Cookeville, TN 38501

!; # We display the cart table. # This also has the effect of # populating the text_of_cart # variable with the ASCII text version # of the cart for emailing/logging # the order that is being processed. # ($subtotal, $total_quantity, $total_measured_quantity, $text_of_cart) = &display_cart_table("process order"); # # Now that the sub-total has been # obtained from the cart, we # can calculate shipping, sales tax, # discount, and grand total. This # new information is appended to # the $text_of_cart variable. # $text_of_cart = &display_calculations($subtotal,"at", $total_measured_quantity,$text_of_cart); # # Now that we have the text of the cart # all together. We check the required # form fields from the previous form # to see if they were filled in by the user # # $required_fields_filled_in is set to "yes" # and remains this way until any ONE # required field is missing -- at which # point it is set to no. # print ""; $required_fields_filled_in = "yes"; foreach $required_field (@sc_printable_order_form_required_fields) { if ($form_data{$required_field} eq "") { $required_fields_filled_in = "no"; print "

You forgot to fill in " . $sc_order_form_array{$required_field} . ".

\n"; } } # End of checking required fields foreach $required_field (@sc_printable_order_form_display_fields) { print $sc_order_form_array{$required_field} . ": " . $form_data{$required_field} . "
"; } print "

\n"; # Since the required fields were # filled in correctly, we process # the rest of the order # # if ($required_fields_filled_in eq "yes") { # The $text_of_cart is appended with all # the values for the form that the user # has entered into the system. # foreach $form_field (sort(keys(%sc_order_form_array))) { $text_of_cart .= &format_text_field($sc_order_form_array{$form_field}) . "= $form_data{$form_field}\n"; } $text_of_cart .= "\n"; # # If PGP (Pretty Good Privacy) is in # use, then we translate the text of the # cart to a PGP encrypted form using # the pgp-lib.pl file that we provided # with the web_store. # if ($sc_use_pgp =~ /yes/i) { &require_supporting_libraries(__FILE__, __LINE__, "$sc_pgp_lib_path"); $text_of_cart = &make_pgp_file($text_of_cart, "$sc_pgp_temp_file_path/$$.pgp"); $text_of_cart = "\n" . $text_of_cart . "\n"; } # # If we are sending the order through # email, then we use the mail-lib.pl # send_mail routine. # if ($sc_send_order_to_email =~ /yes/i) { &send_mail($sc_order_email,$sc_order_email, "Web Store Order", $text_of_cart); } # If we are sending the order to # a log file. Then, we use the following # routine to append to the log file # specified in the setup. # # The entries in the log file # are separated by two lines of # 40 hyphens ("-" x 40) # if ($sc_send_order_to_log =~ /yes/i) { open (ORDERLOG, ">>$sc_order_log_file"); print ORDERLOG "-" x 40; print ORDERLOG $text_of_cart; print ORDERLOG "-" x 40 . "\n"; close (ORDERLOG); } print qq! Return to The Notgrass Company Home Page !; } else { # The user is notified if the order # was not a success (not all required # fields were filled in). # print "

Your order is not ready to print!

\n"; print "

Press the Back button in your browser and
complete the order form.

\n"; } # The footer is printed print "
\n"; print qq! !; } # End of process_order_form ----------------------------------- File: web_store.setup.* Section: Order Form Definition Variables I added two arrays to the setup file that the "display_printable_order_form" subroutine in the "web_store_order_lib.pl" file uses. You can customize them, of course, depending on which fields you want to require or display. @sc_printable_order_form_required_fields = ("01-name", "02-b_street_address", "03-b_city", "04-b_state", "05-b_zip", "06-b_country", "12-phone", "14-e-mail"); @sc_printable_order_form_display_fields = ("01-name", "02-b_street_address", "03-b_city", "04-b_state", "23-b_province", "05-b_zip", "06-b_country", "12-phone", "13-fax", "14-e-mail");