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 05-25-2007 21:21:23

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

Destination and total price script, HELP

Hello,

I've got this script which I grabbed from another post. We are shipping to the USA but if the country is another, we want to call/contact the customer. This is what I have and it's not working.

Code:

my $ship_meth_name = "";
my $ship_total = "";
my $ship_display = "";
my $country = "";
my $region = "";
my @us_countries = ("United States");

foreach $country (@us_countries) {
     if ($country eq $fd_trackitem_shipcountry) {
  $region = "us";
  last;
     } else {
  $region = "rw";
     }
}

if ($region eq "us") {

     $ship_meth_name = "UPS Ground";
     $ship_display = "UPS Ground";

     if ($item_subtotal >= "0" && $item_subtotal <= "50.00") {
  $ship_total = "7.00";
       } elsif ($item_subtotal > "51.00" && $item_subtotal <= "100.00") {
  $ship_total = "10.00";

     } elsif ($item_subtotal > "101.00" && $item_subtotal <= "150.00") {
  $ship_total = "12.00";
       } elsif ($item_subtotal > "151.00" && $item_subtotal <= "200.00") {
  $ship_total = "14.00";
         } elsif ($item_subtotal > "201.00" && $item_subtotal <= "400.00") {
  $ship_total = "17.00";
         } elsif ($item_subtotal > "401.00" {
  $ship_total = "20.00";
  
     } else {
  $ship_total = "0.00";
  $ship_meth_name .= " - FREE";
     }

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

} else {

     $ship_meth_name = "We will notify you with shipping charges";
     $ship_total = "0.00";

     $ship_display = "$ship_meth_name";

}

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

$custom_code_result = "";

$custom_code_result .= <<ENDOFTEXT;

<INPUT TYPE="RADIO" NAME="shipinfo-$shipid" VALUE="$ship_meth_name:$ship_total" CHECKED> $ship_display<br/>
<br/><p>Please note: If your shipment is to any country or state outside the  contiguous  US, we will notify you via phone or email of the actual shipping charges for air delivery.</p>

ENDOFTEXT

Offline

 

#2 05-25-2007 22:33:59

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Destination and total price script, HELP

You have a syntax error on line 33 - missing a right parenthesis.  Try this instead:

Code:

my $ship_meth_name = "";
my $ship_total = "";
my $ship_display = "";
my $country = "";
my $region = "";
my @us_countries = ("United States");

foreach $country (@us_countries) {
     if ($country eq $fd_trackitem_shipcountry) {
  $region = "us";
  last;
     } else {
  $region = "rw";
     }
}

if ($region eq "us") {

     $ship_meth_name = "UPS Ground";
     $ship_display = "UPS Ground";

     if ($item_subtotal >= "0" && $item_subtotal <= "50.00") {
  $ship_total = "7.00";
       } elsif ($item_subtotal > "51.00" && $item_subtotal <= "100.00") {
  $ship_total = "10.00";

     } elsif ($item_subtotal > "101.00" && $item_subtotal <= "150.00") {
  $ship_total = "12.00";
       } elsif ($item_subtotal > "151.00" && $item_subtotal <= "200.00") {
  $ship_total = "14.00";
         } elsif ($item_subtotal > "201.00" && $item_subtotal <= "400.00") {
  $ship_total = "17.00";
         } elsif ($item_subtotal > "401.00") {
  $ship_total = "20.00";
  
     } else {
  $ship_total = "0.00";
  $ship_meth_name .= " - FREE";
     }

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

} else {

     $ship_meth_name = "We will notify you with shipping charges";
     $ship_total = "0.00";

     $ship_display = "$ship_meth_name";

}

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

$custom_code_result = "";

$custom_code_result .= <<ENDOFTEXT;

<INPUT TYPE="RADIO" NAME="shipinfo-$shipid" VALUE="$ship_meth_name:$ship_total" CHECKED> $ship_display<br/>
<br/><p>Please note: If your shipment is to any country or state outside the  contiguous  US, we will notify you via phone or email of the actual shipping charges for air delivery.</p>

ENDOFTEXT

I didn't change anything else or test it (beyond a syntax check), just fixed the syntax error.

P.S. - Free PERL syntax checker that seems to work well at http://www.ult-tex.net/tools/ultra/line_count.pl

Last edited by rachaelseven (05-25-2007 22:35:10)


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#3 05-25-2007 23:09:46

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

Re: Destination and total price script, HELP

You are a life saver!!! Thank you!

Offline

 

Board footer