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

need to add usps shipping option (along with UPS)

Thread began 2/10/2010 1:04 pm by tim299030 | Last modified 4/06/2010 3:53 pm by Eric Mittman | 2903 views | 14 replies |

tim299030

need to add usps shipping option (along with UPS)

I have a store that currently uses UPS as it's shipping option but my customer wants to include USPS as an additional customer selectable option. Is there a recipe or some documentation for this?

If not, what steps are necessary for making it so the customer can choose either UPS or USPS?

Tim

Sign in to reply to this post

Eric Mittman

We don't have any documentation on getting two different providers working together. You could start by setting up the additional server behavior then modifying the triggers to work with the form element the user selects to choose one over the other.

This selection should occur on the checkout page, you can just add a radio group or a select list for the user to choose from.

Next on your confirm page you would apply the new USPS shipping server behavior and configure it accordingly. Once you have both of them on the confirm page you can them update the triggers to look at the posted value for the shipping selection that comes from the checkout page. If it is one value you would use UPS, and if it is the other value you would use USPS.

Please post back with questions about any part of this that you are not familiar with and I will gladly expand and give you some more specifics.

Sign in to reply to this post

tim299030

I've added the menu on the checkout page and added the server behavior on the confirm page. I'm not sure how to configure the trigger.

In your post you said:
Once you have both of them on the confirm page you can them update the triggers to look at the posted value for the shipping selection that comes from the checkout page. If it is one value you would use UPS, and if it is the other value you would use USPS.

How do I pass the value "UPS" or "USPS" to the confirm page? My menu uses the select name and id of "shipping_type" and it shows up in the "ecart_checkout_form" on the checkout page in the bindings panel, but "shipping_type" doesn't show up as an option in the confirm pages binding panel.

Sign in to reply to this post

Eric Mittman

You can try adding the form data binding and select the checkout page to see if that updates the bindings and allows the select list to be available to you. If that does not work you can set the trigger manually by selecting any posted form element and changing the name listed in the trigger like this:

php:
<?php echo isset($_POST['your form element'])?$_POST['your form element']:"" ?>



This is just to get at the value, the actual trigger should look like this when you see it in the code:

php:
if((isset($_POST['your form element'])?$_POST['your form element']:"") == 'UPS'){

the UPS shipping quote server behavior here
} else {
the USPS shipping server behavior here
}



If you post back with the code for the select list that is in your checkout form I can give you a better example of this.

Sign in to reply to this post

tim299030

I think I follow you. Here's what I did:

First, here's my form element from the checkout page:

****************FORM ELEMENT FROM CHECKOUT PAGE*********************

<table border="0" cellspacing="0" cellpadding="0" class="eC_SameAsWrapper" >
<tr>
<td style="padding-right: 10px;">Shipping type: </td>
<td style="vertical-align: top;"><select name="shipping_type" id="shipping_type" >
<option value="UPS">UPS</option>
<option value="USPS">USPS</option>
</select>&nbsp;<span style="color:#A14A35; font-size:18px;">*</span></td>
</tr>
</table>
****************END FORM ELEMENT FROM CHECKOUT PAGE*********************


Then, on the confirm page I put the trigger in manually:

<?php echo((isset($_POST["shipping_type"]))?$_POST["shipping_type"]:"") ?>


Here's what the result is after I do the above:


