close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Free Shipping on a specific item

Thread began 1/11/2010 10:28 am by dan377928 | Last modified 1/14/2010 7:25 pm by Eric Mittman | 1105 views | 8 replies |

dan377928

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?

Sign in to reply to this post

Eric Mittman

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:
<?php if ($WA_eCart->TotalColumn(TotalWeight) > ){ ?>


//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.

Sign in to reply to this post

dan377928

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

Sign in to reply to this post

Eric Mittman

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:
<?php

error_reporting
(E_ALL);
ini_set("display_errors""on");
?>
Sign in to reply to this post

dan377928

<?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);
}
?>

Sign in to reply to this post

Eric Mittman

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:
<?php if ($eCart1->TotalColumn(TotalWeight) > ){ ?>



the server behavior goes next

php:
<?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 == && !$eCart1->EOF()) || ($Shipping_Packaging == && $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:
<?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.

Sign in to reply to this post

dan377928

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

Sign in to reply to this post

dan377928

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.

Sign in to reply to this post

Eric Mittman

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:

php:
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.

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...