Estimated Shipping on Cart: "undefined: Missing value for Country.?

Posts: 141
Joined: 08/07/2007

Hello,

I currently have "estimate shipping costs" on my cart page. When I type in a zip code it gives me the error:

undefined: Missing value for country"

Any ideas?

Thanks,

Aaron

Posts: 9
Joined: 07/02/2008

I'm having the same problem. Please help.

Thanks

Posts: 2357
Joined: 08/07/2007
AdministratoreLiTe!

I'm going to do away with getting quotes on the cart page. Since every shipping method has different requirements for getting a quote, the only way to make the quote form generic enough is for the customer to put in their entire address. And I see no reason for them to do that on the cart page and the checkout page.

My recommendation is to not use the Cart Quotes pane, because it will be gone in the 2.x version.

Posts: 33
Joined: 10/26/2007

I don't think you should do away with it. Almost every major site out there has shipping estimator on the cart page. Since almost everyone has shopped online at a major site, they will expect that and it does effect order completion rate.

OSC uses zip code and country last time I looked (5+ years ago). Aren't most shippers happy with this alone - meaning no need for a full address?

--

===
Elvis McNeely
Blogging about Drupal: http://www.elvisblogs.org/drupal

Posts: 2357
Joined: 08/07/2007
AdministratoreLiTe!

The USPS module can use the ZIP code or the country, but UPS needs the state as well. I don't have any kind of table that relates ZIP codes to states, so quotes on the cart page are broken for UPS quotes. I'm not sure what the FedEx module needs.

I guess there really just needs to be better error handling.

Posts: 33
Joined: 10/26/2007

Hi Lyle, I found an easy fix to this problem. With the following you should get quotes from all US based shippers. I am using this solution at http://iphonegear.com which uses USPS Intl and UPS for the US.

Inside uc_quote within function uc_cart_pane_quotes():

Before:

<?php
$form
['delivery_postal_code'] = uc_textfield(uc_get_field_name('postal_code'), '', true, NULL, 10, 10);
?>

Add the following:

<?php
    $form
['delivery_country'] = uc_country_select(uc_get_field_name('country'), uc_store_default_country(), NULL, 'name', TRUE);
   
$country_id = isset($_POST['delivery_country']) ? intval($_POST['delivery_country']) : uc_store_default_country();
   
$form['delivery_zone'] = uc_zone_select(uc_get_field_name('zone'), null, null, $country_id, 'name', true);
?>

One more change is needed - overriding function theme_uc_cart_pane_quotes(). Instead of making this change in the uc_quote module, I took it to the theme template file. Here is what I have in my template file:

<?php
function themename_uc_cart_pane_quotes($form) {
   
$output = '<div class="solid-border">';
   
$output .= '<h3>'. t('Calculate Shipping Cost:') .'</h3>';
   
$output .= drupal_render($form['delivery_country']);
   
$output .= drupal_render($form['delivery_zone']);
   
$output .= drupal_render($form['delivery_postal_code']);
   
$output .= drupal_render($form['get_quote']);
   
$output .= drupal_render($form);
   
$output .= '</div>';

  return
$output;
}
?>

All the ajax remains intact as well as css. You could take this a step further and look to see which shipping modules are installed and if they require those fields. If not then don't provide them on the uc_pane_cart_quote(). Or, have a setting in admin/store/settings/quotes to make those extra fields available and/or required.

This is a pretty easy fix. It would be nice to see uc_cart_pane_quote() "not" ditched (as I have read on uc) and to see something like this fix in the next uc release Smiling

Cheers

--

===
Elvis McNeely
Blogging about Drupal: http://www.elvisblogs.org/drupal

Posts: 5625
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

@Lyle, +1 to keeping it in if the fix is this simple. Smiling

Posts: 226
Joined: 01/25/2008
Bug FinderBrain StormerGetting busy with the Ubercode.

I agree, the ability to know shipping cost before you enter all your information in is huge. It is in the top five for shopping cart usability in most studies I have read.

Posts: 2357
Joined: 08/07/2007
AdministratoreLiTe!

All right, you've all convinced me. Elvis's changes have been added in to both branches.

Posts: 33
Joined: 10/26/2007

Thanks Lyle. I do have a few requests along with the initial suggestions for shipping quotes module. I am not sure if this should be done within each shipping module or within shipping quotes.

(1) If you are using USPS Intl, there is no need for the zip code. I could be wrong but I don't think there is a need for the zone either. I assume this can be taken care of with jquery...

(2) If user fills out the fields, have those fields saved in sessions or another method. This is a time saver for those who add one item then check the shipping costs. Find another item and again check the shipping costs.

(3) If the user has already filled out the shipping quote fields, if user modifies quantity or removes an item, shipping quotes gets estimate on page reload.

Those are three things I think would bring more value to shipping quotes. I am not a jquery person, or I would tackle (1) and (3). For (2), I don't mind helping out but I was thinking there were session changes from D5 to D6. I am not up to date with D6 standards yet.

--

===
Elvis McNeely
Blogging about Drupal: http://www.elvisblogs.org/drupal

Posts: 33
Joined: 10/26/2007

Hey Lyle, I just spotted another shipping quote issue, I think. I have fedex installed. If you have one product shipping from the store address and another product shipping from the "manufacturer" address, shipping quotes is not showing the combined price of both packages / shipments within each offered rate. But, the xml result is showing the rates appropriately (one combined rate from two package from two different locations shipping to the same address). I assume this is a uc_quote issue, I have not tested it on ups or usps to confirm.

--

===
Elvis McNeely
Blogging about Drupal: http://www.elvisblogs.org/drupal

Posts: 7
Joined: 12/21/2007

Thanks for the fix. Huge help!