Kryptronic Software Support Forum

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.

#1 06-27-2006 13:17:17

carasmo
Member
From: Florida
Registered: 10-07-2002
Posts: 147
Website

International Shipping

Hello,

So far there's a custom calculation based on the cost of the product. Right now the store only ships within the continental US.

Now they want to ship to the UK, Hawaii, Alaska, and Canada as well as the domestic US.

Is the following possible?

Depending on the shipping state field, appropriate shipping options show up. If the customer is in the a UK state, then the shipping calculation for that shows up, if in the domestic US then that price shows up, if in HI and so forth. Those costs are calculated differently for each situation. Domestic shipping is based on the total cost, but the calculation for shipping to canada, the uk, and other states within different countries would be calculated on a base price plus the cost to ship each item. I suspect it would be a very long script since it's looking at the state field and there's so many more if then situations. What do I need to execute this?

In summary it's like this (I don't know how to write this in perl):

If (shipping state is US continental) then the cost is based on a calculation of total cost.

If (shipping country field is Canada) then the cost is based on a calculation of base and cost per item.

If (shipping country field is in the UK) then the cost is based on a calculation of base and cost per item.

If (Hawaii or Alaska) then the cost is based on a calculation of base and cost per item.

When I say base and cost per item, I mean that the first items is $X and each additional item is $X.

Then based on the state or the country, the appropriate shipping is calculated and only that shows up in the shipping information upon check out.


Any suggestions are deeply appreciated.


Thank You!!!

Offline

 

#2 06-28-2006 00:48:38

dh783
Member
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: International Shipping

You said that you have a custom script working now for the US, what code are you useing now?

If you can work out, lets say a script for Canada, the rest of them would basicly be changing the name of the country that you want to check for and maybe the shipping amount variable.

You said that you don't know how to wight perl code, does this mean none at all or very little. If you don't have any programing skill at all you would be better off contacting someone who can do that for you. You can learn how to do it youself but if you on a tight sechule to get this working it might not be your first option.

There where some post of custom shipping methods on this forum or Cool Mods and Hacks which could give you more clues of how to get your idea to work. One of the best ways I know of how to learn to wright scripts is to find a code close to what your looking for and start playing with it, like commenting out parts with the pound sign (# $var_...) to see what happens or changing varaibles to sute you needs. It aslo wouldn't hert to have a perl programing book to use for the syntex for comands or check the documation at wwwperl.com.

This script has the potential of being verry large, knowing that in the US alone there are some 50 plus states and territoies, breaking the area up into larger blocks of territory would make it easer but still a large under taking.

For someone to help on this forum they would need more information on base amount, product amounts for example. But in it's simplest form it could look something like this:

######### Shipping statement #########

if ($tracking_country eq "Canada") {

$shipping_cost .= (($trackitem_quanity * product_base_amount) + shipping_base_amount);

$shipping_total = sprintf("%.2f",$shipping_cost);

} else {

if ($tracking_country eq "next_country") {

$shipping_cost .= (($trackitem_quanity * product_base_amount) + shipping_base_amount);

$shipping_total = sprintf("%.2f",$shipping_cost);

} ##### End of shipping statement.

This example is not taking into account that you may have to make a calls to the tracking and trackitem databases or getting them to show up in cart, since I have not done any custome shipping methods yet. But placeing them in the custom shipping fields in the system, I think, should take care of that part.

John

Offline

 

#3 06-28-2006 13:27:39

carasmo
Member
From: Florida
Registered: 10-07-2002
Posts: 147
Website

Re: International Shipping

Right now I've got this script for domestic shipping, which is calculated based on the subtotal.

Code:

#########

my $ship_meth_name = "UPS Ground";
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 <= "100.00") {

$ship_total = "7.00";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";

} elsif ($item_subtotal > "101.00" && $item_subtotal <= "200.00") {

$ship_total = "11.00";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";

} elsif ($item_subtotal > "201.00" && $item_subtotal <= "300.00") {

$ship_total = "15.00";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";

} elsif ($item_subtotal > "301.00" && $item_subtotal <= "400.00") {

$ship_total = "19.00";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";

} elsif ($item_subtotal > "401.00") {

$ship_total = "23.00";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";

} else {

$ship_total = "0.00";
$ship_display = "$ship_meth_name - FREE";

} ######### End of if statement.

#########
######### 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><span class="maintext"> $ship_display<BR></span>

ENDOFTEXT

While it wouldn't be automatic based on the customer's country or state field, if there were options that user could click then that would work. This is some old script that Nick created in 2002 or 03, it was based on cost per item. So what I need is a combo of both the shipping cost per item and shipping based on subtotal.

Code:

######### 
######### Edit shipping names and methods below.
#########

$shipname1 = "Domestic/Continental US";
$shipamt1  = "3.00";
$shipadd1  = ".75";

******NOTE: Instead of having a cost per item, the shipping for Domestic Contental US is based on the subtotal. The other methods are based on the cost plus additional here.

$shipname2 = "Canada, Hawaii, Alaska";
$shipamt2  = "3.85";
$shipadd2  = "1.25";

$shipname3 = "United Kingdom";
$shipamt3  = "4.85";
$shipadd3  = "1.50";

#########
######### Shipping logic - Method 1 (this would change to the amounts based on the subtotals in the previous code that I'm using now).
#########

$items1 = "$cart_quantity_found";
$shipcost1 = "0.00";

if ($items1 > "0") {

$items1 = ($items1 - 1);
$shipcost1 = "$shipamt1";

} ######### End of if statement.

while ($items1 > "0") {

$items1 = ($items1 - 1);
$shipcost1 = ($shipcost1 + $shipadd1);

} ######### End of while statement.

$shipcost1 = sprintf("%.2f", $shipcost1);

$shipdisp1 = "$shipname1 - $currency_symbol$shipcost1";

#########
######### Shipping logic - Method 2
#########

$items2 = "$cart_quantity_found";
$shipcost2 = "0.00";

if ($items2 > "0") {

$items2 = ($items2 - 1);
$shipcost2 = "$shipamt2";

} ######### End of if statement.

while ($items2 > "0") {

$items2 = ($items2 - 1);
$shipcost2 = ($shipcost2 + $shipadd2);

} ######### End of while statement.

$shipcost2 = sprintf("%.2f", $shipcost2);

$shipdisp2 = "$shipname2 - $currency_symbol$shipcost2";

#########
######### Shipping logic - Method 3
#########

$items3 = "$cart_quantity_found";
$shipcost3 = "0.00";

if ($items3 > "0") {

$items3 = ($items3 - 1);
$shipcost3 = "$shipamt3";

} ######### End of if statement.

while ($items3 > "0") {

$items3 = ($items3 - 1);
$shipcost3 = ($shipcost3 + $shipadd3);

} ######### End of while statement.

$shipcost3 = sprintf("%.2f", $shipcost3);

$shipdisp3 = "$shipname3 - $currency_symbol$shipcost3";

} ######### End of if statement.

