PDA

View Full Version : Show the type of shipping option instead of the number


robert329616
05-01-2009, 12:20 PM
Hello.

I am now adding multiple shipping options. I followed a solution (see below) that was posted in a previous thread which worked perfectly. On the confirmation page I would like to have Shipping: Shipping type (Ground etc) for the customer to see.
I then added the following code to the confirm.php page:
<td class="eC_SummaryLabel">Shipping: <?php echo((isset($_POST["shipping_options"]))?$_POST["shipping_options"]:"") ?></td>
This shows as; Shipping: 03 (for ground). Is there a way to actually post as Ground instead of 03?

Here is the solution I followed:
On the checkout page in the shipping part of the form you will need to add a new select list. The name does not matter so much as the options and values in it. After the select list is in place use these for the options:
<option value="01">Next Day Air</option>
<option value="02">2nd Day Air</option>
<option value="03">Ground</option>
<option value="07">Worldwide Express</option>
<option value="08">Worldwide Expedited</option>
<option value="11">Standard</option>
<option value="12">3 Day Select</option>
<option value="13">Next Day Air Saver</option>
<option value="14">Next Day Air Early AM</option>
<option value="54">Worldwide Express Plus</option>
<option value="59">2nd Day Air AM</option>
<option value="65">Express Saver</option>
Once this is in place you will need to edit the UPS shipping server behavior that is on the confirm page. In here you will use the lightning bolt for the service type and choose this new select list that you put in the checkout form.

You may also need to know...
On your confirm page you may need to go to Bindings > Form Data and select your checkout page to get the form bindings available on this page. After you do this you should see the form from the checkout page, on my confirm page it is eCart_checkout_form.

Thanks!

Regards,
Rob

Ray Borduin
05-01-2009, 12:32 PM
There is no way to get it to post as Ground instead of 03 without breaking it. Your shipping provider needs it to say 03 to work right.

Your options are to either move the text to a hidden form element so you can have both, or to add them to a database table so you can look the text up based on the number, or to use a series of if statement to set the correct value into a session variable.

robert329616
05-01-2009, 12:53 PM
OK, thanks Ray!

Regards,
Rob

robert329616
05-04-2009, 01:12 PM
Ray,

I have tried for the last few days to figure out how to create the hidden form element (from checkout.php) so I can show shipping: "ground" in the summary (confirm.php) instead of the number. I am also trying to show it in the hidden form (freight) so I can pass that through to Authorize.net as what type of shipping should be used.

Is there a solution recipe I could follow?

Thanks for your help.

Regards,
Rob

Ray Borduin
05-05-2009, 03:20 PM
not sure if there is a solution recipe... try:

<input type="hidden" name="shipTypeText" id="shipTypeText" value="Ground">
<select name="shipType" onChange="document.getElementById("shipTypeText").value = this.options[this.selectedIndex].text;">
<option value="01">Next Day Air</option>
<option value="02">2nd Day Air</option>
<option value="03" selected>Ground</option>
<option value="07">Worldwide Express</option>
<option value="08">Worldwide Expedited</option>
<option value="11">Standard</option>
<option value="12">3 Day Select</option>
<option value="13">Next Day Air Saver</option>
<option value="14">Next Day Air Early AM</option>
<option value="54">Worldwide Express Plus</option>
<option value="59">2nd Day Air AM</option>
<option value="65">Express Saver</option>

robert329616
05-06-2009, 06:18 AM
Ray,

Thanks for the help.

I added the code to my page:

<th>Please select:</th>
<td>
<input type="hidden" name="shipTypeText" id="shipTypeText" value="Ground">
<select name="shipType" onChange="document.getElementById("shipTypeText"). value = this.options[this.selectedIndex].text;">
<option value="01">Next Day Air</option>
<option value="02">2nd Day Air</option>
<option value="03" selected>Ground</option>
<option value="07">Worldwide Express</option>
<option value="08">Worldwide Expedited</option>
<option value="11">Standard</option>
<option value="12">3 Day Select</option>
<option value="13">Next Day Air Saver</option>
<option value="14">Next Day Air Early AM</option>
<option value="54">Worldwide Express Plus</option>
<option value="59">2nd Day Air AM</option>
<option value="65">Express Saver</option>
</select></td>

I receive the following error when I check out (shipping quote):
Missing/Illegal Service/Code.

Is there something I am missing?

Thanks again for your help.

Regards,
Rob

Ray Borduin
05-06-2009, 09:17 AM
I used the wrong form element name.

Find and replace "shipType" with: "shipping_options", since that was the name of the form element originally... or vice versa to use the form element name I used. The problem is it is out of synch.

robert329616
05-06-2009, 01:08 PM
Ray,

That worked, I am now able to get the quote and it shows ground. I have a problem that when I select another shipping option the price changes but it still says ground.

I apologize, I am having a hard time getting my mind around this one. Do I need to create a hidden field for each shipping option?

Thanks.

Rob

robert329616
05-07-2009, 09:24 AM
Ray,

I was trying to google the code. Do I need a Java Script in the page to make this work?
Or should it work as is with maybe adding more hidde fields?

Thanks for all your help with this.

Regards,
Rob

robert329616
05-07-2009, 12:48 PM
Ray,

I called out to a friend who is good with javascript and came up with this solution:

JS:
<script type="text/javascript">
function setPrice(selObj){
document.forms['ecart_checkout_form'].price.value = selObj.options[selObj.options.selectedIndex].value;
document.forms['ecart_checkout_form'].pricetext.value = selObj.options[selObj.options.selectedIndex].text;
}
</script>

Form:
<select name="shipping_options" onchange='javascript: setPrice(this);'>
<option value=''>Select an option</option>
<option value="01">Next Day Air</option>
<option value="02">2nd Day Air</option>
<option value="03" selected="selected">Ground</option>
<option value="07">Worldwide Express</option>
<option value="08">Worldwide Expedited</option>
<option value="11">Standard</option>
<option value="12">3 Day Select</option>
<option value="13">Next Day Air Saver</option>
<option value="14">Next Day Air Early AM</option>
<option value="54">Worldwide Express Plus</option>
<option value="59">2nd Day Air AM</option>
<option value="65">Express Saver</option>
</select>
<input name="price" type="hidden" value="03" />
<input name="pricetext" type="hidden" value="Ground" />

Thanks again for all your help! This forum is great.

Regards,
Rob