close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Saving Shipping choice when multiple options

Thread began 4/10/2012 1:53 pm by Steve | Last modified 6/27/2013 11:49 am by Jason Byrnes | 3705 views | 13 replies |

Steve

Saving Shipping choice when multiple options

Hello,
When you have multiple shipping values is there a plan to then set the Shipping Type selected so the Admin can then make sure they use the chosen shipping type?

For instance:

php:
<form name="checkoutForm"  id="checkoutForm"  action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">


<select name="shipSelect" id="shipSelect" onchange="document.getElementById('checkoutForm').submit()" >
<option value="<?php echo($groundShip); ?><?php if (!(strcmp($groundShip$eCart1->GetShipping()))) {echo "selected=\"selected\"";} ?>>Ground $<?php echo($groundShip); ?></option>
<option value="<?php echo($twoDayAir); ?><?php if (!(strcmp($twoDayAir$eCart1->GetShipping()))) {echo "selected=\"selected\"";} ?>>2nd Day Air $<?php echo($twoDayAir); ?></option>
</select>



If there is not some pre-determined eCart procedures I will be taking the $groundShip and $twoDayAir vars, looking to see which is availble in the $_Post then setting that as a Session value.

Next it looks like the 'eCart Store Details in Database' and eCart Store Summary in Database" lack a field value for accepting the designation of the selected Shipping Type so one of these will need to be manually tweaked to accept the Insert or Update procedures.

Then the Database will need to be adjusted to have a table field that will accept these incoming values.

Is this the correct flow or is there something already in place I am missing?

Thanks in advance!

Sign in to reply to this post

Jason ByrnesWebAssist

you will needt o add a column to the orders table for the ship type, save the selected ship type in a session variable, then update the Store Order Summary behavior to bind the ship type column of the orders table to the ship type session you create.

Sign in to reply to this post

Steve

Originally Said By: Jason Byrnes
  you will needt o add a column to the orders table for the ship type, save the selected ship type in a session variable, then update the Store Order Summary behavior to bind the ship type column of the orders table to the ship type session you create.  




Thanks Jason.

Sign in to reply to this post

Steve

Hello,
Finally getting around to putting the shipping type in place on this cart. The suggested methods were implemented but do not work as the value in the select list is the numeric value returned from the shipper not the visual reference.

<?php echo WA_eCart_DisplayMoney($eCart1, $eCart1->GetShipping()); ?>
<select name="shipSelect" id="shipSelect" onchange="document.getElementById('checkoutForm').submit()" >
<option value="<?php echo($groundShip); ?>" <?php if (!(strcmp($groundShip, $eCart1->GetShipping()))) {echo "selected=\"selected\"";} ?>>Ground $<?php echo($groundShip); ?></option>
<option value="<?php echo($twoDayAir); ?>" <?php if (!(strcmp($twoDayAir, $eCart1->GetShipping()))) {echo "selected=\"selected\"";} ?>>2nd Day Air $<?php echo($twoDayAir); ?></option>
</select>



I have the session value being saved and inserted but how to get the title rather then value from a select list to put in the session?

<?php // added 6_26_13 to save off shipping method

if (!session_id()) session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
$_SESSION["eCartCheckoutForm_shipping_method"] = "".((isset($_POST["shipSelect"]))?$_POST["shipSelect"]:"") ."";
}
?>
Sign in to reply to this post

Jason ByrnesWebAssist

add a hidden element to the form, and add a javascript on change event to the select list to save the label of the select to the hidden element


onChange="document.form1.hiddenfield.value = document.form1. shipSelect[document.form1. shipSelect.selectedIndex].text"

This example assumes the hidden element is named hiddenfield and the form is named form1

add another set session value behavior to store the hidden element in a session:

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


and use the eCartCheckoutForm_shipping_method_label session to store the selected shipping method.

Sign in to reply to this post

Steve

Hmmnnn, I just figured I could use this method :

if (isset($_POST['shipSelect']) && ($_POST['shipSelect']==$groundShip)) {
$_SESSION["eCartCheckoutForm_shipping_method"] = 'Ground';
} elseif (isset($_POST['shipSelect']) && ($_POST['shipSelect']==$twoDayAir)) {
$_SESSION["eCartCheckoutForm_shipping_method"] = '2 Day Air';



I'll test my solution then use yours if it falis. Thanks for the fast reply.

Sign in to reply to this post

Steve

Niether method worked :-(

Using your method I need append an already existing onChange trigger:
(note the form is called "ecart_checkout_form"

<select name="shipSelect" id="shipSelect" onchange="document.getElementById('checkoutForm').submit(); document.ecart_checkout_form.shipping_method.value = document.ecart_checkout_form. shipSelect[document.ecart_checkout_form. shipSelect.selectedIndex].text">




The hidden field is named "shipping_method":

<input type="hidden" name="shipping_method" id="shipping_method" value="<?php echo ((isset($_SESSION["eCartCheckoutForm_shipping_method"]))?$_SESSION["eCartCheckoutForm_shipping_method"]:"") ?>" />




and setting the session is as follows referencing the hidden field name:

php:
if (!session_id()) session_start();

if($_SERVER["REQUEST_METHOD"] == "POST")     {
  $_SESSION["eCartCheckoutForm_shipping_method"] = "".((isset($_POST["shipping_method"]))?$_POST["shipping_method"]:"") ."";
}



I use a print_r ($_SESSION); on the confirm page and only see the hidden value still supporting the numeric cost of the selected shipping.

I'll keep studying this but can not currently see the problem other than the JS that should be getting the label value?

Sign in to reply to this post

Jason ByrnesWebAssist

1) the on change:
onchange="document.getElementById('checkoutForm').submit(); document.ecart_checkout_form.shipping_method.value = document.ecart_checkout_form. shipSelect[document.ecart_checkout_form. shipSelect.selectedIndex].text"

should be reversed:
onchange="document.ecart_checkout_form.shipping_method.value = document.ecart_checkout_form. shipSelect[document.ecart_checkout_form. shipSelect.selectedIndex].text; document.getElementById('checkoutForm').submit(); "

2) The shipping method session should still have the number, the number needs to be passed to the shipping lookup, you need to set another session to capture the label


so you have one session that captures the number that is passed, and another session that is capturing the label.

Sign in to reply to this post

Steve

Message sent

Sign in to reply to this post

Jason ByrnesWebAssist

Originally Said By: Steve
  Message sent  
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...