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.
Can someone assist in how I would make it to where the customer will either be charged on a shipping table OR choose express mail for $18. Here's what we had but it doesn't seem to be working correctly at the moment so there must be an error in the script. This did not include the $18 express mail option:
#########MINE ######### This custom script calculates shipping ######### based on total item cost. Items ######### over a subtotal of CURR 50.00 are free. ######### ######### Custom scripts may apply to a whole ######### order if all of the items ordered ######### use the same shipping method (Custom) ######### and the same script selection. Scripts ######### are built to handle a group of like ######### items. ######### ######### A listing of available variables: ######### ######### $item_quantity Total quantity of items ######### $item_subtotal Subtotal for all items ######### $item_total_weight Total weight of all items ######### ######### Directly below, enter in the name for this ######### method to be displayed to the user. ######### my $ship_meth_name = "Standard Shipping"; my $ship_total = "0.00"; my $ship_display = ""; ######### ######### Figure out what the shipping charge will be by ######### using if statements and less than/greater than ######### logic. ######### if ($item_subtotal >= "0" && $item_subtotal <= "20.00") { $ship_total = "5.95"; $ship_display = "$ship_meth_name - $currency_symbol$ship_total"; } elsif ($item_subtotal > "20.01" && $item_subtotal <= "40.00") { $ship_total = "6.95"; $ship_display = "$ship_meth_name - $currency_symbol$ship_total"; } elsif ($item_subtotal > "40.01" && $item_subtotal <= "60.00") { $ship_total = "7.95"; $ship_display = "$ship_meth_name - $currency_symbol$ship_total"; } elsif ($item_subtotal > "60.01" && $item_subtotal <= "80.00") { $ship_total = "8.95"; $ship_display = "$ship_meth_name - $currency_symbol$ship_total"; } elsif ($item_subtotal > "80.01" && $item_subtotal <= "100.00") { $ship_total = "10.95"; $ship_display = "$ship_meth_name - $currency_symbol$ship_total"; } elsif ($item_subtotal > "100.01" && $item_subtotal <= "200.00") { $ship_total = "12.95"; $ship_display = "$ship_meth_name - $currency_symbol$ship_total"; } elsif ($item_subtotal > "200.01" && $item_subtotal <= "300.00") { $ship_total = "14.95"; $ship_display = "$ship_meth_name - $currency_symbol$ship_total"; } elsif ($item_subtotal > "300.01" && $item_subtotal <= "99999999.00") { $ship_total = "15.95"; $ship_display = "$ship_meth_name - $currency_symbol$ship_total"; } else { $ship_total = "15.95"; $ship_display = "$ship_meth_name - $currency_symbol$ship_total"; ######### ######### Format the $ship_total as a price. ######### $ship_total = sprintf("%.2f", $ship_total); ######### ######### Return the HTML in the variable ######### $custom_code_result. ######### $custom_code_result = ""; $custom_code_result .= <<ENDOFTEXT; <INPUT TYPE="RADIO" NAME="shipinfo-$shipid" 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<BR></FONT> ENDOFTEXT
Offline
Along the lines of the "Give a man a fish....." proverb, I am giving you a fish - I did some basic testing and this should work for you (I did NOT check the Standard Shipping totals etc.)
I highlighted my additions to the script in blue so that you can follow what was done. The Express Mail method was added as was the code for the radio button in the custom code result.
Highlighted in red is an end bracket for your "If" statement that was missing in your version.
#########MINE
######### This custom script calculates shipping
######### based on total item cost. Items
######### over a subtotal of CURR 50.00 are free.
#########
######### Custom scripts may apply to a whole
######### order if all of the items ordered
######### use the same shipping method (Custom)
######### and the same script selection. Scripts
######### are built to handle a group of like
######### items.
#########
######### A listing of available variables:
#########
######### $item_quantity Total quantity of items
######### $item_subtotal Subtotal for all items
######### $item_total_weight Total weight of all items
#########
######### Directly below, enter in the name for this
######### method to be displayed to the user.
#########
my $ship_meth_name = "Standard Shipping";
my $ship_total = "0.00";
my $ship_display = "";
#########
######### Figure out what the shipping charge will be by
######### using if statements and less than/greater than
######### logic.
#########
if ($item_subtotal >= "0" && $item_subtotal <= "20.00") {
$ship_total = "5.95";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} elsif ($item_subtotal > "20.01" && $item_subtotal <= "40.00") {
$ship_total = "6.95";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} elsif ($item_subtotal > "40.01" && $item_subtotal <= "60.00") {
$ship_total = "7.95";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} elsif ($item_subtotal > "60.01" && $item_subtotal <= "80.00") {
$ship_total = "8.95";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} elsif ($item_subtotal > "80.01" && $item_subtotal <= "100.00") {
$ship_total = "10.95";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} elsif ($item_subtotal > "100.01" && $item_subtotal <= "200.00") {
$ship_total = "12.95";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} elsif ($item_subtotal > "200.01" && $item_subtotal <= "300.00") {
$ship_total = "14.95";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} elsif ($item_subtotal > "300.01" && $item_subtotal <= "99999999.00") {
$ship_total = "15.95";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} else {
$ship_total = "15.95";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
#########
######### Format the $ship_total as a price.
#########
$ship_total = sprintf("%.2f", $ship_total);
#########
######### Return the HTML in the variable
######### $custom_code_result.
#########
$custom_code_result = "";
$custom_code_result .= <<ENDOFTEXT;
<BR><BR>
<INPUT TYPE="RADIO" NAME="shipinfo-$shipid" 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<BR></FONT>
<BR><BR>
ENDOFTEXT
Offline
Thank you very much!
Offline
Just tested this and it works perfectly!!!!
I really appreciate your help. Thanks so much
Offline
Hi All,
I'm pretty new to this so test carefully for your own setup, but it works perfectly for me.
My scenario is that I offer standard and next day shipping, and if your order is over €50 then standard is free and next day is subsidised. I've changed the code to reflect this and also to change the description of the shipping method to make it clear to the customer that the shipping is free / subsidised because fo the order value.
Hope it helps.
#########
######### This custom script calculates shipping
######### based on user scripting. The default script
######### uses a flat rate shipping fee.
#########
######### Custom scripts may apply to a whole
######### order if all of the items ordered
######### use the same shipping method (Custom)
######### and the same script selection. Scripts
######### are built to handle a group of like
######### items.
#########
######### A listing of available variables:
#########
######### $item_quantity Total quantity of items
######### $item_subtotal Subtotal for all items
######### $item_total_weight Total weight of all items
#########
######### Directly below, enter in the name for this
######### method to be displayed to the user.
#########
my $ship_meth_name = "An Post - Registered Delivery";
my $ship_total = "0.00";
my $ship_display = "";
my $ship_meth_name1 = "Courier - Next Day Delivery";
my $ship_total1 = "0.00";
my $ship_display1 = "";
#########
######### Figure out what the shipping charge will be by
######### using if statements and less than/greater than
######### logic.
#########
if ($item_subtotal >= "0" && $item_subtotal <= "50.00") {
$ship_total = "7.50";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
$ship_total1 = "11.50";
$ship_display1 = "$ship_meth_name1 - $currency_symbol$ship_total1";
} elsif ($item_subtotal > "50.01" && $item_subtotal <= "99999999.00") {
$ship_total = "0.00";
$ship_meth_name = "An Post - Registered Delivery (Free for order over €50)";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
$ship_total1 = "4.50";
$ship_meth_name1 = "Courier - Next Day Delivery (Discounted by €7.00 for an order over €50)";
$ship_display1 = "$ship_meth_name1 - $currency_symbol$ship_total1";
} else {
$ship_total = "7.50";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
$ship_total1 = "11.50";
$ship_display1 = "$ship_meth_name1 - $currency_symbol$ship_total1";
}
#########
######### Return the HTML in the variable
######### $custom_code_result.
#########
$custom_code_result = "";
$custom_code_result .= <<ENDOFTEXT;
<INPUT TYPE="RADIO" NAME="shipinfo-$shipid" 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<BR></FONT>
<INPUT TYPE="RADIO" NAME="shipinfo-$shipid" VALUE="$ship_meth_name1:$ship_total1"> <FONT FACE="$html_base_font_face" SIZE="$html_base_font_size" COLOR="$html_base_font_color"> $ship_display1<BR></FONT>
ENDOFTEXT
Offline