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 09-26-2003 17:44:19

karleil
Member
From: Pennsylvania
Registered: 09-19-2003
Posts: 39
Website

How Do I Add Usps Insurance To Order?

I hope I'm not being too dense, but I cannot figure out how to calculate USPS insurance for an order total. I'm using the USPS Webtools API and it works fine, but I cannot find a way to calculate and add the insurance to the shipping total. In fact, I can't even find a place in CCP51 for shipping insurance. Any suggestions?

Offline

 

#2 09-26-2003 23:35:16

EagleWolf
Member
From: Daytona Beach, FL
Registered: 07-27-2003
Posts: 979

Re: How Do I Add Usps Insurance To Order?

Karl,

I got this mod from Nick.

This mod is to calculate a shipping insurance price to charge the customer based on 5% of the purchase price. I am not sure if this will work for you or not.



Code:

###

if ($checked eq "N") {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

$checked = "Y";

} else {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\"> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

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

###

Add in:

###

$service_name .= "$service_name (Insured)";
$insurance = ($tracking_subtotal * .05);
$service_rate = ($service_rate + $insurance);
$service_rate = sprintf("%.2f", $service_rate);

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\"> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

###

Chris
<a href='mailto:webmaster@equivity.com'>webmaster@equivity.com</a>
-

Offline

 

#3 09-28-2003 09:41:16

karleil
Member
From: Pennsylvania
Registered: 09-19-2003
Posts: 39
Website

Re: How Do I Add Usps Insurance To Order?

I modified the code a bit more to calculate the actual USPS domestic insurance charges.

Replace the code below (from the 'ste_chkout_meth_realtime_proc' routine
in ste_chkout.pl) :

Code:

if ($checked eq "N") {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

$checked = "Y";

} else {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\"> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

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



Code:

if ($checked eq "N") {

## USPS 1st Class & Priority Mail insurance costs
if ($tracking_subtotal < 50.01) {
$insurance = 1.30;
} elsif ($tracking_subtotal < 100.01) {
$insurance = 2.20;
} elsif ($tracking_subtotal > int($tracking_subtotal/100) * 100) {
$insurance = int($tracking_subtotal/100) + 2.20;
} elsif ($sub_price = int($tracking_subtotal/100) * 100) {
$insurance = int($tracking_subtotal/100) + 1.20;
};

$service_name .= "$service_name (Insured)";
$service_rate = ($service_rate + $insurance);
$service_rate = sprintf("%.2f", $service_rate);

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

$checked = "Y";

} else {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\"> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

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

This only works for USPS domestic mail (First Class and Priority)

Offline

 

#4 09-28-2003 10:03:57

karleil
Member
From: Pennsylvania
Registered: 09-19-2003
Posts: 39
Website

Re: How Do I Add Usps Insurance To Order?

Oops, I just discovered that for multiple shipping options, you need to set the variables:

Code:

## USPS 1st Class & Priority Mail insurance costs
if ($tracking_subtotal < 50.01) {
$insurance = 1.30;
} elsif ($tracking_subtotal < 100.01) {
$insurance = 2.20;
} elsif ($tracking_subtotal > int($tracking_subtotal/100) * 100) {
$insurance = int($tracking_subtotal/100) + 2.20;
} elsif ($sub_price = int($tracking_subtotal/100) * 100) {
$insurance = int($tracking_subtotal/100) + 1.20;
};

$service_name .= "$service_name (Insured)";
$service_rate = ($service_rate + $insurance);
$service_rate = sprintf("%.2f", $service_rate);

before the if statement:

Code:

if ($checked eq "N") {

NOW it works fine.

Offline

 

#5 09-28-2003 11:18:57

karleil
Member
From: Pennsylvania
Registered: 09-19-2003
Posts: 39
Website

Re: How Do I Add Usps Insurance To Order?

One more bit of debugging. It turns out the line

Code:

$service_name .= "$service_name (Insured)";

does not print "(Insured)" after the shipping method. Replace it with this line:

Code:

$service_name_display .= " (Insured)";

Now you will see a shipping option that looks like this:



I think that should do it.

Offline

 

#6 11-12-2003 17:28:33

VGF
Member
Registered: 11-12-2003
Posts: 64
Website

Re: How Do I Add Usps Insurance To Order?

I've used the mod that Karleil posted above. After I made the changes and uploaded the new code I checked my store.

On the checkout pages instead of the nice, clean form to enter your billing and shipping info,  I have my code showing.

See  here:



Here's the code I used:


Code:

## USPS 1st Class & Priority Mail insurance costs
if ($tracking_subtotal < 50.01) {
$insurance = 1.30;
} elsif ($tracking_subtotal < 100.01) {
$insurance = 2.20;
} elsif ($tracking_subtotal > int($tracking_subtotal/100) * 100) {
$insurance = int($tracking_subtotal/100) + 2.20;
} elsif ($sub_price = int($tracking_subtotal/100) * 100) {
$insurance = int($tracking_subtotal/100) + 1.20;
};

$service_name_display .= " (Insured)";
$service_rate = ($service_rate + $insurance);
$service_rate = sprintf("%.2f", $service_rate);

if ($checked eq "N") {

## USPS 1st Class & Priority Mail insurance costs
if ($tracking_subtotal < 50.01) {
$insurance = 1.30;
} elsif ($tracking_subtotal < 100.01) {
$insurance = 2.20;
} elsif ($tracking_subtotal > int($tracking_subtotal/100) * 100) {
$insurance = int($tracking_subtotal/100) + 2.20;
} elsif ($sub_price = int($tracking_subtotal/100) * 100) {
$insurance = int($tracking_subtotal/100) + 1.20;
};

$service_name_display .= " (Insured)";
$service_rate = ($service_rate + $insurance);
$service_rate = sprintf("%.2f", $service_rate);

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

$checked = "Y";

} else {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\"> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

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

I've been over this and it's been driving me nuts trying to sort it out.

I uploaded it in ascii format.

What did I do wrong?

Thanks in advance for your help!

 


Earl


Got the Game, Get the Toy!

Offline

 

#7 11-13-2003 01:28:00

elle01
Member
Registered: 09-11-2003
Posts: 21

Re: How Do I Add Usps Insurance To Order?

it's not the code, it's the html.

Code:

TD VALIGN="TOP"><FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE="1" COLOR="000000"><B>First Name <FONT COLOR="FF0000">*</FONT></B></FONT><BR><BR>

should be:

Code:

<TD VALIGN="TOP"><FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE="1" COLOR="000000"><B>First Name <FONT COLOR="FF0000">*</FONT></B></FONT><BR><BR>

Offline

 

#8 01-24-2004 02:46:21

AcousticTX
Member
Registered: 01-07-2004
Posts: 35

Re: How Do I Add Usps Insurance To Order?

Anyone know how to make this work with only USPS?

Im using the mod that allows the customer to pick either UPS or USPS and this insurance mod works great, but it calculates in on both carriers.

Thanks


Thanks!
-Jake

Offline

 

#9 01-27-2004 14:07:36

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: How Do I Add Usps Insurance To Order?

Reply to your other thread about this.  I just posted a question there.


Nick Hendler

Offline

 

#10 01-27-2004 15:13:33

karleil
Member
From: Pennsylvania
Registered: 09-19-2003
Posts: 39
Website

Re: How Do I Add Usps Insurance To Order?

Try this for USPS-only insurance. I don't have my store configured for UPS, so I can't test compatibility with UPS realtime. But it should add the insurance only to USPS and skip it for UPS.

Code:

# USPS insurance costs
my $ship_ident = ();
$ship_ident = substr($service_name, 1, 4);

if ($ship_ident = "USPS") {
if ($tracking_subtotal < 50.01) {
$insurance = 1.30;
} elsif ($tracking_subtotal < 100.01) {
$insurance = 2.20;
} elsif ($tracking_subtotal > int($tracking_subtotal/100) * 100) {
$insurance = int($tracking_subtotal/100) + 2.20;
} elsif ($sub_price = int($tracking_subtotal/100) * 100) {
$insurance = int($tracking_subtotal/100) + 1.20;
};

$service_name_display .= " (Insured)";
$service_rate = ($service_rate + $insurance);
$service_rate = sprintf("%.2f", $service_rate);

};

Offline

 

#11 01-28-2004 04:00:21

modiphier
Member
From: Cranston, Rhode Island
Registered: 12-13-2003
Posts: 87
Website

Re: How Do I Add Usps Insurance To Order?

Hi,

I added the following

Code:

## ADD UPS Insurance
$service_name_display .= " (Insured)";
$insurance = ($tracking_subtotal * .05);
$service_rate = ($service_rate + $insurance);
$service_rate = sprintf("%.2f", $service_rate);
## END HACK

Right below

if ($checked eq "N") {

as explained above.

My question is when I test this it is displaying ups ground (insured) but the 2nd and 3rd day ups selections do not offer the insured feature nor is the user able to select ups ground without the insurance.

Anyway of tweaking this to give the user the option to select a radio button with the additional insuance displayed??


R U NUKED?

Offline

 

#12 01-28-2004 08:50:10

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: How Do I Add Usps Insurance To Order?

Let me just do that hack again.  It's all too hard to read.  In ./cgi-bin/library/modules/ste_chkout.pl in the routine 'ste_chkout_meth_realtime_proc' you'll see:

Code:


if ($checked eq "N") {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

$checked = "Y";

} else {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\"> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

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

Immediately below that, you will want to add:

Code:


if ($shiptype eq "USPS") {

$service_name .= "$service_name (Insured)";
$insurance = ($tracking_subtotal * .05);
$service_rate = ($service_rate + $insurance);
$service_rate = sprintf("%.2f", $service_rate);

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

$checked = "Y";

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

That does 5% on USPS only - adjust the calculation to do more/less.


Nick Hendler

Offline

 

#13 01-28-2004 12:22:38

karleil
Member
From: Pennsylvania
Registered: 09-19-2003
Posts: 39
Website

Re: How Do I Add Usps Insurance To Order?

Nick, a straight percentage does not work for accurate USPS domestic insurance. USPS uses a set of increments:

-- up to $50 = $1.30

-- $50.01 to $100 = $2.20

-- Over $100 = $2.20 for the first $100, plus $1.00 for each break over $x00.00 (i.e., $3.20 insurance for $100.01 to $200, $4.20 insur for $200.01 to $300, etc.)

Offline

 

#14 01-28-2004 21:23:16

modiphier
Member
From: Cranston, Rhode Island
Registered: 12-13-2003
Posts: 87
Website

Re: How Do I Add Usps Insurance To Order?

Hi guys,

So I use UPS only.. So I can not use this mode at all?? Is that right?


R U NUKED?

Offline

 

#15 01-29-2004 09:32:51

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: How Do I Add Usps Insurance To Order?

The insurance charges would need to be modified to use UPS I suppose.  The key is to change the line:

Code:


if ($shiptype eq "USPS") {

To read:

Code:


if ($shiptype =~ /^UPS/) {

To use UPS.  As far as variable insurance charges, the code is here in this post for figuring them out.  Just replace:

Code:


$insurance = ($tracking_subtotal * .05);

With whatever logic you need to calculate the insurance.


Nick Hendler

Offline

 

#16 01-30-2004 01:11:19

modiphier
Member
From: Cranston, Rhode Island
Registered: 12-13-2003
Posts: 87
Website

Re: How Do I Add Usps Insurance To Order?

Hi Nick,

It is actually this

Code:

if ($shiptype =~ /^UPS/) {

$service_name_display .= " (Insured)";     
$insurance = ($tracking_subtotal * .05);
$service_rate = ($service_rate + $insurance);
$service_rate = sprintf("%.2f", $service_rate);

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

$checked = "Y";

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

Note the correction to the Insured string. Now the only problem I see is it doesn't send any type of  notice in the order email.

It did list both ups ground and ups 2nd day with the insured rate just below but no sign of it in the order or throughout the rest of the checkout process.


R U NUKED?

Offline

 

#17 01-30-2004 23:36:35

modiphier
Member
From: Cranston, Rhode Island
Registered: 12-13-2003
Posts: 87
Website

Re: How Do I Add Usps Insurance To Order?

this works fine now..


if ($shiptype =~ /^UPS/) {

$service_name_display .= " (Insured)";
$insurance = ($tracking_subtotal * .05);
$service_rate = ($service_rate + $insurance);
$service_rate = sprintf("%.2f", $service_rate);

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name_display\:$service_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

$checked = "Y";

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


R U NUKED?

Offline

 

#18 03-02-2004 19:36:54

edgar
Member
Registered: 02-17-2004
Posts: 17

Re: How Do I Add Usps Insurance To Order?

Could I use the mod for UPS insurance for FedEx insurance? Just substitute FedEx for UPS?

Offline

 

#19 03-03-2004 12:03:05

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: How Do I Add Usps Insurance To Order?

It should work for all, just change the text in the hack to use 'USPS' or 'FEDEX'.


Nick Hendler

Offline

 

#20 03-03-2004 18:05:33

edgar
Member
Registered: 02-17-2004
Posts: 17

Re: How Do I Add Usps Insurance To Order?

I add the USPS/UPS hack for FEDEX. It does work, however, when the shipping comes up half of the Radio buttons are checked. Also, this mod displays both shipping with and without insurance. There should only be shipping with insurance and the choices are ground, standard, etc. Any suggestions of what to do with the mod.

Thanks,
Edgar

Offline

 

#21 03-04-2004 09:19:20

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: How Do I Add Usps Insurance To Order?

This code was modified a lot in this post.  Make sure your implementation checks the '$checked' variable to make sure whether ' CHECKED' is printed or not in the radio buttons.


Nick Hendler

Offline

 

#22 03-04-2004 16:13:47

edgar
Member
Registered: 02-17-2004
Posts: 17

Re: How Do I Add Usps Insurance To Order?

Okay, now only one Radio button is selected. I haven't a clue what I did that changed it but today it has only one button checked. What I really need to know is how to have only insured choices show up. Here is what I am getting:

FedEx Ground Service® - $10.61
FedEx Ground Service® (Insured) - $13.98
FedEx Express Saver® - $29.64
FedEx Express Saver® (Insured) - $33.01
FedEx 2 Day® - $34.06
FedEx 2 Day® (Insured) - $37.43
FedEx Priority® - $62.22
FedEx Priority® (Insured) - $65.59

What I want is this:

FedEx Ground Service® (Insured) - $13.98
FedEx Express Saver® (Insured) - $33.01
FedEx 2 Day® (Insured) - $37.43
FedEx Priority® (Insured) - $65.59

Any suggestions?

Thanks,
Edgar

Offline

 

#23 03-05-2004 01:01:28

Big Dave
Member
Registered: 10-24-2003
Posts: 742

Re: How Do I Add Usps Insurance To Order?

OK... with all the changes in this thread I got completely lost.
Can someone please post the process to get the following in ONE post please?

FedEx Ground Service® - $10.61
FedEx Ground Service® (Insured) - $13.98
FedEx Express Saver® - $29.64
FedEx Express Saver® (Insured) - $33.01
FedEx 2 Day® - $34.06
FedEx 2 Day® (Insured) - $37.43
FedEx Priority® - $62.22
FedEx Priority® (Insured) - $65.59


Thank you a thousand times.

Offline

 

#24 03-12-2004 12:06:18

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: How Do I Add Usps Insurance To Order?

Replace the code below (from the 'ste_chkout_meth_realtime_proc' routine
in ste_chkout.pl) :

Code:


if ($checked eq "N") {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

$checked = "Y";

} else {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\"> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

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

With this:

Code:


if ($checked eq "N") {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

$checked = "Y";

} else {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\"> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

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

if ($tracking_subtotal < 50.01) {
$insurance = 1.30;
} elsif ($tracking_subtotal < 100.01) {
$insurance = 2.20;
} elsif ($tracking_subtotal > int($tracking_subtotal/100) * 100) {
$insurance = int($tracking_subtotal/100) + 2.20;
} elsif ($sub_price = int($tracking_subtotal/100) * 100) {
$insurance = int($tracking_subtotal/100) + 1.20;
};

$service_name .= "$service_name (Insured)";
$service_rate = ($service_rate + $insurance);
$service_rate = sprintf("%.2f", $service_rate);
 
if ($checked eq "N") {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

$checked = "Y";

} else {

$return_value .= "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$service_name\:$service_rate\"> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $service_name_display - $currency$service_rate<BR></FONT>\n";

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


Nick Hendler

Offline

 

#25 04-29-2005 22:39:42

MBM
Member
Registered: 04-08-2005
Posts: 24

Re: How Do I Add Usps Insurance To Order?

Got this hack but how do I go about putting the option they chose onto the invoice? Wheater USPS First Class Mail or USPS First Class Mail (Insured) is chosen, it still only says USPS First Class Mail. Will not put the (Insured) on the order nor invoice.

Thanks!

Offline

 

Board footer