15 replies [Last post]
mimetic2's picture
Offline
Joined: 08/07/2007
Juice: 478
Was this information Helpful?

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

yoeff's picture
Offline
Joined: 07/02/2008
Juice: 40
Me too!

I'm having the same problem. Please help.

Thanks

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Estimated Shipping on Cart: "undefined: Missing value for Co

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.

mcneelycorp's picture
Offline
Joined: 10/26/2007
Juice: 72
Re: Re: Estimated Shipping on Cart: "undefined: Missing value fo

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

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: Re: Estimated Shipping on Cart: "undefined: Missing valu

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.

mcneelycorp's picture
Offline
Joined: 10/26/2007
Juice: 72
Re: Re: Re: Re: Estimated Shipping on Cart: "undefined: Missing

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

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: Re: Estimated Shipping on Cart: "undefined: Miss

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

thill's picture
Offline
Joined: 01/25/2008
Juice: 815
Re: Re: Re: Re: Re: Re: Estimated Shipping on Cart: "undefined:

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.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: Re: Re: Re: Re: Re: Estimated Shipping on Cart: "undefin

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

mcneelycorp's picture
Offline
Joined: 10/26/2007
Juice: 72
Re: Re: Re: Re: Re: Re: Re: Re: Estimated Shipping on Cart: "und

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

mcneelycorp's picture
Offline
Joined: 10/26/2007
Juice: 72
Re: Re: Re: Re: Re: Re: Re: Re: Estimated Shipping on Cart: "und

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

simonyost's picture
Offline
Joined: 12/21/2007
Juice: 25
Thank you!

Thanks for the fix. Huge help!

ron_s's picture
Offline
Joined: 09/11/2008
Juice: 173
Re: Estimated Shipping on Cart: "undefined: Missing value for Co

I'd like to make a recommendation about shipping quotes on the Shopping Cart page (/cart). Estimated shipping quote needs to be removed if no items in the cart are shippable.

There is already functionality on the Checkout Settings page (admin/store/settings/checkout/edit) to do this by selecting the "Hide shipping information when possible for carts with no shippable items." This same functionality should be in place for the Shipping Quotes module.

Also the quote should be smart enough to provide an estimated shipping amount based on only those items that are shippable.

ron_s's picture
Offline
Joined: 09/11/2008
Juice: 173
Re: Re: Estimated Shipping on Cart: "undefined: Missing value fo

Ok, I think I may have already found a way to fix the problem of the estimated shipping quote form being displayed when none of the items in the cart are shippable. I am implementing this solution in Ubercart 5.x-1.7. I needed to make an edit to the uc_cart_pane_quotes function in the uc_quote.module file. Around line 994 is the following block of code:

$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);
$form['delivery_postal_code'] = uc_textfield(uc_get_field_name('postal_code'), '', TRUE, NULL, 10, 10);
$form['quote_method'] = array('#type' => 'hidden',
   '#value' => key($method_choices),
);
$form['get_quote'] = array('#type' => 'button',
   '#value' => t('Calculate'),
);
$form['page'] = array('#type' => 'hidden',
   '#value' => 'cart',
);
$form['uid'] = array('#type' => 'hidden',
   '#value' => $user->uid,
);
$form['quote'] = array('#type' => 'markup',
   '#value' => '<div id="quote"></div>',
);

The issue is there needs to be some conditional logic wrapped around this form to display it if there are any shippable items in the cart, and to remove it if there are none. Therefore, edit the code above to include the following:

foreach(uc_cart_get_contents() as $product) {
   if(uc_cart_product_is_shippable($product)) {
      $ship = TRUE;
      break;
   } else {
      $ship = FALSE;
   }

if($ship) {
   $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);
   $form['delivery_postal_code'] = uc_textfield(uc_get_field_name('postal_code'), '', TRUE, NULL, 10, 10);
   $form['quote_method'] = array('#type' => 'hidden',
      '#value' => key($method_choices),
   );
   $form['get_quote'] = array('#type' => 'button',
      '#value' => t('Calculate'),
   );
   $form['page'] = array('#type' => 'hidden',
      '#value' => 'cart',
   );
   $form['uid'] = array('#type' => 'hidden',
      '#value' => $user->uid,
   );
   $form['quote'] = array('#type' => 'markup',
      '#value' => '<div id="quote"></div>',
   );
}

I would have thought I could make this edit in template.php using the theme_uc_cart_pane_quotes function. However for some reason putting the conditional logic here did not stop the form from being displayed. It did get rid of the "Estimated shipping cost:" DIV that is shown. So I added the following in template.php:

function mytheme_uc_cart_pane_quotes($form) {
   foreach(uc_cart_get_contents() as $product) {
      if(uc_cart_product_is_shippable($product)) {
         $ship = TRUE;
         break;
      } else {
         $ship = FALSE;
      }
   }
   if($ship) {
      $output = '<div class="solid-border">';
      $output .= '<strong>'. t('Estimated shipping cost:') .'</strong>';
      $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>';
   } else {
      $output = '';
   }
   return $output;
}

Well there you go ... I think that should work to stop the shipping quote form from being displayed if no items in the cart are shippable.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: Re: Estimated Shipping on Cart: "undefined: Missing valu

Instead of putting code in two different places, it's better to prevent the pane from being loaded at all. That happens in uc_quote_cart_pane(), so I've made a patch that moves the "pane enabled" check from the pane form to the pane hook.

AttachmentSize
cart_shipping_pane-d6.patch 1.02 KB
cart_shipping_pane-d5.patch 1.02 KB
ron_s's picture
Offline
Joined: 09/11/2008
Juice: 173
Re: Re: Re: Re: Estimated Shipping on Cart: "undefined: Missing

Thanks for the patch Lyle. Works well... much appreciated.