close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

USPS Shipping rates and options

Thread began 1/20/2010 12:48 pm by ryanteets270615 | Last modified 1/22/2010 5:54 pm by Eric Mittman | 2340 views | 8 replies |

ryanteets270615

USPS Shipping rates and options

My site is selling small lightweight and inexpensive items, so I want to keep the shipping to a minimum for the customer. I will be shipping by USPS First Class mail which works for total weight at 13 oz. or less. The lookup quote is accurate for these small orders.

However, should someone order a large quantity and the total weigh goes over 13 oz. and I can no longer ship by First Class mail, but rather have to use Priority Mail rates. In which case the rate quote returned is no longer accurate.

Has anyone else run into this issue?

Can I create 2 shipping rules and get rate quotes:
1. total weight <= 13oz. then Get Quote for First Class Mail
2. total weight > 13oz. then Get Quote for Priority Mail

How would I do this in eCart 5?

Sign in to reply to this post

ryanteets270615

also..

I see now that if the package weight is over 13oz. then the Rate returned is Parcel Post. However, I would rather use Priority Mail since it is faster and only slightly more expensive.

My original question still stands, is that possible?

Thanks!

Sign in to reply to this post

ryanteets270615

Alternative option

I was thinking that I could just add a little extra fee to orders that have a Totalweight over the 13 oz. first class limit.

So I setup 2 Shipping rules that I thought would do this. However, if the Total weight goes over 13oz. the Priority Mail rule does not calculate... Not sure why? It looks as if this approach would work...??

Any ideas?

Sign in to reply to this post

ryanteets270615

Ups

I see that I set the calculation on UPS rate rather than USPS rate... my mistake, however when corrected it still does not work.

Maybe the best way is just to add a flat rate $1.30 markup to the standard first-class/parcel post rate that is returned by the shipping quote. That would cover the slight difference in Priority mail cost, plus the $.80 delivery confirmation fee.

If you have other suggestions, I'd love to hear...!?

Sign in to reply to this post

Eric Mittman

One way you could to this so that you have two different service types in use depending on the weight would be to add in a second USPS server behavior and set it to use the Priority Mail.

Once the second server behavior is on the page you can create an if statements around them so that if the weight if less than 13oz then use the first server behavior, and if it is over 13oz then use the other one. You could simplify this further by putting the if statement directly into the server behavior around the service type. That way is a little more advanced though and would require you to hand edit the code for the server behavior.

If you can add the second server behavior to the page I can show you how you would craft the if statement to use one or the other.

Sign in to reply to this post

ryanteets270615

that will work

If you could help me with the code to construct the page, that would be great.

What I would like to do is add the package weight (+3) to the Total Cart Weight: (WA_eCart_FormatNumber($ecoCart->TotalColumn('TotalWeight'), true, 1))
Then, use that value as the variable to determine the shipping quote.

So, something like this:

$shipping_weight = (WA_eCart_FormatNumber($ecoCart->TotalColumn('TotalWeight'), true, 1) + 3

if $shipping_weight <= 13 then
run UPSP First Class Ship Quote Server Behaviour
Else
run UPSP Priority Mail Ship Quote Server Behaviour
End if


Sorry about my language since I'm coming from ASP and have not learned all the PHP code.

Here's my code that works:
UPSP First Class Ship Quote Server Behaviour:

<?php
if ("" == "") {
//WA eCart (Copyright 2007, WebAssist)
//WA eCart USPS Shipping - USPS
$Shipping_SuccessURL = "view_cart.php";
$Shipping_FailureURL = "shipping_failure.php";
$Shipping_Packaging = 0;
$Shipping_PackageArray = array();
$Shipping_PackageIndex = 0;
$Shipping_Counter = 0;
$Shipping_Parameters = array();
$Shipping_Parameters["ShiptoZip"] = "".((isset($_POST["shipping_postcode"]))?$_POST["shipping_postcode"]:"") ."";
$Shipping_Parameters["ShiptoCountry"] = "United States";
$Shipping_Parameters["UserID"] = "6##########";
$Shipping_Parameters["USPSServer"] = "http://production.shippingapis.com/shippingapi.dll";
$Shipping_Parameters["CarrierCode"] = "FIRST CLASS";
$Shipping_Parameters["DefaultIntl"] = "none";
$Shipping_Parameters["ShipperZip"] = "90069";
while (($Shipping_Packaging == 1 && !$ecoCart->EOF()) || ($Shipping_Packaging == 0 && $Shipping_Counter == 0)) {
if (WA_eCart_USPS_IsTrueValue("true")) {
$Shipping_PackageArray[] = array();
$Shipping_PackageIndex = sizeof($Shipping_PackageArray)-1;
$Shipping_PackageArray[$Shipping_PackageIndex]["eCart_Quantity"] = (($Shipping_Packaging == 1)?$ecoCart->DisplayInfo("Quantity"):1);
$Shipping_PackageArray[$Shipping_PackageIndex]["IsPackage"] = "true";
$Shipping_PackageArray[$Shipping_PackageIndex]["Quantity"] = "1";
$Shipping_PackageArray[$Shipping_PackageIndex]["WeightUnits"] = "oz";
/* Replaced these with above entries
$Shipping_PackageArray[$Shipping_PackageIndex]["Quantity"] = "".WA_eCart_FormatNumber($ecoCart->DisplayInfo('Quantity'), true, 1) ."";
$Shipping_PackageArray[$Shipping_PackageIndex]["WeightUnits"] = "".strtolower($ecoCart->WeightUnits) ."";
*/
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageWeight"] = "".WA_eCart_FormatNumber($ecoCart->TotalColumn('TotalWeight'), true, 1) ."";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageType"] = "YOURPACKAGING";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageSize"] = "REGULAR";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageMachinable"] = "false";
$Shipping_PackageArray[$Shipping_PackageIndex]["IPackageType"] = "none";
//Special Services
}
$Shipping_Counter++;
if ($Shipping_Packaging == 1) $ecoCart->MoveNext();
}
if ($Shipping_Packaging == 1) $ecoCart->MoveFirst();
$Shipping_Result = WA_eCart_USPS_GetRateQuote($ecoCart, $Shipping_Parameters, $Shipping_PackageArray);

