starview
asked on
Programming for commerce.cgi shopping cart-Shipping by category
Please don't tell me to go to Commerce.cgi, I have been there and got no help.
I am not even sure I have the right
I get this error in the checkout:
Software error:
Undefined subroutine &main::shipping_by_categor y called at
./library/shipping_lib.pl line 44.
Here is the script I rewrote and changed from the one in commerce.cgi This
script works anyway the first part does if I change the name of the script to
"shipping_by_subtotal.pl" and change the "sub shipping_by_category" to
shipping_by_subtotal"
But when I order by a different category it still uses the same shipping
price.
I guess I might be leaving something out. I am not too sure if the
category_count is the correct way of picking the category to be used. I hope
you can understand what I am writing. Or have any suggestion, maybe I am way
off base. I place this script in the add-on folder
sub shipping_by_category
{
local ($shipMethod, $subtotal, $weight, $total_shipping, $category_count) =
@_; local ($shipping_price);
if ($category_count{'Gifts_No velty'} eq "") {
if ($subtotal <= 100.00) { $shipping_price = 5.95; }
elsif ($subtotal >= 101.00 && $subtotal <= 249.00) { $shipping_price =
7.95; }
elsif ($subtotal >= 250.00 && $subtotal <= 499.00) { $shipping_price =
9.95; }
# All orders over the previous value
else { $shipping_price = 0.00; }
} else {
if ($subtotal <= 20.00) { $shipping_price = 7.00; }
elsif ($subtotal >= 30.00 && $subtotal <= 39.00) { $shipping_price =
8.50; }
elsif ($subtotal >= 40.00 && $subtotal <= 49.00) { $shipping_price =
10.00; }
elsif ($subtotal >= 50.00 && $subtotal <= 59.00) { $shipping_price =
11.50; }
elsif ($subtotal >= 60.00 && $subtotal <= 69.00) { $shipping_price =
13.00; }
elsif ($subtotal >= 70.00 && $subtotal <= 79.00) { $shipping_price =
15.00; }
elsif ($subtotal >= 80.00 && $subtotal <= 89.00) { $shipping_price =
19.00; }
elsif ($subtotal >= 90.00 && $subtotal <= 99.00) { $shipping_price =
23.00; }
elsif ($subtotal >= 100.00 && $subtotal <= 119.00) { $shipping_price =
27.00; }
elsif ($subtotal >= 120.00 && $subtotal <= 129.00) { $shipping_price =
32.00; }
# All orders over the previous value
else { $shipping_price = 38.00; }
}
return ($shipping_price);
}
1;
I am not even sure I have the right
I get this error in the checkout:
Software error:
Undefined subroutine &main::shipping_by_categor
./library/shipping_lib.pl line 44.
Here is the script I rewrote and changed from the one in commerce.cgi This
script works anyway the first part does if I change the name of the script to
"shipping_by_subtotal.pl" and change the "sub shipping_by_category" to
shipping_by_subtotal"
But when I order by a different category it still uses the same shipping
price.
I guess I might be leaving something out. I am not too sure if the
category_count is the correct way of picking the category to be used. I hope
you can understand what I am writing. Or have any suggestion, maybe I am way
off base. I place this script in the add-on folder
sub shipping_by_category
{
local ($shipMethod, $subtotal, $weight, $total_shipping, $category_count) =
@_; local ($shipping_price);
if ($category_count{'Gifts_No
if ($subtotal <= 100.00) { $shipping_price = 5.95; }
elsif ($subtotal >= 101.00 && $subtotal <= 249.00) { $shipping_price =
7.95; }
elsif ($subtotal >= 250.00 && $subtotal <= 499.00) { $shipping_price =
9.95; }
# All orders over the previous value
else { $shipping_price = 0.00; }
} else {
if ($subtotal <= 20.00) { $shipping_price = 7.00; }
elsif ($subtotal >= 30.00 && $subtotal <= 39.00) { $shipping_price =
8.50; }
elsif ($subtotal >= 40.00 && $subtotal <= 49.00) { $shipping_price =
10.00; }
elsif ($subtotal >= 50.00 && $subtotal <= 59.00) { $shipping_price =
11.50; }
elsif ($subtotal >= 60.00 && $subtotal <= 69.00) { $shipping_price =
13.00; }
elsif ($subtotal >= 70.00 && $subtotal <= 79.00) { $shipping_price =
15.00; }
elsif ($subtotal >= 80.00 && $subtotal <= 89.00) { $shipping_price =
19.00; }
elsif ($subtotal >= 90.00 && $subtotal <= 99.00) { $shipping_price =
23.00; }
elsif ($subtotal >= 100.00 && $subtotal <= 119.00) { $shipping_price =
27.00; }
elsif ($subtotal >= 120.00 && $subtotal <= 129.00) { $shipping_price =
32.00; }
# All orders over the previous value
else { $shipping_price = 38.00; }
}
return ($shipping_price);
}
1;
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That is the reason I ask if someone who knew anything about commerce,cgi shopping cart software.
There is no shipping_by_category that I know of, I though someone who Had knowledge of commerce-cgi might be able to help me build one.
There is no shipping_by_category that I know of, I though someone who Had knowledge of commerce-cgi might be able to help me build one.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You have lost me there
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I did not change any script this is and add on script for shipping cost per category.
I will attach a script that is a add on for shipping per subtotal, this script is all ready in the add-on fold.
it is a pl script I had to change the name to a txt file, would not take here other wise.
shipping-by-subtotal.txt
I will attach a script that is a add on for shipping per subtotal, this script is all ready in the add-on fold.
it is a pl script I had to change the name to a txt file, would not take here other wise.
shipping-by-subtotal.txt
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Looked in all the directories no log file and no tmp directory
ASKER
The checkout showed $1.00 added to my total
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I made a tmp directory and set the permission to 777 and there is still no log file. and my server is not windows. This directory is in the cgi-bin folder and in the same directory as the add-0n folder which is set to 777
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The $12.34 did show up and it wrote to the log file which I have attached
shipping-by-category.log
shipping-by-category.log
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am already calculating the shipping cost using subtotals, but that that does it for all items in my shopping cart.
What I was looking for was to beable to set a shipping cost for each of my categories with a different shipping cost. That would include all the subcategories with in the category.
What I was looking for was to beable to set a shipping cost for each of my categories with a different shipping cost. That would include all the subcategories with in the category.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That fine, I have found someone that knows commerce-cgi and say that he can do it.
I want to thank you for your try
I want to thank you for your try
ASKER
##########################
# Main Shipping Routine
##########################
sub calculate_shipping
{
local ($subtotal, $total_weight) = @_;
local ($total_shipping);
local ($shipKey, $shipMethod) = split(/\|/, $form_data{'upgradeShippin
open(SHIPPINGFILE, "$sc_log_file_directory_pa
while (<SHIPPINGFILE>)
{
@ship_options = split(/\|/, $_);
if ($ship_options[0] eq $shipKey)
{
$shipping_price = $ship_options[2];
$shipping_percent = $ship_options[3];
$shipping_weight = $ship_options[4];
$shipping_sub = $ship_options[5];
chomp $shipping_sub;
}
}
close (SHIPPINGFILE);
if ($shipping_price)
{
$total_shipping += $shipping_price;
}
if ($shipping_percent)
{
$total_shipping += $subtotal*($shipping_perce
}
if ($shipping_weight eq "yes")
{
$total_shipping += $total_weight;
}
if ($shipping_sub)
{
$shipping_sub =~ /([\w]+)/;
$total_shipping += &{$shipping_sub}($shipKey,
}
return ($total_shipping);
}
1;
--------------------------
This the store varibles
##########################
# Misc. HTML Store Variables #
##########################
$sc_shall_i_let_client_kno
$sc_item_ordered_message = qq~
<!-- Start \$sc_item_ordered_message - html_lib.pl -->
<div class="item_added_message"
<!-- End \$sc_item_ordered_message - html_lib.pl -->
~;
##########################
# create_html_page_from_db
##########################
sub create_html_page_from_db
{
local ($fromshown, $toshown, $pages, $keywords);
local ($lowrange, $highrange);
local (@database_rows, @database_fields, @item_ids, @display_fields);
local ($total_row_count, $id_index, $display_index, $header_title);
local ($row, $field, $empty, $option_tag, $option_location, $output);
if (!($sc_db_lib_was_loaded =~ /yes/i))
{
require "$sc_library_directory_pat
&errorcode(__FILE__, __LINE__, "$sc_library_directory_pat
}
($status,$total_row_count)
$nextCount = $form_data{'next'}+$items_
$prevCount = $form_data{'next'}-$items_
$minCount = $form_data{'next'};
$maxCount = $form_data{'next'}+$items_
$item_counter = "1";
$items_per_row = "3";
if ($form_data{'row'})
{
$items_per_row = $form_data{'row'};
}
if ($form_data{'pid'} eq "" && $form_data{'ppage'} eq "")
{
$sc_product_display_row .= qq~
<div align="center">
<center>
<table border="0" width="90%"><tr><td width="33%" valign="top">
~;
}
my $percent = int(100/$items_per_row);
foreach $row (@database_rows)
{
if ($form_data{'pid'} eq "" && $form_data{'ppage'} eq "")
{
if ($rowCount > $minCount && $rowCount <= $maxCount)
{
if ($item_counter == $items_per_row)
{
$sc_product_display_row .= qq~
</td></tr><tr><td width="$percent\%" valign="top">
~;
$item_counter = "1";
} else {
$sc_product_display_row .= qq~
</td><td width="$percent\%" valign="top">
~;
$item_counter++;
}
}
}
$rowCount++;
$prevHits = $items_per_page;
$nextHits = $items_per_page;
if ($rowCount > $minCount && $rowCount <= $maxCount)
{
@database_fields = split (/\|/, $row);
if ($database_fields[$db{"opt
{
($empty, $option_tag, $option_location) = split (/%%/, $database_fields[$db{"opti
$database_fields[$db{"opti
open (OPTION_FILE, "<$sc_options_directory_pa
&errorcode(__FILE__, __LINE__, "$sc_options_directory_pat
while (<OPTION_FILE>)
{
s/\{PRODUCT_ID\}/$database
$database_fields[$db{"opti
}
close (OPTION_FILE);
}
$sc_product_display_row .= &displayProductPage;
}
}
if ($form_data{'pid'} eq "" && $form_data{'ppage'} eq "")
{
$sc_product_display_row .= qq~
</td></tr></table></center
~;
}
local ($hidden_string) = &make_hidden_string("no_ne
$product = $form_data{'product'};
if ($status ne "")
{
if ($status =~ /max.*row.*exceed.*/i)
{
$product = $form_data{'product'};
if($form_data{'next'} > "0")
{
if ($ENV{'REQUEST_URI'} =~ /commerce.cgi/i || !($use_html))
{
$link = "$sc_store_url?next=$prevC
} else {
$link = "$html_folder\/$prevCount\
}
$back = qq~
<a href="$link">
<span class="back_link"><<< Back</span>
</a>
~;
}
if ($maxCount == $rowCount-1)
{
$nextHits = (@database_rows-$maxCount)
if ($nextHits == 1)
{
if ($ENV{'REQUEST_URI'} =~ /commerce.cgi/i || !($use_html))
{
$link = "$sc_store_url?next=$maxCo
} else {
$link = "$html_folder\/$maxCount\/
}
$front = qq~
<a href="$link">
<span class="next_link">Next >>></span>
</a>
~;
}
}
if ($maxCount < $rowCount && $maxCount != $rowCount-1)
{
if ($maxCount >= $rowCount-$nextHits )
{
$lastCount = $rowCount-$maxCount;
if ($ENV{'REQUEST_URI'} =~ /commerce.cgi/i || !($use_html))
{
$link = "$sc_store_url?next=$maxCo
} else {
$link = "$html_folder\/$maxCount\/
}
$front = qq~
<a href="$link">
<span class="next_link">Next >>></span>
</a>
~;
} else {
if ($ENV{'REQUEST_URI'} =~ /commerce.cgi/i || !($use_html))
{
$link = "$sc_store_url?next=$maxCo
} else {
$link = "$html_folder\/$maxCount\/
}
$front = qq~
<a href="$link">
<span class="next_link">Next >>></span>
</a>
~;
}
}
if ($status =~ /max.*row.*exceed.*/i)
{
$next = $form_data{'next'};
$product = $form_data{'product'};
if ($maxCount > $total_row_count)
{
$toshown = $total_row_count;
} else {
$toshown = $maxCount;
}
if ($next < 1)
{
$fromshown = 1;
} else {
$fromshown = $next;
}
$page = $toshown/$items_per_page;
$pages = $total_row_count/$items_pe
if ($page =~ /\./g)
{
$page = int($page)+1;
}
if ($pages =~ /\./g)
{
$pages = int($pages)+1;
}
$cc=1;
$page_message .= qq~<span class="default_text">Page:
while ($cc<=$pages)
{
$ccnext = ($cc-1)*$items_per_page;
if ($cc == $page)
{
$page_message .= qq~
<span class="default_text">$cc&n
~;
} else {
if ($ENV{'REQUEST_URI'} =~ /commerce.cgi/i || !($use_html))
{
$link = "$sc_store_url?next=$ccnex
} else {
$link = "$html_folder\/$ccnext\/$f
}
$page_message .= qq~
<a href="$link"><span class="default_text">$cc</
~;
}
$cc++;
}
}
}
}
if ($form_data{'pid'})
{
$header_title = "Product Listing - $database_fields[$db{'name
} elsif ($form_data{'keywords'}) {
$header_title = "Search Listing - $form_data{'keywords'}";
} else {
$header_title = "Category Listing - $product";
}
&StoreHeader($header_title
# Added for expandability
print "$sub_product_header_messa
if ($form_data{'add_to_cart_b
{
print "$sc_item_ordered_message"
}
print $sc_product_display_row;
# Added for expandability
print "$sub_product_footer_messa
&StoreFooter("regular");
}
##########################
# display_page Subroutine #
##########################
sub display_page
{
local ($page, $routine, $file, $line) = @_;
if ($form_data{'secure'})
{
&StoreHeader("$site_name",
} else {
&StoreHeader("$site_name",
}
# Added for expandability
print "$sub_page_header_message"
open (PAGE, "<$page") || &errorcode(__FILE__, __LINE__, "$page", "$!", "print", "FILE OPEN ERROR", "0");
while (<PAGE>)
{
$page = $form_data{'page'};
s/\{mini_cart\}/$minicart/
s/\{scriptURL\}/$sc_store_
s/\{cart_id\}/$cart_id/g;
s/\{page\}/$page/g;
s/\{date\}/$date/g;
if ($form_data{'secure'})
{
s/\{URLofImages\}/$URL_of_
} else {
s/\{URLofImages\}/$URL_of_
}
s/\{highlightcolor\}/$high
s/\{highlightfontcolor\}/$
s/\{site_name\}/$site_name
s/\{custom1\}/$custom1/g;
s/\{custom2\}/$custom2/g;
s/\{custom3\}/$custom3/g;
s/\{custom4\}/$custom4/g;
s/\{custom5\}/$custom5/g;
s/\{custom6\}/$custom6/g;
s/\{custom7\}/$custom7/g;
s/\{custom8\}/$custom8/g;
s/\{custom9\}/$custom9/g;
s/\{custom10\}/$custom10/g
s/\{custom11\}/$custom11/g
s/\{custom12\}/$custom12/g
s/\{custom13\}/$custom13/g
s/\{custom14\}/$custom14/g
s/\{custom15\}/$custom15/g
if ($form_data{'add_to_cart_b
$sc_shall_i_let_client_kno
{
if ($_ =~ /<FORM/i)
{
print "$_";
print "$sc_item_ordered_message"
}
}
if ($_ =~ /<!--.*&/i)
{
my $cmd = (split(/--/, $_))[1];
$cmd =~ /([\w]+)/;
$cmd = "$1";
print eval($cmd);
} else {
print $_;
}
}
close (PAGE);
# Added for expandability
print "$sub_page_footer_message"
if ($form_data{'secure'})
{
&StoreFooter("secure");
} else {
&StoreFooter("regular");
}
}
##########################
# Display Product Page
##########################
sub displayProductPage
{
local($keywords, $imageURL, $product_page, $control, $description, $price);
$keywords = $form_data{'keywords'};
$keywords =~ s/ /+/g;
local ($hidden_fields) = &make_hidden_fields;
$encrypt_text = $database_fields[$db{"name
$control = &hmac_hex($encrypt_text, $encrypt_key);
$hidden_fields .= qq~
<input type="hidden" name="control" value="$control">
~;
if ($form_data{'pid'} eq "")
{
$ppage = "Thumb";
}
if ($form_data{'pid'} eq "" && $ENV{'REQUEST_URI'} !~ /commerce.cgi/i && $use_html eq "yes")
{
$ppage = "HTML";
}
if ($form_data{'ppage'})
{
$ppage = $form_data{'ppage'};
}
open (PAGE, "$sc_template_directory_pa
&errorcode(__FILE__, __LINE__, "$sc_template_directory_pa
while (<PAGE>)
{
$product_page .= $_;
}
close (PAGE);
$imageURL = $database_fields[$db{"imag
$small_image_test = "$images_path\/product\/$i
$large_image_test = "$images_path\/product\/$i
$na_image_if_not_found = "yes";
if ($na_image_if_not_found eq "yes")
{
if (-f $small_image_test)
{
$small_image = "$URL_of_images_directory\
} else {
$small_image = "$URL_of_images_directory\
}
if (-f $large_image_test)
{
$large_image = "$URL_of_images_directory\
} else {
$large_image = "$URL_of_images_directory\
}
} else {
$small_image = "$URL_of_images_directory\
$large_image = "$URL_of_images_directory\
}
$product_page =~ s/\{URLofImages\}/$URL_of_
$product_page =~ s/\{image\}/$imageURL/g;
$product_page =~ s/\{small_image\}/$small_i
$product_page =~ s/\{large_image\}/$large_i
$product_page =~ s/\{product_id\}/$database
$product_page =~ s/\{scriptURL\}/$sc_store_
$product_page =~ s/\{cart_id\}/$cart_id/g;
$product_page =~ s/\{product\}/$database_fi
$product_page =~ s/\{keywords\}/$keywords/g
$product_page =~ s/\{hidden_fields\}/$hidde
$product_page =~ s/\{name\}/$database_field
$description = $database_fields[$db{"desc
$description =~ s/\{cart_id\}/$cart_id/g;
$description =~ s/\{URLofImages\}/$URL_of_
$description =~ s/\{scriptURL\}/$sc_store_
$product_page =~ s/\{description\}/$descrip
$product_page =~ s/\{optionFile\}/$database
if ($database_fields[$db{"pri
{
$price = &display_price(&format_pri
}
$product_page =~ s/\{price\}/$price/g;
$product_page =~ s/\{hidden_price\}/$databa
$product_page =~ s/\{shipping\}/$database_f
$product_page =~ s/\{user1\}/$database_fiel
$product_page =~ s/\{user2\}/$database_fiel
$product_page =~ s/\{user3\}/$database_fiel
$product_page =~ s/\{user4\}/$database_fiel
$product_page =~ s/\{user5\}/$database_fiel
$product_page =~ s/\{highlightcolor\}/$high
$product_page =~ s/\{highlightfontcolor\}/$
$product_page =~ s/\{inventory\}/$inventory
$product_page =~ s/\{similar\}/$similar/g;
$product_page =~ s/\{custom1\}/$custom1/g;
$product_page =~ s/\{custom2\}/$custom2/g;
$product_page =~ s/\{custom3\}/$custom3/g;
$product_page =~ s/\{custom4\}/$custom4/g;
$product_page =~ s/\{custom5\}/$custom5/g;
$product_page =~ s/\{custom6\}/$custom6/g;
$product_page =~ s/\{custom7\}/$custom7/g;
$product_page =~ s/\{custom8\}/$custom8/g;
$product_page =~ s/\{custom9\}/$custom9/g;
$product_page =~ s/\{custom10\}/$custom10/g
$product_page =~ s/\{custom11\}/$custom11/g
$product_page =~ s/\{custom12\}/$custom12/g
$product_page =~ s/\{custom13\}/$custom13/g
$product_page =~ s/\{custom14\}/$custom14/g
$product_page =~ s/\{custom15\}/$custom15/g
return ($product_page);
}
##########################
sub StoreHeader
{
my ($title, $header) = @_;
my ($hidden_string) = &make_hidden_string;
my ($dcat, $v_category, $h_category, $d_category);
my ($pages, $h_pages);
$keywords = $form_data{'keywords'};
$keywords =~ s/ /+/g;
$cart_contents = &cart_content;
$mini_cart = &mini_cart;
($pages, $h_pages) = &pages;
if (-f "$sc_template_directory_pa
{
if ($form_data{'template'}){ $template = $form_data{'template'}; }
}
($d_category, $v_category, $h_category) = &categories;
open (TEMPLATE, "$sc_template_directory_pa
&errorcode(__FILE__, __LINE__, "$sc_template_directory_pa
while (<TEMPLATE>)
{
if ($_ =~ /\{DATA\}/i){ last; }
s/\{v_category\}/$v_catego
s/\{h_category\}/$h_catego
s/\{d_category\}/$d_catego
s/\{mini_cart\}/$minicart/
s/\{cart_id\}/$cart_id/g;
s/\{cart_contents\}/$cart_
s/\{highlightcolor\}/$high
s/\{highlightfontcolor\}/$
s/\{random_products\}/$ran
s/\{keywords\}/$keywords/g
s/\{next\}/$form_data{'nex
s/\{page\}/$page_message/g
s/\{product\}/$form_data{'
s/\{scriptURL\}/$sc_store_
s/\{site_name\}/$site_name
s/\{title\}/$title/g;
s/\{pages\}/$pages/g;
s/\{h_pages\}/$h_pages/g;
s/\{custom1\}/$custom1/g;
s/\{custom2\}/$custom2/g;
s/\{custom3\}/$custom3/g;
s/\{custom4\}/$custom4/g;
s/\{custom5\}/$custom5/g;
s/\{custom6\}/$custom6/g;
s/\{custom7\}/$custom7/g;
s/\{custom8\}/$custom8/g;
s/\{custom9\}/$custom9/g;
s/\{custom10\}/$custom10/g
s/\{custom11\}/$custom11/g
s/\{custom12\}/$custom12/g
s/\{custom13\}/$custom13/g
s/\{custom14\}/$custom14/g
s/\{custom15\}/$custom15/g
if ($header eq "secure")
{
s/\{URLofImages\}/$URL_of_
} else {
s/\{URLofImages\}/$URL_of_
}
s/\{hidden_string\}/$hidde
if (!($_ =~ /\{DATA\}/i))
{
if ($_ =~ /<!--.*&/i)
{
my $cmd = (split(/--/, $_))[1];
$cmd =~ /([\w]+)/;
$cmd = "$1";
print eval($cmd);
} else {
print $_;
}
}
}
}
##########################
sub StoreFooter
{
local ($footer) = @_;
local ($d_category, $v_category, $h_category, $pages, $h_pages);
local ($hidden_string) = &make_hidden_string;
($d_category, $v_category, $h_category) = &categories;
($pages, $h_pages) = &pages;
while (<TEMPLATE>)
{
s/\{v_category\}/$v_catego
s/\{h_category\}/$h_catego
s/\{d_category\}/$d_catego
s/\{mini_cart\}/$minicart/
s/\{front\}/$front/g;
s/\{back\}/$back/g;
s/\{scriptURL\}/$sc_store_
s/\{hidden_string\}/$hidde
s/\{pages\}/$pages/g;
s/\{h_pages\}/$h_pages/g;
s/\{page\}/$page_message/g
if ($footer eq "secure")
{
s/\{URLofImages\}/$URL_of_
} else {
s/\{URLofImages\}/$URL_of_
}
s/\{cart_id\}/$cart_id/g;
s/\{highlightcolor\}/$high
s/\{highlightfontcolor\}/$
s/\{random_products\}/$ran
s/\{site_name\}/$site_name
s/\{custom1\}/$custom1/g;
s/\{custom2\}/$custom2/g;
s/\{custom3\}/$custom3/g;
s/\{custom4\}/$custom4/g;
s/\{custom5\}/$custom5/g;
s/\{custom6\}/$custom6/g;
s/\{custom7\}/$custom7/g;
s/\{custom8\}/$custom8/g;
s/\{custom9\}/$custom9/g;
s/\{custom10\}/$custom10/g
s/\{custom11\}/$custom11/g
s/\{custom12\}/$custom12/g
s/\{custom13\}/$custom13/g
s/\{custom14\}/$custom14/g
s/\{custom15\}/$custom15/g
if (!($_ =~ /\{DATA\}/i))
{
if ($_ =~ /<!--.*&/i)
{
my $cmd = (split(/--/, $_))[1];
$cmd =~ /([\w]+)/;
$cmd = "$1";
print eval($cmd);
} else {
print $_;
}
}
}
close (TEMPLATE);
}
##########################
# cart_table_header
##########################
sub cart_table_header
{
my ($modify_type) = @_;
my ($hidden_fields) = &make_hidden_fields;
$keywords = $form_data{'keywords'};
$keywords =~ s/ /+/g;
if (($modify_type ne "") && ($modify_type ne "orderform") && ($modify_type ne "verify"))
{
$modify_type = qq~<td class="colored_cell_header
}
if ($modify_type eq "")
{
$modify_type = qq~<td class="colored_cell_header
}
if ($modify_type eq "orderform")
{
$modify_type = "";
}
if ($modify_type eq "verify")
{
$modify_type = "";
}
# Added for expandability
print "$sub_cart_table_header_me
print qq~
<FORM METHOD="post" ACTION="$sc_store_url">
$hidden_fields
<table border="0" cellpadding="5" cellspacing="0" WIDTH="90%" align="center">
<tr>
$modify_type
~;
$field_counter = 0;
foreach $field (@sc_cart_display_fields)
{
if ($sc_cart_index_for_displa
$sc_cart_index_for_display
$sc_cart_index_for_display
{
print qq~<td class="colored_cell_header
} else {
print qq~<td class="colored_cell_header
}
$field_counter++;
}
print qq~</tr>~;
}
##########################
# display_cart_table Subroutine #
##########################
sub display_cart_table
{
local ($reason_to_display_cart, $required_fields_filled_in
local (@cart_fields, $cart_id_number, $quantity, $unformatted_subtotal);
local ($subtotal, $unformatted_grand_total, $grand_total, $price);
local ($total_measured_quantity)
local ($display_index, $counter, $hidden_field_name);
local ($hidden_field_value, $display_counter, $product_id);
local ($ship_company, $upgradeShipPrice, $shipMethod);
local ($final_shipping, $final_discount, $final_sales_tax, $grand_total);
local ($hidden_string, $lineTotal, $cart_error, $product_name, $product_price );
$total_quantity = 0;
if (($reason_to_display_cart =~ /orderform/i) || ($reason_to_display_cart =~ /verify/i))
{
&StoreHeader("Cart Contents","secure");
} else {
&StoreHeader("Cart Contents","regular");
}
if (-s "$sc_cart_path")
{
if ($reason_to_display_cart =~ /orderform/i)
{
$reason_to_display_cart = "orderform";
&cart_table_header($reason
} elsif ($reason_to_display_cart =~ /verify/i) {
$reason_to_display_cart = "verify";
&cart_table_header($reason
} else {
&cart_table_header("Delete
}
open (CART, "$sc_cart_path") || &errorcode(__FILE__, __LINE__, "$sc_cart_path", "$!", "print", "FILE OPEN ERROR", "0");
while (<CART>)
{
$row_count++;
$remain = $row_count % 2; # This gets the remainder after division.
if ($remain)
{
$bgcolor = "#FFFFFF";
} else {
$bgcolor = "#DDDDDD";
}
print "<TR>";
chomp;
@cart_fields = split (/\|/, $_);
$cart_row_number = pop(@cart_fields);
push (@cart_fields, $cart_row_number);
$quantity = $cart_fields[$cart{"quanti
$product_id = $cart_fields[$cart{"produc
$product_name = $cart_fields[$cart{"name"}
$product_price = $cart_fields[$cart{"price"
if (($reason_to_display_cart =~ /orderform/i) && ($sc_order_check_db =~ /yes/i))
{
if (!($sc_db_lib_was_loaded =~ /yes/i))
{
require "$sc_library_directory_pat
&errorcode(__FILE__, __LINE__, "$sc_library_directory_pat
}
if ($product_id ne "00" && $product_id ne "0")
{
$cart_error = &check_db_with_product_id(
}
}
$total_quantity += $quantity;
$hidden_string = &make_hidden_string;
if ($reason_to_display_cart =~ /change*quantity/i)
{
print qq~
<TD ALIGN = "center">
<INPUT TYPE = "text" NAME = "$cart_row_number" SIZE ="3">
</TD>
~;
} elsif (($reason_to_display_cart =~ /orderform/i) || ($reason_to_display_cart =~ /process order/i) || ($reason_to_display_cart =~ /verify/i)) {
} else {
print qq~
<td class="cartcontents" bgcolor="$bgcolor">
<a href="$sc_store_url?submit
</td>
~;
}
$display_counter = 0;
foreach $display_index (@sc_cart_index_for_displa
{
if ($cart_fields[$display_ind
{
$cart_fields[$display_inde
}
if ($display_index == $cart{"price"})
{
$price = &display_price($cart_field
print qq~
<td class="cartcontents" align="right" bgcolor="$bgcolor" nowrap>$price</td>
~;
} elsif ($display_index == $cart{"options"}) {
$cart_html = "";
if (($reason_to_display_cart =~ /orderform/i) || ($reason_to_display_cart =~ /process order/i) || ($reason_to_display_cart =~ /verify/i))
{
$cart_html .= qq~
</tr>
<tr>
<td class="cartcontents" bgcolor="$bgcolor"> <
<td class="cartcontents" bgcolor="$bgcolor">$cart_f
<td class="cartcontents" bgcolor="$bgcolor"> <
<td class="cartcontents" bgcolor="$bgcolor"> <
~;
} else {
$cart_html .= qq~
</tr>
<tr>
<td class="cartcontents" bgcolor="$bgcolor"> <
<td class="cartcontents" bgcolor="$bgcolor"> <
<td class="cartcontents" bgcolor="$bgcolor">$cart_f
<td class="cartcontents" bgcolor="$bgcolor"> <
<td class="cartcontents" bgcolor="$bgcolor"> <
~;
}
print $cart_html;
} elsif ($display_index == $cart{"name"}) {
print qq~
<td class="cartcontents" bgcolor="$bgcolor">$cart_f
~;
} elsif ($display_index == $cart{"price_after_options
$lineTotal = &format_price($cart_fields
$lineTotal = &display_price($lineTotal)
print qq~
<td class="cartcontents" align="right" bgcolor="$bgcolor" nowrap>$lineTotal</td>
~;
} elsif (($display_index == "0") && ($reason_to_display_cart eq /orderform/i)) {
print qq~
<td class="cartcontents" align="center" bgcolor="$bgcolor">
<input class="cart_edit_quantity"
</td>
~;
} else {
print qq~
<td class="cartcontents" align="center" bgcolor="$bgcolor">$cart_f
~;
}
if ($display_index == $cart{"shipping"})
{
$total_measured_quantity += ($cart_fields[$cart{"quant
$shipping_total = $total_measured_quantity;
}
$display_counter++;
}
$total_measured_quantity += ($cart_fields[$cart{"quant
$shipping_total = $total_measured_quantity;
$unformatted_subtotal = ($cart_fields[$cart{"price
$subtotal = &format_price($cart_fields
$unformatted_grand_total = $grand_total + $subtotal;
$grand_total = &format_price($unformatted
$category_count{$cart_fiel
$category_subtotal{$cart_f
$cart_pid{$cart_fields[$ca
}
close (CART);
$price = &display_price(&format_pri
$shipping_total = &display_price($shipping_t
print qq~
</table>
~;
if ($reason_to_display_cart =~ /verify/i)
{
print qq~
<input type="hidden" name="total" value="$grand_total">
~;
}
print qq~
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td width="100%">
<div align="right">
<table width="300">
<tr>
<td class="cart_totals_labels"
<td class="cart_totals" width="40%" valign="top" align="right">$price</td>
</tr>
~;
($shipKey, $shipMethod) = split(/\|/, $form_data{'upgradeShippin
if (($form_data{'submit_order
{
($final_shipping, $final_discount, $final_sales_tax, $grand_total) = &calculate_final_values($g
if (-f "$sc_extra_directory_path/
{
$grand_total = &service_fee($grand_total)
}
$pass_final_shipping = &format_price($final_shipp
if ($final_shipping > 0)
{
$final_shipping = &format_price($final_shipp
$final_shipping = &display_price($final_ship
if($upgradeShipPrice && $shipMethod)
{
$shipText = $shipMethod;
} else {
$shipText = "Shipping";
}
print qq~
<tr>
<td class="cart_totals_labels"
<td class="cart_totals" width="50%" valign="top" align="right">$final_shipp
</tr>
~;
}
$pass_final_discount = &format_price($final_disco
if ($final_discount > 0)
{
$final_discount = &format_price($final_disco
$final_discount = &display_price($final_disc
print qq~
<tr>
<td class="cart_totals_labels"
<td class="cart_totals" width="50%" valign="top" align="right">$final_disco
</tr>
~;
}
$pass_final_sales_tax = &format_price($final_sales
if ($final_sales_tax > 0)
{
$final_sales_tax = &format_price($final_sales
$final_sales_tax = &display_price($final_sale
print qq~
<tr>
<td class="cart_totals_labels"
<td class="cart_totals" width="50%" valign="top" align="right">$final_sales
</tr>
~;
}
$pass_subtotal = &format_price($unformatted
$pass_grand_total = &format_price($grand_total
$grand_total = &display_price(&format_pri
if ($form_data{'submit_order_
{
print qq~
<tr>
<td class="cart_totals_labels"
<td class="cart_totals" width="50%" valign="top" align="right">$grand_total
</tr>
~;
}
}
print qq~
</table>
</div>
</table>
</center>
</div>
~;
}
if ($cart_error)
{
print qq~
<br><br>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td class="cart_error" width="100%">
$cart_error
</td>
</tr>
</table>
</center>
</div>
~;
&StoreFooter("regular");
exit;
}
}
##########################
# cart_footer
##########################
sub cart_footer
{
my ($hidden_fields) = &make_hidden_fields;
# MEMBERS ONLY MINIMUM ORDER CODE
# Customized by LEW
$minimum_amount{'Western_A
$minimum_order{'Western_Ac
$minimum_amount{'Gifts_Nov
$minimum_order{'Gifts_Nove
while ( my ($pass_key, $pass_value) = each(%minimum_amount) )
{
if ($minimum_order{$pass_key}
{
$min_cat_error = $pass_key;
$min_cat_amount = &display_price(&format_pri
}
}
if ($total_quantity eq "0")
{
$file_title = "$sc_template_directory_pa
} elsif ($min_cat_error) {
$minimum_order_amount = "$min_cat_amount $min_cat_error";
$file_title = "$sc_template_directory_pa
} else {
$file_title = "$sc_template_directory_pa
}
# END MINIMUM ORDER CODE
$gateway_links = qq~
</form>
<div align="center">
<center>
<table border="0" cellpadding="20" cellspacing="0">
<tr>
$gateway_checkout_buttons
</tr>
</table>
</center>
</div>
~;
open (CARTFOOTER, "$file_title") || &errorcode(__FILE__, __LINE__, "$sc_cart_path", "$!", "print", "FILE OPEN ERROR", "0");
while (<CARTFOOTER>)
{
s/\{scriptURL\}/$sc_store_
s/\{gateway_links\}/$gatew
s/\{hidden_fields\}/$hidde
s/\{URLofImages\}/$URL_of_
s/\{cart_id\}/$cart_id/g;
s/\{highlightcolor\}/$high
s/\{highlightfontcolor\}/$
s/\{minimum_order_amount\}
s/\{custom1\}/$custom1/g;
s/\{custom2\}/$custom2/g;
s/\{custom3\}/$custom3/g;
s/\{custom4\}/$custom4/g;
s/\{custom5\}/$custom5/g;
s/\{custom6\}/$custom6/g;
s/\{custom7\}/$custom7/g;
s/\{custom8\}/$custom8/g;
s/\{custom9\}/$custom9/g;
s/\{custom10\}/$custom10/g
s/\{custom11\}/$custom11/g
s/\{custom12\}/$custom12/g
s/\{custom13\}/$custom13/g
s/\{custom14\}/$custom14/g
s/\{custom15\}/$custom15/g
print $_;
}
close CARTFOOTER;
# Added for expandability
print "$sub_cart_footer_message"
&StoreFooter("regular");
}
##########################
# make_hidden_fields Subroutine #
##########################
sub make_hidden_fields
{
local($hidden, $field);
local($db_query_row);
local($db_form_field);
foreach $field (@sc_hidden_fields)
{
$field = (split(/\|/, $field))[0];
if ($form_data{$field} ne "")
{
$hidden .= qq~
<input type="hidden" name="$field" value="$form_data{$field}"
~;
}
}
foreach $db_query_row (@sc_db_query_criteria)
{
$db_form_field = (split(/\|/, $db_query_row))[0];
if ($form_data{$db_form_field
{
$hidden .= qq~
<input type="hidden" name="$db_form_field" value="$form_data{$db_form
~;
}
}
return ($hidden);
}
##########################
# make_hidden_string Subroutine #
##########################
sub make_hidden_string
{
local($no_next) = @_;
local($hidden, $field, $data);
local($db_query_row);
local($db_form_field);
foreach $field (@sc_hidden_fields)
{
# $field = (split(/\|/, $field))[0];
if ($form_data{$field} ne "")
{
unless (($no_next eq "no_next") && ($field eq "next"))
{
$hidden .= "\&$field=$form_data{$
}
}
}
foreach $db_query_row (@sc_db_query_criteria)
{
$db_form_field = (split(/\|/, $db_query_row))[0];
if ($form_data{$db_form_field
{
$data = $form_data{$db_form_field}
$data =~ s/ /+/g;
$hidden .= "\&$db_form_field=$dat
}
}
return ($hidden);
}
##########################
# PrintNoHitsBodyHTML
##########################
sub PrintNoHitsBodyHTML
{
&StoreHeader("No Products Found","regular");
print qq~
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="no_items_found" width="100%">
</td>
</tr>
</table>
~;
&StoreFooter("regular");
exit;
}
##########################
# Cart Contents
##########################
sub cart_content
{
local ($cart_contents);
my $count = "";
my $total_qty = "";
my $total_cost = "";
open (CARTFILE, "$sc_cart_path");
while (<CARTFILE>)
{
$count++;
@cart_fields = split (/\|/, $_);
$quantity = $cart_fields[$cart{"quanti
$product_id = $cart_fields[$cart{"produc
$price = $cart_fields[$cart{"price_
$total_cost = $total_cost + $quantity * $price;
$total_qty = $total_qty + $quantity;
}
close (CARTFILE);
if ($count > 0)
{
$total_cost = &display_price(&format_pri
} else {
$total_cost = &display_price(&format_pri
$total_qty = "0";
}
$cart_contents = qq~
Total Quantity: $total_qty &nbs
~;
return ($cart_contents);
}
##########################
# Categories
##########################
sub categories
{
local ($d_category, $v_category, $h_category, $dcat);
$d_category = qq~
<select name="SeeAlsoSelect" class="d_category" onChange=ViewCrossReferenc
<option> </option>
~;
open(CATFILE, "$sc_log_file_directory_pa
while (<CATFILE>)
{
chomp $_;
$_ =~ s/\r//g;
$dcat = $_;
my $key = (split(/\!/, $form_data{'product'}))[0]
if ($dcat =~ /\!/i && $form_data{'product'} && $dcat =~ /^$key/i)
{
$dcat =~ s/.*\!//g;
$indent_it = "yes";
} else {
$indent_it = "no";
}
$dcat =~ s/_/ /g;
if ($_ =~ /\!/i)
{
if ($indent_it eq "yes")
{
if ($ENV{'REQUEST_URI'} =~ /commerce.cgi/i || !($use_html))
{
$v_category .= " - <a href=\"$sc_store_url?produ
push (@h_category, " - <a href=\"$sc_store_url?produ
$d_category .= " - <option value=\"$sc_store_url?prod
} else {
$v_category .= " - <a href=\"$_\.htm\">$dcat</a>
push (@h_category, " - <a href=\"$_\.htm\">$dcat</a>
$d_category .= " - <option value=\"$_\.htm=$cart_id\"
}
}
} else {
if ($ENV{'REQUEST_URI'} =~ /commerce.cgi/i || !($use_html))
{
$v_category .= "<a href=\"$sc_store_url?produ
push (@h_category, "<a href=\"$sc_store_url?produ
$d_category .= "<option value=\"$sc_store_url?prod
} else {
$v_category .= "<a href=\"$_\.htm\">$dcat</a>
push (@h_category, "<a href=\"$_\.htm\">$dcat</a>
$d_category .= "<option value=\"$_\.htm=$cart_id\"
}
}
}
close (CATFILE);
$h_category = join(' | ', @h_category);
$d_category .= qq~
</SELECT>
~;
return ($d_category, $v_category, $h_category);
}
##########################
# mini_cart
##########################
sub mini_cart
{
my ($mini_cart, $mc_count, $mc_quantity, $mc_price, $mc_total_cost);
my ($mc_product, $mc_id);
open (CART, "$sc_cart_path");
while (<CART>)
{
$mc_count++;
@mc_cart_fields = split (/\|/, $_);
$mc_quantity = $mc_cart_fields[$cart{"qua
$mc_product = $mc_cart_fields[$cart{"pro
$mc_price = $mc_cart_fields[$cart{"pri
$mc_total_cost += $mc_quantity * $mc_price;
$mc_id = $mc_cart_fields[$cart{"pro
# If using buy now button where pid is 0 then just return to home page.
if ($mc_cart_fields[$cart{"pr
{
$mc_contents.= qq~
+ <a href="$sc_store_url?pid=$m
$mc_cart_fields[$cart{"nam
~;
} else {
$mc_contents.= qq~
+ $mc_cart_fields[$cart{"nam
~;
}
}
close (CART);
$cart_total = &display_price(&format_pri
if ($mc_count > 0)
{
$minicart = qq~
$mc_contents
<div> </div>
<div>Items in cart: $mc_count </div>
<div>Sub Total: $cart_total</div>
~;
} else {
$minicart = qq~
+ Your cart is empty<br><br>Items in cart: 0 <br>Sub Total: $cart_total
~;
}
return ($minicart);
}
##########################
# Create links to all the pages in the pages directory
##########################
sub pages
{
local ($pages, $pname, $ext);
opendir(PAGES,"$Path/pages
@pnames = readdir(PAGES);
for $pnames(@pnames)
{
($pname, $ext) = split (/\./, $pnames);
$pname =~ s/_/ /g;
if ($pname && $pname ne "Home" && $ext eq "htm")
{
if ($ENV{'REQUEST_URI'} =~ /commerce.cgi/i || !($use_html))
{
$pages .= "<a href=\"$sc_store_url?page=
$h_pages .= "| <a href=\"$sc_store_url?page=
} else {
$pages .= "<a href=\"$html_folder\/$pnam
$h_pages .= "| <a href=\"$html_folder\/$pnam
}
}
}
close (PAGES);
return ($pages, $h_pages);
}
##########################
# display_price
##########################
sub display_price
{
local ($price) = @_;
local ($format_price);
if ($sc_money_symbol_placemen
{
$format_price = "$sc_money_symbol $price";
} else {
$format_price = "$price $sc_money_symbol";
}
return $format_price;
}
1;