#########
######### Shipping display.
#########

print <<ENDOFTEXT;

<CENTER>

<TABLE WIDTH="100\%" CELLPADDING="5" CELLSPACING="2">

<TR BGCOLOR="$html_pri_tablerow_color"><TD VALIGN="TOP"><SPAN CLASS="small"><B>Shipping Method</b> <SPAN CLASS="fontnull"><B>$html_notnull_character</b></span><BR><BR></span>

<INPUT TYPE="RADIO" NAME="shipinfo" VALUE="$shipname1\:$shipcost1" CHECKED> <SPAN CLASS="maintext">$shipdisp1<BR></span>

<INPUT TYPE="RADIO" NAME="shipinfo" VALUE="$shipname2\:$shipcost2"> <SPAN CLASS="maintext">$shipdisp2<BR></span>

<INPUT TYPE="RADIO" NAME="shipinfo" VALUE="$shipname3\:$shipcost3"> <SPAN CLASS="maintext">$shipdisp3<BR></span>
</td></tr>

</table>

</center>

<BR>

ENDOFTEXT

What's the cost to make this?

Offline

 

#4 06-30-2006 16:34:31

carasmo
Member
From: Florida
Registered: 10-07-2002
Posts: 147
Website

Re: International Shipping

bump

Offline

 

#5 06-30-2006 16:55:41

dtwg
Member
From: California
Registered: 11-15-2004
Posts: 1339
Website

Re: International Shipping

There are tons of custom shipping script examples here on the forum. You can try searching on "custom and shipping and script and country" or such. It will take some effort, but there are some good examples out there.

This wouldn't be a particularly difficult script to write. Any of the  could do it for you for a reasonable fee. The user forum is not a good place to request a quote, though, so you should probably try to contact them directly or submit a .

HTH,

dtwg

Offline

 

#6 06-30-2006 18:03:30

dh783
Member
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: International Shipping

Give this a try, you will have to change the shipping amounts to sute your needs:

Code:

######### 
######### Edit shipping names and methods below.
#########
$shipname1 = "Hawaii";
$shipamt1  = "3.00";
$shipadd1  = ".75";
$shipname2 = "Alaska";
$shipamt2  = "3.00";
$shipadd2  = ".75";
$shipname3 = "Canada";
$shipamt3  = "3.85";
$shipadd3  = "1.25";
$shipname4 = "United Kingdom";
$shipamt4  = "4.85";
$shipadd4  = "1.50";
#########
#########


if ($fd_tracking_country eq "United States" && $fd_tracking_stateprov ne "Hawaii" && $fd_tracking_stateprov ne "Alaska") {

#########
my $ship_meth_name = "UPS Ground";
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 <= "100.00") {
$ship_total = "7.00";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} elsif ($item_subtotal > "101.00" && $item_subtotal <= "200.00") {
$ship_total = "11.00";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} elsif ($item_subtotal > "201.00" && $item_subtotal <= "300.00") {
$ship_total = "15.00";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} elsif ($item_subtotal > "301.00" && $item_subtotal <= "400.00") {
$ship_total = "19.00";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} elsif ($item_subtotal > "401.00") {
$ship_total = "23.00";
$ship_display = "$ship_meth_name - $currency_symbol$ship_total";
} else {
$ship_total = "0.00";
$ship_display = "$ship_meth_name - FREE";
} ######### End of if statement.
#########
######### 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><span class="maintext"> $ship_display<BR></span>
ENDOFTEXT

} #### End of it statement.

