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

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

2 Basic Shipping Options required

Thread began 1/03/2011 10:16 pm by craig158722 | Last modified 2/07/2011 11:32 am by Heckie | 1539 views | 10 replies |

craig158722

2 Basic Shipping Options required

This seems such a simple option to have on my clients site but the answer is avoiding me.

My client would like to have 2 flat rate options for shipping added to their site using a drop down selection box. These are:

Collect from store - £0.00

Next day courier - £8.00

Can anybody tell me the best way to go about this?

I have tried adding this option to the checkout page but cannot for the life of me get the confirm page to pick it up and show the shipping cost.

Sign in to reply to this post

CraigRBeta Tester

one approach would be to have a dropdown with the shipping options for the customer.

Set a session variable to the value of the dropdown, and in the shipping calculation in the ecart object, set the shipping cost based on the value of the session variable

Sign in to reply to this post

craig158722

Thanks for leaving your reply.

I have created a dropdown in the checkout page with the values adding to a session variable and I can get the value to display on the confirm page but for some reason the cart isn't picking it up and adding the value to the shipping cost.

Can't seem to figure out how to get the value to add to the order total.

The site that I am trying to get this working with is shop.php

Not sure where to go with this to make it work.

Below is the snippet of code which I have taken from the ELShop_PHP.php file which is the eCart for this site:

//eCart Rule
function WAEC_ELShop_Collectfromstore() {
$totalShipping = 0;
if (true && (((isset($_SESSION['Shipping_cost'])?$_SESSION['Shipping_cost']:"") != "1"))) {
$totalShipping += 0.00;//Result
}
return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_ELShop_Shippinghandling() {
$totalShipping = 0;
if (true && (((isset($_SESSION['Shipping_cost'])?$_SESSION['Shipping_cost']:"") != "3"))) {
$totalShipping += 8.00;//Result
}
return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//end node


I have tried various options with no success.

Sign in to reply to this post

CraigRBeta Tester

Here's one approach which may work for you.

In the option list, (on the cart page or wherever), give the free shipping a value of 0, the paid shipping a value of 1.

set the session variable to be the value of the list option

In the shipping tab for the eCart object, create a new shipping rule, and test for the existence of the session variable you created.

set the calculation to be flat rate, $_SESSION['testshipping'] * 8.

in the case where the free shipping is selected 0 * 8 will give you 0, but the other option will give you 1 * 8

the screenshot for the eCart object is attached, the code block in the cart_PHP.php page looks like this...

//eCart Rule
function WAEC_rainbowcart_test() {
$totalShipping = 0;
if (true && ((isset($_SESSION['testshipping'])))) {
$totalShipping += $_SESSION['testshipping'] * 8;//Result
}
return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
Sign in to reply to this post

craig158722

Thank you for your help on this Craig but still pulling my hair out!!

It seems that whenever I use a session variable within the shipping of the eCart the shipping option is no longer recognised and is ignored.

If I set the shipping to items in basket greater than 0 and set a flat rate of £8.00 this shows up on the confirm page but as soon as I change it to session variable nothing shows and the total does not include the shipping.

I know the session variable is being set as I have added a php echo at the bottom of the shipping address section which then shows the value of the session variable so looks like that works but eCart is just ignoring it. Unless of course I am missing something really stupid here. You mentioned above to set the value of the session variable to the value of the list option. can you confirm how I do this in case as I said I am doing something really silly.

Also you mentioned testing the session variable in the shipping section of the eCart. Is there a way of doing this other than what I have already done?

Any ideas where I could go from here?

Thanks again for your help.

Sign in to reply to this post

CraigRBeta Tester

the issue you have is that if the value of the shipping calculation is 0, then nothing will appear in the shipping line of the cart

what i would be tempted to do is change the shipping calculation, so that it is a fixed value.

this will obviously be set regardless of the session value selected, but at least it will show that the session variable is being set and detected.

once this works, change the calculation

if all else fails, zip and post the offending pages

Sign in to reply to this post

Jason ByrnesWebAssist

send a copy of your checkout, confirm and ELShop_PHP.php page so we can take a look at the code, this will help us see where the problem is.

Sign in to reply to this post

craig158722

Thanks for your help guys. Offending pages have been attached.

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

Jason ByrnesWebAssist

your code to set the ship type variable is not correct.

on the confirm page, you have:

php:
<?php



if (!session_id()) session_start();
if(
"" == "")     {
  
$_SESSION["ShipType"] = "".$_SESSION['ShipType']  ."";
}
?>




this is setting the ship type session to be equal to the ship type session, since it hasn't been set yet, it wont get set this way. you need to use the ShipType POST:

php:
<?php

if (!session_id()) session_start();
if(
$_SERVER["REQUEST_METHOD"] == "POST")     {
  
$_SESSION["ShipType"] = "".((isset($_POST["ShipType"]))?$_POST["ShipType"]:"")  ."";
}
?>





also change the hidden form element code to be consistant:

php:
<input name="shipType" type="hidden" id="Shipping_cost" value="<?php echo((isset($_POST["Shipping_cost"]))?$_POST["Shipping_cost"]:""?>" />



should be:

php:
<input name="ShipType" type="hidden" id="ShipType" value="<?php echo((isset($_POST["ShipType"]))?$_POST["ShipType"]:""?>" />
Sign in to reply to this post

Heckie

Im looking for a similar solution, but maybe in a slightly different way.

I would like to have a drop-down on the 'cart.php' page that inserts the correct shipping price before going to 'checkout.php'.

I would prefer this solution as some of my clients use PayPal Express only.

I have set up a session value called 'Destination' and have a drop-down inside the cart form called 'DestinationChoice'.

There are only 2 choices - UK Mainland and UK Offshore.

I would like the drop-down to update the form once a selection has been made and change the value accordingly.

I can set up the eCart Shipping calculation based on the Session Variable, but I'm not sure how to get the form to POST it in the first place?

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