<?php
if ((((isset($_POST["shipping_type"]))?$_POST["shipping_type"]:"") != "")) {
//WA eCart (Copyright 2007, WebAssist)
//WA eCart UPS Shipping - UPS
$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"] = "MY_CUSTOMERS_USER_ID";
$Shipping_Parameters["Password"] = "MY_CUSTOMERS_PW";
$Shipping_Parameters["AccessKey"] = "MY_CUSTOMERS_ACCESS_KEY";
$Shipping_Parameters["CarrierCode"] = "03";
$Shipping_Parameters["PickupType"] = "03";
$Shipping_Parameters["CustomerClass"] = "none";
$Shipping_Parameters["ShipperNumber"] = "MY_CUSTOMERS_SHIPPER_NO";
$Shipping_Parameters["ShipperCity"] = "Findlay";
$Shipping_Parameters["ShipperState"] = "OH";
$Shipping_Parameters["ShipperZip"] = "45840";
$Shipping_Parameters["ShipperCountry"] = "US";
$Shipping_Parameters["ShiptoCity"] = "".((isset($_POST["shipping_city"]))?$_POST["shipping_city"]:"") ."";
$Shipping_Parameters["ShiptoState"] = "".((isset($_POST["shipping_state_province"]))?$_POST["shipping_state_province"]:"") ."";
$Shipping_Parameters["ShiptoZip"] = "".((isset($_POST["shipping_postcode"]))?$_POST["shipping_postcode"]:"") ."";
$Shipping_Parameters["ShiptoCountry"] = "".((isset($_POST["shipping_country"]))?$_POST["shipping_country"]:"") ."";
while (($Shipping_Packaging == 1 && !$RoyaleCart->EOF()) || ($Shipping_Packaging == 0 && $Shipping_Counter == 0)) {
if (WA_eCart_UPS_IsTrueValue("true")) {
$Shipping_PackageArray[] = array();
$Shipping_PackageIndex = sizeof($Shipping_PackageArray)-1;
$Shipping_PackageArray[$Shipping_PackageIndex]["eCart_Quantity"] = (($Shipping_Packaging == 1)?$RoyaleCart->DisplayInfo("Quantity"):1);
$Shipping_PackageArray[$Shipping_PackageIndex]["IsPackage"] = "true";
$Shipping_PackageArray[$Shipping_PackageIndex]["Quantity"] = "1";
$Shipping_PackageArray[$Shipping_PackageIndex]["WeightUnits"] = "LBS";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageWeight"] = "".$RoyaleCart->DisplayInfo("TotalWeight") ."";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageType"] = "02";
$Shipping_PackageArray[$Shipping_PackageIndex]["SizeUnits"] = "IN";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageLength"] = "17";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageWidth"] = "11";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageHeight"] = "8";
//Special Services
}
$Shipping_Counter++;
if ($Shipping_Packaging == 1) $RoyaleCart->MoveNext();
}
if ($Shipping_Packaging == 1) $RoyaleCart->MoveFirst();
$Shipping_Result = WA_eCart_UPS_GetRateQuote($RoyaleCart, $Shipping_Parameters, $Shipping_PackageArray);
if ($Shipping_Result && $Shipping_SuccessURL != "")
$RoyaleCart->redirStr = $Shipping_SuccessURL;
else if (!$Shipping_Result && $Shipping_FailureURL != "") {
Header("Location: " . $Shipping_FailureURL); exit;
}
}
else if (!isset($_SESSION["RoyaleCart_UPS_Success"])) {
WA_eCart_UPS_SetSessionDefaults($RoyaleCart);
}
?>
<?php
if ((((isset($_POST["shipping_type"]))?$_POST["shipping_type"]:"") != "")) {
//WA eCart (Copyright 2007, WebAssist)
//WA eCart USPS Shipping - USPS
$Shipping_SuccessURL = "";
$Shipping_FailureURL = "checkout_failure.php";
$Shipping_Packaging = 0;
$Shipping_PackageArray = array();
$Shipping_PackageIndex = 0;
$Shipping_Counter = 0;
$Shipping_Parameters = array();
$Shipping_Parameters["UserID"] = "MY_CUSTOMERS_USER_ID";
$Shipping_Parameters["USPSServer"] = "http://production.shippingapis.com/shippingapi.dll";
$Shipping_Parameters["CarrierCode"] = "PRIORITY";
$Shipping_Parameters["DefaultIntl"] = "Global Express Guaranteed Non-Document Service";
$Shipping_Parameters["ShipperZip"] = "45840";
$Shipping_Parameters["ShiptoZip"] = "".$_SESSION['eCartCheckoutForm_shipping_postcode'] ."";
$Shipping_Parameters["ShiptoCountry"] = "".$_SESSION['eCartCheckoutForm_shipping_country'] ."";
while (($Shipping_Packaging == 1 && !$RoyaleCart->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)?$RoyaleCart->DisplayInfo("Quantity"):1);
$Shipping_PackageArray[$Shipping_PackageIndex]["IsPackage"] = "true";
$Shipping_PackageArray[$Shipping_PackageIndex]["Quantity"] = "1";
$Shipping_PackageArray[$Shipping_PackageIndex]["WeightUnits"] = "lb";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageWeight"] = "".WA_eCart_FormatNumber($RoyaleCart->TotalColumn('TotalWeight'), true, 1) ."";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageType"] = "YOURPACKAGING";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageSize"] = "REGULAR";
$Shipping_PackageArray[$Shipping_PackageIndex]["PackageMachinable"] = "none";
$Shipping_PackageArray[$Shipping_PackageIndex]["IPackageType"] = "Package";
//Special Services
}
$Shipping_Counter++;
if ($Shipping_Packaging == 1) $RoyaleCart->MoveNext();
}
if ($Shipping_Packaging == 1) $RoyaleCart->MoveFirst();
$Shipping_Result = WA_eCart_USPS_GetRateQuote($RoyaleCart, $Shipping_Parameters, $Shipping_PackageArray);
if ($Shipping_Result && $Shipping_SuccessURL != "")
$RoyaleCart->redirStr = $Shipping_SuccessURL;
else if (!$Shipping_Result && $Shipping_FailureURL != "") {
Header("Location: " . $Shipping_FailureURL); exit;
}
}
else if (!isset($_SESSION["RoyaleCart_USPS_Success"])) {
WA_eCart_USPS_SetSessionDefaults($RoyaleCart);
}
?>