elsif ($fd_tracking_country eq "United States" && ($fd_tracking_stateprov eq "Hawaii")) {

$items1 = "$cart_quantity_found";
$shipcost1 = "$0.00";
if ($items1 > "0") {
$items1 = ($items1 - 1);
$shipcost1 = "$shipamt1";
} ######### End of if statement.
while ($items1 > "0") {
$items1 = ($items1 - 1);
$shipcost1 = ($shipcost1 + $shipadd1);
} ######### End of while statement.
$shipcost1 = sprintf("%.2f", $shipcost1);
$shipdisp1 = "$shipname1 - $currency_symbol$shipcost1";

$custom_code_result = "";
$custom_code_result .= <<ENDOFTEXT;
<INPUT TYPE="RADIO" NAME="shipinfo-$shipid" VALUE="$shipname1\:$shipcost1" CHECKED><span class="maintext">$shipdisp1<BR></span>
ENDOFTEXT

} #### end of if statement.

elsif ($fd_tracking_country eq "United States" && ($fd_tracking_stateprov eq "Alaska")) {

#########
######### Shipping logic - Method 2
#########
$items2 = "$cart_quantity_found";
$shipcost2 = "0.00";
if ($items2 > "0") {
$items2 = ($items2 - 1);
$shipcost2 = "$shipamt2";
} ######### End of if statement.
while ($items2 > "0") {
$items2 = ($items2 - 1);
$shipcost2 = ($shipcost2 + $shipadd2);
} ######### End of while statement.
$shipcost2 = sprintf("%.2f", $shipcost2);
$shipdisp2 = "$shipname2 - $currency_symbol$shipcost2";

$custom_code_result = "";
$custom_code_result .= <<ENDOFTEXT;
<INPUT TYPE="RADIO" NAME="shipinfo-$shipid" VALUE="$shipname2\:$shipcost2" CHECKED><span class="maintext">$shipdisp2<BR></span>
ENDOFTEXT


} ######## end of if statemnt.

elsif ($fd_tracking_country eq "Canada") {

#########
######### Shipping logic - Method 3
#########
$items3 = "$cart_quantity_found";
$shipcost3 = "0.00";
if ($items3 > "0") {
$items3 = ($items3 - 1);
$shipcost3 = "$shipamt3";
} ######### End of if statement.
while ($items3 > "0") {
$items3 = ($items3 - 1);
$shipcost3 = ($shipcost3 + $shipadd3);
} ######### End of while statement.
$shipcost3 = sprintf("%.2f", $shipcost3);
$shipdisp3 = "$shipname3 - $currency_symbol$shipcost3";

$custom_code_result = "";
$custom_code_result .= <<ENDOFTEXT;
<INPUT TYPE="RADIO" NAME="shipinfo-$shipid" VALUE="$shipname3\:$shipcost3" CHECKED><span class="maintext">$shipdisp3<BR></span>
ENDOFTEXT

} ###### End of if statemnt.

elsif ($fd_tracking_country eq "United Kingdom") {

$items4 = "$cart_quantity_found";
$shipcost4 = "$shipampt4";
if ($items4 > "0") {
$items4 = ($items4 - 1);
$shipcost4 = "$shipamt4";
} ######### End of if statement.
while ($items4 > "0") {
$items4 = ($items4 - 1);
$shipcost4 = ($shipcost4 + $shipadd4);
} ######### End of while statement.
$shipcost4 = sprintf("%.2f", $shipcost4);
$shipdisp4 = "$shipname4 - $currency_symbol$shipcost4";

$custom_code_result = "";
$custom_code_result .= <<ENDOFTEXT;
<INPUT TYPE="RADIO" NAME="shipinfo-$shipid" VALUE="$shipname4\:$shipcost4" CHECKED><span class="maintext">$shipdisp4<BR></span>
ENDOFTEXT

} #### end of if statemnt.

######## I have edited the original post to correct the shipcost4 total. ########

John

Offline

 

#7 06-30-2006 19:47:10

carasmo
Member
From: Florida
Registered: 10-07-2002
Posts: 147
Website

Re: International Shipping

Man oh Man! You rock!

I will test it out this weekend. Gotta add back some countries and states in table.

Gigantic Thanks!!!

Offline

 

#8 07-03-2006 06:28:01

dh783
Member
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: International Shipping

I was just rechecking the code I gave you and noticed that I didn't change something so at

Code:

$shipcost4 = ($shipcost4 + $shipadd2);

change it to

Code:

$shipcost4 = ($shipcost4 + $shipadd4);

that will add the right amout to the UK shipping total.

John

Offline

 

Board footer