You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
I have a client who sells books online and his shipping method is to charge $3 for the first book and $1 for each additional book.
Is there a way to do this easily using the custom shipping option? My knowlege of Perl is pretty limited.
Thanks,
Bob S.
In ste_shipcus_quan, replace all the code with this:
#########
######### This script bases price on the quantity of
######### items in the cart. There is a charge per item.
#########
######### A listing of available variables:
#########
######### $ship_items_found Count Of shippable items
#########
######### $ship_methods_found Count of items with a
######### shipping method already
#########
######### $cart_items_found Count of rows in the cart
#########
######### $cart_quantity_found Total quantity of items
######### in the cart
#########
######### $tracking_subtotal Subtotal of the prices for
######### all items in the cart
#########
######### $cart_total_weight Total weight of all items
######### in the cart in pounds.
#########
######### Directly below, enter in the name for this
######### method to be displayed to the user.
#########
my $ship_meth_name = "Standard Carrier";
my $price_per_item = "1.00";
my $ship_total = "0.00";
my $ship_total1 = "0.00";
my $ship_display = "";
my $ship_quantity = "0";
#########
######### Figure out what the shipping charge will be by
######### multiplying the weight by the price per item.
#########
if ($cart_quantity_found = "1") {
$ship_total = "3.00";
} else {
$ship_quantity = (cart_quantity_found - 1);
$ship_total1 = ($ship_quantity * $price_per_item)
$ship_total = (ship_total1 + "3.00");
} ######### end of if statement
#########
######### Format the $ship_total as a price.
#########
$ship_total = sprintf("%.2f", $ship_total);
#########
######### Create the display based on the price.
#########
if ($ship_total > "0") {
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} else {
$ship_display = "$ship_meth_name - FREE";
} ######### End of if statement.
#########
######### Print the HTML display for the shipping
######### charge.
#########
print <<ENDOFTEXT;
<CENTER>
<TABLE WIDTH="100%" CELLPADDING="10" CELLSPACING="3">
<TR BGCOLOR="$html_pri_tablerow_color">
<TD VALIGN="TOP"><FONT FACE="$html_small_font_face" SIZE="$html_small_font_size" COLOR="$html_small_font_color"><B>Shipping Method</B> <FONT COLOR="$html_notnull_font_color"><B>$html_notnull_character</B></FONT><BR><BR></FONT>
<INPUT TYPE="RADIO" NAME="shipinfo" VALUE="$ship_meth_name:$ship_total" CHECKED> <FONT FACE="$html_base_font_face" SIZE="$html_base_font_size" COLOR="$html_base_font_color">
$ship_display
</FONT></TD>
</TR>
</TABLE>
</CENTER>
<BR>
ENDOFTEXT
I am sure that others can/will trim this code down, but I am doing this on the fly.
Offline
I'm not sure why...but I can't get to work.
On the Manage Shipping page, I enabled Custom Method and Calculation on Total Order Quantity. What other settings do I need to make this work?
The line:
$ship_quantity = (cart_quantity_found - 1);
Should be:
$ship_quantity = ($cart_quantity_found - 1);
___________________________
Nick Hendler
Webmaster, Kryptronic, Inc.
Offline
replace $cart_quantity_found = "1" with $cart_quantity_found eq "1"
Offline