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

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

logic question regarding shipping calculation

Thread began 7/06/2016 9:28 am by Christopher West | Last modified 7/12/2016 2:15 pm by Ray Borduin | 1899 views | 9 replies |

Christopher WestCommunity Expert

logic question regarding shipping calculation

Hey quick question regarding the same sake of the Question Topic (above).

I plan to have the following structure
Basket - This will include basket summary and form to enter a coupon code.
Checkout - This will just include a form for billing/shipping details and card payment details
Confirm - this does all the paypal communication stuff
Success - This page will display thank you message and include server behaviors for email and adding order to database.

For shipping calculation I plan to place all the calculation in a separate hidden php file. I assume the best way to accomplish this, is on the checkout page when a customer enters the postcode for shipping, it will access the separate hidden php file and then return the calculated shipping cost as a session variable. I assume I would either do some kind of AJAX call to this file, or some type of inline javascript on the form field in question (kind of like an onclick event - but obviously when a customer clicks out of the input field?

The alternative option is to place the shipping postcode form field on the basket page. But then obviously with this method the customer could easily type in any old postcode on the basket page which can be different to the postcode they enter on the checkout page (I could prevent this by storing the post code as a session and then adding this postcode session variable on the checkout page and making the postcode form input read only.

Which would be the best method from described above? or is there an alternative that I haven't thought of?

NOTE: the postcode calculation will take only the first 2 characters of the customers delivery postcode, since the shipping companies use the first 2 characters of the postcode to associate with a shipping zone.

Chris

Sign in to reply to this post

Ray BorduinWebAssist

If you add the shipping to the confirm_cart.php page after running the eCart 6 checkout wizard, then it will automatically recalculate using AJAX during checkout.

Sign in to reply to this post

Christopher WestCommunity Expert

if I chose not to use the ecart wizard, and instead use the individual ecart server behaviours to create the checkout process.Would you have an alternative solution? One reason why I thought not to use the checkout wizard is that I want to keep the code simple as the ecart wizard does add a lot of css classes. I could obviously remove them all, but that could take just as long. Or I could run the wizard on a separate project folder and then copy the required ajax functionality.

Sign in to reply to this post

Ray BorduinWebAssist

There is a lot of javascript involved in getting it all working properly. You can do it manually, but I think removing the extra css after running the wizard would be easier.

Sign in to reply to this post

Christopher WestCommunity Expert

Hi. ok I am running the checkout wizard. after the wizard finished. there is a syntax error on the confirm.php file. Attaching file - its on line 326.
$WA_fieldValuesStr = @@FieldValueStrParam@@;

also on 357: $WA_fieldValuesStr = @@FieldValueStrParam@@;

I corrected the syntax error as it seemed it was missing double quotes


Also as I have my own order detail and order summary tables, the wizard explained that some fields it will ignore.

When uploading all files to localhost and adding a product to checkout etc. I get this error:
Warning: require_once(WA_eCart/WA_eCart_Database_PHP.php): failed to open stream: No such file or directory in C:\xampp\htdocs\armadillo\confirm.php on line 49

Fatal error: require_once(): Failed opening required 'WA_eCart/WA_eCart_Database_PHP.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\armadillo\confirm.php on line 49

php:
require_once("WA_eCart/WA_eCart_Database_PHP.php");



I checked the directory and that file is indeed missing?

Chris


Chris

Sign in to reply to this post

Ray BorduinWebAssist

Try running the wizard again. It looks like it failed when doing the database storage portion. That code is incorrect even with the double quotes. It should have been replaced with column names.

Sign in to reply to this post

Christopher WestCommunity Expert

Hi yeah that worked. but I think I am going to try doing a manual setup, as the checkout process that I want is slightly different to the wizard version.

mainly because I still want to capture the billing details for customer via the form on the website if the customer chooses to pay using the paypal option.

few questions:
1. The persist server behaviors - are these required if I am using payment fields (card number, expiry etc) on the website? I just wanted to get a handle on the purpose of this?
2. the wizard generates confirm.php and pp_confirm.php - assume that pp_confirm.php is used for paypal payment. but in the confirm.php there is the server behavior : authentication for paypal express (this has nothing to do with paypal button does it What I mean is this server behaviour also required for card payments on the website?).

Chris

Sign in to reply to this post

Ray BorduinWebAssist

1) Persist just saves all of the values in the session so they can be more easily referred to later when saving in the database and sending email. Since the form submits via ajax and the card information is in a separate form it has to be saved in the session to keep track of it more easily.

2) That is only necessary for express checkout, as is the pp_confirm page.

Sign in to reply to this post

Christopher WestCommunity Expert

(1) With regard to answer answer (1) you provided, in the past I have just used session variables to do the same thing that you mentioned, what are the main differences between both approaches?

(2) With the answer you provided, "only necessary for express checkout, as is the pp_confirm page" - Why isn't this server behavior in the pp_confirm file then?

Im just trying to break down the check wizard.
a) the checkout.php seems to use framework builder to call the files confirm_cart.php and confirm.php files on javascript conditions.
b) confirm_cart.php - purpose is to display shopping basket
c) confirm.php - purpose is to display credit card form
d) pp_confirm.php - is the pay that PayPal Express returns to after login to paypal.

A few things I need to change (workflow) is:
a) I would like to allow PayPal Express users to fill in the billing details (unless of course after login to PayPal I can return values I can store in database)?
b) I need to place somewhere my shipping calculation - where would this be best placed in terns of which files?
c) I believe best place to place coupon code calculation is in the shopping basket page (before checkout).
d) I before checkout - the client wants to allow customers to either login or use checkout as a guest checkout - do you have any recommendations on workflow. Im looking at ways to integrate this if I were to use the checkout wizard?

Chris

Sign in to reply to this post

Ray BorduinWebAssist

1) Persist form just saves the entire form into a single session variable so you don't have to save them all individually.

2) The pp confirm page should have the process transaction server behavior as well as save in database for paypal. Authenticate is the first step in the process before you can process.

a) Yes
b) Yes and to calculate shipping or tax costs based on the shipping information
c) Yes as well as do the process server behaviors for credit cards
d) Yes

Changes
a) You could update the javascript to not hide the billing fields for paypal. Ultimately it is going to use the billing information from paypal however, so I'm not sure why you want to ask for it on your site as well.
b) confirm_cart is for shipping calculation
c) Yes
d) By default it is guest checkout. You can add login and pre-fill the fields as well as save the UserID from the session into the orders table if they choose to log in.

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