if ($Shipping_Result && $Shipping_SuccessURL != "")
$ecoCart->redirStr = $Shipping_SuccessURL;
else if (!$Shipping_Result && $Shipping_FailureURL != "") {
Header("Location: " . $Shipping_FailureURL); exit;
}
}
else if (!isset($_SESSION["ecoCart_USPS_Success"])) {
WA_eCart_USPS_SetSessionDefaults($ecoCart);
}
?>





UPSP Priority Mail Ship Quote Server Behaviour:

<?php
if ("" == "") {
//WA eCart (Copyright 2007, WebAssist)
//WA eCart USPS Shipping - USPS
$Shipping_SuccessURL = "view_cart.php";
$Shipping_FailureURL = "shipping_failure.php";
$Shipping_Packaging = 0;
$Shipping_PackageArray = array();
$Shipping_PackageIndex = 0;
$Shipping_Counter = 0;
$Shipping_Parameters = array();
$Shipping_Parameters["ShiptoZip"] = "".((isset($_POST["shipping_postcode"]))?$_POST["shipping_postcode"]:"") ."";
$Shipping_Parameters["ShiptoCountry"] = "United States";
$Shipping_Parameters["UserID"] = "6#########";
$Shipping_Parameters["USPSServer"] = "http://production.shippingapis.com/shippingapi.dll";
$Shipping_Parameters["CarrierCode"] = "PRIORITY";
$Shipping_Parameters["DefaultIntl"] = "none";
$Shipping_Parameters["ShipperZip"] = "90069";

while (($Shipping_Packaging == 1 && !$ecoCart->EOF()) || ($Shipping_Packaging == 0 && $Shipping_Counter == 0)) {
if (WA_eCart_USPS_IsTrueValue("true")) {
$Shipping_PackageArray[] = array();
$Shipping_PackageIndex = sizeof($Shipping_PackageArray)-1;
$Shipping_PackageArray[$Shipping_PackageIndex]["eCart_Quantity"] = (($Shipping_Packaging == 1)?$ecoCart->DisplayInfo("Quantity"):1);
$Shipping_PackageArray[$Shipping_PackageIndex]["IsPackage"] = "true";
$Shipping_PackageArray[$Shipping_PackageIndex]["Quantity"] = "1";
$Shipping_PackageArray[$Shipping_PackageIndex]["WeightUnits"] = "oz";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageWeight"] = "".WA_eCart_FormatNumber($ecoCart->TotalColumn('TotalWeight'), true, 1) ."";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageType"] = "YOURPACKAGING";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageSize"] = "REGULAR";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageMachinable"] = "false";
$Shipping_PackageArray[$Shipping_PackageIndex]["IPackageType"] = "none";
//Special Services
}
$Shipping_Counter++;
if ($Shipping_Packaging == 1) $ecoCart->MoveNext();
}
if ($Shipping_Packaging == 1) $ecoCart->MoveFirst();
$Shipping_Result = WA_eCart_USPS_GetRateQuote($ecoCart, $Shipping_Parameters, $Shipping_PackageArray);
if ($Shipping_Result && $Shipping_SuccessURL != "")
$ecoCart->redirStr = $Shipping_SuccessURL;
else if (!$Shipping_Result && $Shipping_FailureURL != "") {
Header("Location: " . $Shipping_FailureURL); exit;
}
}
else if (!isset($_SESSION["ecoCart_USPS_Success"])) {
WA_eCart_USPS_SetSessionDefaults($ecoCart);
}
?>



many thanks!

Sign in to reply to this post

Eric Mittman

You are very close with the pseudo code you have. It would look like this in php:

php:
$shipping_weight = ($ecoCart->TotalColumn('TotalWeight')) + 3; //I took out the number formatting as it should not be needed here


if($shipping_weight <= 13){
 //UPSP First Class Ship Quote Server Behaviour
}else{
 //UPSP Priority Mail Ship Quote Server Behaviour
}



let me know if you have any problems with this.

Sign in to reply to this post

ryanteets270615

that worked!!

Thank you for the correct coding. Works great.

Sign in to reply to this post

Eric Mittman

Your welcome, the php code looks more like c or java coding that vb coding, you can use the same type of if and loop structures. Let us know if you have any further questions.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...