Free Shipping on a specific item
it as recommended in another post to set the weight of an item to zero to get free shipping on an item. When i do this i get an error from USPS
"No packages to ship"
How can i fix this?
it as recommended in another post to set the weight of an item to zero to get free shipping on an item. When i do this i get an error from USPS
"No packages to ship"
How can i fix this?
You must have some weight in the cart in order to obtain a shipping quote. If you have no weight then the quote will fail with this error message.
To allow customers to purchase only the item with the free shipping like this you will need to modify your code on the confirm page so that only if there is a weight in the cart will you try to get a quote for the shipping. While in code view if you go to the server behaviors and click on the USPS server behavior it should highlight the code on the page.
You will need to add an if statement just before this code block and add a curly brace just after it. The if statement will look like this:
<?php if ($WA_eCart->TotalColumn(TotalWeight) > 0 ){ ?>
//usps server behavior goes here
<?php } ?>
You would need to replace the WA_eCart with the name of your cart. This will ensure that the shipping quote only occurs if there is a weight in the cart.
Thanks for your help, When i tried this MY confirm page went blank.
Can you give me a little assist here keeping in mind that I dont do code very well.
Thanks
Could you post back with your confirm page, minus the sensitive details? I can show you where in the page this should go.
When you get a blank php page it usually means there is an error on the page and you have error reporting turned off. You can turn error reporting on by adding the following code to the top of your page:
<?php
error_reporting(E_ALL);
ini_set("display_errors", "on");
?>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//WA eCart (Copyright 2007, WebAssist)
//WA eCart USPS Shipping - USPS
$Shipping_SuccessURL = "";
$Shipping_FailureURL = "shipping_failure.php";
$Shipping_Packaging = 0;
$Shipping_PackageArray = array();
$Shipping_PackageIndex = 0;
$Shipping_Counter = 0;
$Shipping_Parameters = array();
$Shipping_Parameters["UserID"] = "xxxxx";
$Shipping_Parameters["USPSServer"] = "http://production.shippingapis.com/shippingapi.dll";
$Shipping_Parameters["CarrierCode"] = "PRIORITY";
$Shipping_Parameters["DefaultIntl"] = "Airmail Parcel Post";
$Shipping_Parameters["ShipperZip"] = "92860";
$Shipping_Parameters["ShiptoZip"] = "92860";
$Shipping_Parameters["ShiptoCountry"] = "US";
while (($Shipping_Packaging == 1 && !$eCart1->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)?$eCart1->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"] = "".$eCart1->DisplayInfo("TotalWeight") ."";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageType"] = "YOURPACKAGING";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageSize"] = "REGULAR";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageMachinable"] = "true";
$Shipping_PackageArray[$Shipping_PackageIndex]["IPackageType"] = "Package";
//Special Services
}
$Shipping_Counter++;
if ($Shipping_Packaging == 1) $eCart1->MoveNext();
}
if ($Shipping_Packaging == 1) $eCart1->MoveFirst();
$Shipping_Result = WA_eCart_USPS_GetRateQuote($eCart1, $Shipping_Parameters, $Shipping_PackageArray);
if ($Shipping_Result && $Shipping_SuccessURL != "")
$eCart1->redirStr = $Shipping_SuccessURL;
else if (!$Shipping_Result && $Shipping_FailureURL != "") {
Header("Location: " . $Shipping_FailureURL); exit;
}
}
else if (!isset($_SESSION["eCart1_USPS_Success"])) {
WA_eCart_USPS_SetSessionDefaults($eCart1);
}
?>
In the code that you posted the if statement should just go around the entire server behavior like this:
top of the if statement
<?php if ($eCart1->TotalColumn(TotalWeight) > 0 ){ ?>
the server behavior goes next
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//WA eCart (Copyright 2007, WebAssist)
//WA eCart USPS Shipping - USPS
$Shipping_SuccessURL = "";
$Shipping_FailureURL = "shipping_failure.php";
$Shipping_Packaging = 0;
$Shipping_PackageArray = array();
$Shipping_PackageIndex = 0;
$Shipping_Counter = 0;
$Shipping_Parameters = array();
$Shipping_Parameters["UserID"] = "xxxxx";
$Shipping_Parameters["USPSServer"] = "http://production.shippingapis.com/shippingapi.dll";
$Shipping_Parameters["CarrierCode"] = "PRIORITY";
$Shipping_Parameters["DefaultIntl"] = "Airmail Parcel Post";
$Shipping_Parameters["ShipperZip"] = "92860";
$Shipping_Parameters["ShiptoZip"] = "92860";
$Shipping_Parameters["ShiptoCountry"] = "US";
while (($Shipping_Packaging == 1 && !$eCart1->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)?$eCart1->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"] = "".$eCart1->DisplayInfo("TotalWeight") ."";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageType"] = "YOURPACKAGING";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageSize"] = "REGULAR";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageMachinable"] = "true";
$Shipping_PackageArray[$Shipping_PackageIndex]["IPackageType"] = "Package";
//Special Services
}
$Shipping_Counter++;
if ($Shipping_Packaging == 1) $eCart1->MoveNext();
}
if ($Shipping_Packaging == 1) $eCart1->MoveFirst();
$Shipping_Result = WA_eCart_USPS_GetRateQuote($eCart1, $Shipping_Parameters, $Shipping_PackageArray);
if ($Shipping_Result && $Shipping_SuccessURL != "")
$eCart1->redirStr = $Shipping_SuccessURL;
else if (!$Shipping_Result && $Shipping_FailureURL != "") {
Header("Location: " . $Shipping_FailureURL); exit;
}
}
else if (!isset($_SESSION["eCart1_USPS_Success"])) {
WA_eCart_USPS_SetSessionDefaults($eCart1);
}
?>
just after the server behavior you will put in the closing curly brace for the if
<?php } ?>
I also updated the cart that is referenced in the example to be your cart so you can put this code directly onto your page.
Thank you very much. You guys are very good at what you do and I am very pleased to have such a high quality support team and high quality products to work with
it is working except for the follow.
If you have only the zero weight item in your cart it is fine. If you add an item that has weight to the order i get a No packages to ship message.
If an item is in the cart that has weight and you add a zero weight item it works fine.
Ok, you can account for this by doing another check within the server behavior when it is looping over the items. You can check the current item to see if it has a weight, if it does not then you can skip that one.
You can just alter the existing code in this server behavior where it is looping like this:
if ((WA_eCart_USPS_IsTrueValue("true")) && ($eCart1->DisplayInfo("TotalWeight") > 0) ) {
$Shipping_PackageArray[] = array();
$Shipping_PackageIndex = sizeof($Shipping_PackageArray)-1;
$Shipping_PackageArray[$Shipping_PackageIndex]["eCart_Quantity"] = (($Shipping_Packaging == 1)?$eCart1->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"] = "".$eCart1->DisplayInfo("TotalWeight") ."";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageType"] = "YOURPACKAGING";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageSize"] = "REGULAR";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageMachinable"] = "true";
$Shipping_PackageArray[$Shipping_PackageIndex]["IPackageType"] = "Package";
//Special Services
}
This should allow it to just skip the items that do not have a weight if there are any items in the cart that do have a weight. Please test this out with your various scenarios and let us know if this works for you and if not let us know what the result is.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
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.