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

shipping per country - PayPal failure

Thread began 4/29/2015 9:18 am by rob75685 | Last modified 5/06/2015 1:07 pm by Ray Borduin | 836 views | 14 replies |

rob75685

shipping per country - PayPal failure

hi guys

I'm having problems setting up a different shipping cost per country selected on the checkout page. I just want one price for GB and another price for any other selection.

I've set up two shipping rules as follows:

//eCart Rule
function WAEC_eCart1_std_shipping() {
$totalShipping = 0;
if (true && (((isset($_SESSION['eCartCheckoutForm_country'])?$_SESSION['eCartCheckoutForm_country']:"") == "GB"))) {
$totalShipping += floatVal("10");//Result
}
return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_eCart1_shipping_row() {
$totalShipping = 0;
if (true && (((isset($_SESSION['eCartCheckoutForm_country'])?$_SESSION['eCartCheckoutForm_country']:"") != "GB"))) {
$totalShipping += floatVal("15");//Result
}
return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule


here's my SESSION variable on the checkout page:

@session_start();
if(!isset($_SESSION["eCartCheckoutForm_country"])) {
$_SESSION["eCartCheckoutForm_country"] = "".(WA_getSavedFormValue("CheckoutWizard_NewFromBlank_Default","Country")) ."";
}


and here's my cart page live (you can add a misc item to test it):

http://www.rtmedia.co.uk/test/davidhayward/cart.php

any ideas what I've done wrong ?
many thanks as always :)

Sign in to reply to this post

Ray BorduinWebAssist

One thing for sure is you should change the trigger for setting the session variable. The trigger you are using will only set the session variable if it isn't already set, and would prevent people from changing the setting.

It should probably just always set it like:

@session_start();
if(""=="") {
$_SESSION["eCartCheckoutForm_country"] = "".(WA_getSavedFormValue("CheckoutWizard_NewFromBlank_Default","Country")) ."";
}

Another thing that I'd probably do is add a condition to both rules "If session variable exists" so that it won't show any shipping until after they set their country on the checkout page.

Sign in to reply to this post

rob75685

thanks for your help Ray

that changes the Shipping total successfully from one to the other, but I still get the PayPal checkout failure... but with no indication why

I've attached my files if you could take a look please - eCart1_PHP.php, confirm.php and checkout.php

Sign in to reply to this post

Ray BorduinWebAssist

Add this code to the failure page:

<?php
@session_start();
var_dump($_SESSION);
?>

The resulting code will include details on why it failed. If you have a hard time interpreting it, view source on the page and copy the code and post it back here in the private area since it may include api credentials. I'll take a look and tell you what might be wrong.

Sign in to reply to this post

rob75685

thanks Ray - code attached privately

Sign in to reply to this post

Ray BorduinWebAssist

It is complaining that the Total doesn't match the sum of the items in the cart.

If you can view source before copy and pasting the error codes I can see better what is going on. Please post the same message as before, but view source on the page first so that I can see it with the spaces and tags that won't show when viewed through the browser.

Then attach a copy of the confirm.php page and I can figure out how to resolve it.

Sign in to reply to this post

rob75685

thanks Ray - code attached

Attached Files
confirm.php
source_code.txt
Sign in to reply to this post

Ray BorduinWebAssist

The issue is with the currency conversion thing you are doing and how you are calculating the grand total based on the taxable total from the cart. This doesn't includethe shipping or handling. Since your cart includes a shipping charge, that is what is causing the problem.

If you don't want to convert the shipping charge you would have to still add it to the grand total on line 77 like this:

$grandtotal += $eCart1->GetShipping();

If you do want to include the shipping in the conversion then you would have to use the Grand Total from the cart and do the same conversion on the shipping field below.

Sign in to reply to this post

rob75685

Thanks Ray, If I want to include the shipping in the conversion then presumably I can do this:

$grandtotal += $shippingtotal

whereby $shippingtotal is a variable that takes $eCart1->GetShipping(); with the currency conversion applied in the same manner as $grandtotal

Sign in to reply to this post

rob75685

hi Ray - more details attached, thank you

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