close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

eCart - Shipping rates from country codes

Thread began 9/26/2011 1:55 pm by shop280345 | Last modified 10/28/2011 5:13 pm by Jason Byrnes | 1428 views | 11 replies |

shop280345

eCart - Shipping rates from country codes

Dear Webassist,
I am building a database site with CS3/DataAssist/eCart5 with items_detail, cart, checkout, confirm, etc through to Paypal standard payment.
I am using XAMPP 1.7.3, MySql 5.1, Php 5.3.1, local server to test.
At present I have a single (6.25) flat rate shipping applied to the total amount in the cart.
I would like to apply three different flat rates for shipping, based on the entered Checkout form country codes?
Rate1-£6.25 United Kingdom "GB"
Rate2-£7.60 Europe "AL","AD","AM","AT","BE","BG", etc,
Rate3-£9.60 USA, rest of World "US","AU","BR", etc.

I have looked through "Shippping rates" in the forum which suggests this is achievable
but I'm not sure how or quite where to start.
Can you help me please
Johnnie

Sign in to reply to this post

CraigRBeta Tester

i would set the chosen shipping country as a session variable, and use this variable in the shipping calculation.

(On your confirm page, you may already have this variable in place)

if (!session_id()) session_start();
if (isset($_POST["Checkout"]) || isset($_POST["Checkout_x"])) {
$_SESSION["eCartCheckoutForm_country"] = "".((isset($_POST["country"]))?$_POST["country"]:"") ."";
}



in your ecart object, under the shipping tab, you create 3 shipping rules, one for each of your possible shipping options.

eg for GB shipping, make the condition based on a session variable value, the variable name being what you call it, (it would be 'eCartCheckoutForm_country' using the above code) and the value = 'GB' and the calculation as a flat rate.

for europe shipping, make the condition based on a session variable value = 'AL' or 'AD' etc

eg

Sign in to reply to this post

shop280345

Thanks for your help Craig,
That works, all the correct totals go through to PayPal gateway, and in the specified country code language.
However, only if the top line of code//Shipping (in this case "ShippingGB" = "6.25")is selected, does the shipping cost get shown above the Total, on file confirm.php.

Any Ideas?
Johnnie

From ecart1_PHP.php
//Shipping
$this->Shipping[] = new WA_eCart_Rule(urldecode("ShippingGB"), true, "WAEC_eCart1_ShippingGB");
$this->Shipping[] = new WA_eCart_Rule(urldecode("ShippingEurope"), true, "WAEC_eCart1_ShippingEurope");
$this->Shipping[] = new WA_eCart_Rule(urldecode("ShippingUSA"), true, "WAEC_eCart1_ShippingUSA");
}
//end node

//eCart Rule
function WAEC_eCart1_ShippingGB() {
$totalShipping = 0;
if (true && (((isset($_SESSION['eCartCheckoutForm_country'])?$_SESSION['eCartCheckoutForm_country']:"") == "GB"))) {
$totalShipping += 6.25;//Result
}
return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_eCart1_ShippingEurope() {
$totalShipping = 0;
if (true && (((isset($_SESSION['eCartCheckoutForm_country'])?$_SESSION['eCartCheckoutForm_country']:"") == "FR"))) {
$totalShipping += 7.60;//Result
}
return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_eCart1_ShippingUSA() {
$totalShipping = 0;
if (true && (((isset($_SESSION['eCartCheckoutForm_country'])?$_SESSION['eCartCheckoutForm_country']:"") == "US"))) {
$totalShipping += 9.5;//Result
}
return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule

Sign in to reply to this post

CraigRBeta Tester

can you zip and upload your checkout and confirm pages ?

do you have a link ?

thanks

Sign in to reply to this post

shop280345

Craig,
Checkout and confirm pages,
Site is on my local puter.
Johnnie

Attached Files
checkout.zip
Sign in to reply to this post

CraigRBeta Tester

Hmm.

Well the code looks ok, I can't see anything obvious.

I compared it to something similar I did a while ago, and there are no glaring errors.

Let me clarify, if you choose GB for shipping, you get the shipping displayed in the shipping section of the confirm page, but if you choose France or US, it is not displayed?


Only anomaly i did find is that the session you have chosen is for the billing country, NOT the shipping country, which could be the cause of your problem

Sign in to reply to this post

shop280345

Craig,
I've changed/added shipping_country into the mix and same occurrs, everything still correct at paypal and saved on my database orders/details. But still only shows on confirm.php if GB is selected. Ignoring the "shippingEurope" & "shippingUSA" below.
If I swap them around it will show whichever is first of the three..

From ecart1_PHP.php
//Shipping
$this->Shipping[] = new WA_eCart_Rule(urldecode("ShippingGB"), true, "WAEC_eCart1_ShippingGB");
$this->Shipping[] = new WA_eCart_Rule(urldecode("ShippingEurope"), true, "WAEC_eCart1_ShippingEurope");
$this->Shipping[] = new WA_eCart_Rule(urldecode("ShippingUSA"), true, "WAEC_eCart1_ShippingUSA");
}
//end node

Do I need to create a new rule/definition for Europe & USA in the eCart1/definitions files?
Johnnie

Attached Files
eCart1_PHP.zip
Sign in to reply to this post

Jason ByrnesWebAssist

send a link where i can see this in the browser please.

Sign in to reply to this post

CraigRBeta Tester

a link would really help.

the session must be set correctly if paypal is processing the correct values.

i even tried copying your code onto a test page, and it works !

have you tried to echo the session value on the confirm page

Sign in to reply to this post

shop280345

Well I've just spent a silly amount of time unsuccesfully trying to get all this onto a server you can see! I will post back when it's running!
I'm away now untill the 12th Oct.
Thanks for time thus far.
Johnnie

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