Am I in the ball park? Do you need to see the actual files?

Thanks for your help.

Tim

Sign in to reply to this post

Eric Mittman

You are very close, you just need to update these two triggers to check for the specific value of the posted element, like this:

php:
if ((((isset($_POST["shipping_type"]))?$_POST["shipping_type"]:"") == "UPS")) {



For the second server behavior you would update to be like this:

php:
if ((((isset($_POST["shipping_type"]))?$_POST["shipping_type"]:"") != "UPS")) {



This way it will check if the user selected UPS, and if not the USPS shipping quote will be used.

Sign in to reply to this post

tim299030

Eric -- I thought I followed your instructions well but it appears I'm missing something. I'm getting the following error:

Parse error: syntax error, unexpected T_CONCAT_EQUAL in /home/royaleco/public_html/WA_eCart/WA_eCart_USPS_PHP.php on line 49

I'll attach the files I think you need. If you need additional or different ones please let me know.

Sign in to reply to this post

Eric Mittman

Did you select USPS as the shipping type? In the file I have with this name the line of code referenced is just checking on the package weight. Here is the line of code that I have on the line referenced:

php:
if ($USPS_LbWeight > 0 || $USPS_OzWeight > 13.0)  {//weight limit for first class



Is this the same line of code that you have on line 49? If so then ther is probably a bad value that is being used within this server behavior. Are you using First Class mail as the type of mailing for USPS? Please post back with this info and if we need to look into this further I can open a ticket so we can exchange the files in private.

Sign in to reply to this post

tim299030

Eric,


Line 49 in my document is:

$USPS_XML ..= "<Service>" . $USPS_Parameters["CarrierCode"] . "</Service>";

I have it set in the server behavior for Priority NOT First Class.

Tim

Sign in to reply to this post

Eric Mittman

What is the version of eCart that you are working with? This looks like an old issue that has been updated in the newer releases of eCart. I'm including a new updated copy of the USPS file for you. Make a backup of yours and replace it with this newer file and test it out again.

The problem with the line of code is the dot dot where it is assigning the value to this variable.

This

php:
$USPS_XML ..=



should be this

php:
$USPS_XML .=
Attached Files
WA_eCart_USPS_PHP.zip
Sign in to reply to this post
loading

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