Non-shippable products error

RachelNY - February 3, 2009 - 19:43
Project:Ubercart Addresses
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:freixas
Status:closed
Description

When my products are not shippable I am getting an extra State/Province field at the bottom of the checkout page, above and to the right of the buttons.

When products are not shippable, it looks like uc_addresses is creating an additional address entry that looks like this:

aid = 11
uid = 5
first_name
last_name
phone
company
street1
street2
city
zone = 43
postal_code
country = 840
address_name
created = 1233689017
modified = 1233689017

When I delete it, either from the edit screen or directly from the database, it comes back after the next order.

It seems to be working ok with shippable products.

Here is what the HTML it generates looks like (select 'options' and 'value' edited out to fit):

<fieldset id="comments-pane" class=" collapsible"><legend>Order comments</legend>
<div class="description">Use this area for special instructions or questions regarding your order.</div>
<div class="form-item" id="edit-panes-comments-comments-wrapper">
<label for="edit-panes-comments-comments">Order comments: </label>
<textarea cols="60" rows="5" name="panes[comments][comments]" id="edit-panes-comments-comments"  class="form-textarea resizable"></textarea>
</div>
</fieldset>
<div class="form-item" id="edit-panes-delivery-delivery-zone-wrapper">
<label for="edit-panes-delivery-delivery-zone">State/Province:
<span class="form-required" title="This field is required.">*</span></label>
<select name="panes[delivery][delivery_zone]" class="form-select required" id="edit-panes-delivery-delivery-zone" >
<option value="">Please select</option>
<option value="1">Alabama</option>
<option value="43" selected="selected">New York</option>
</select>
</div>
<span class="zone-throbber"></span><div id="checkout-form-bottom">
<input type="hidden" name="cart_contents" id="edit-cart-contents" value="edited-for-space"  />
<input type="submit" name="op" id="edit-cancel" value="Cancel"  class="form-submit" />
<input type="submit" name="op" id="edit-continue" value="Review order"  class="form-submit" />

#1

freixas - February 7, 2009 - 03:50
Assigned to:Anonymous» freixas
Status:active» fixed

Fixed.

The code is supposed to skip the delivery address if there isn't one (i.e. none of the products are shippable). I had this covered in one section of the code but not another. Both cases are no covered and the unwanted zone field does not appear.

Look for the fix in the next dev release dated 2/6/09 or later.

Thanks for spotting this.

#2

RachelNY - February 7, 2009 - 16:38

Partially fixed.

The stray field no longer appears on the checkout page, but the stray DB entry is still being created unless I add the following code on line 1257 of my uc_addresses.module:

if ($address->zone != '0') { //EDIT to prevent extra address entry
  db_query("INSERT INTO {uc_addresses} (aid, uid, first_name, last_name, "

Thanks,
Rachel

#3

freixas - February 15, 2009 - 04:59

Ok, here's another attempt to fix this bug. The fix is available in the first dev release date 2/14/09 or later.

One problem was that when the order completed, I was not checking whether the delivery address was needed.

The other problem is that I wasn't using the same check the system uses to determine if the shipping address should be requested. The correct check is

<?php
if  (uc_cart_is_shippable() || !variable_get('uc_cart_delivery_not_shippable', TRUE)) {
?>

After making the fixes, my code seemed to work properly, by the Ubercart orders have an empty shipping address. This generates a warning in the watchdog log about a failure to send email (because there is no recipient).

This appears to be an Ubercart bug: if I disable the uc_addresses module and try the operation, I get the same problem.

#4

freixas - February 15, 2009 - 05:34

#5

System Message - March 1, 2009 - 05:40
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#6

jeeberpow - March 5, 2009 - 22:04
Version:6.x-1.x-dev» 5.x-2.x-dev

This is the same bug for the reported for 6.x (#368675: Non-shippable products error). It exists in 5.x and has not yet been updated.
Summary: the shipping State/Province (zone) field shows up on the checkout page even when the product is non-shippable.
I matched and copied the fixes in your 6.x release for my own installation but am not versed enough to submit a patch - sorry!
I also could not easily compare and update the _uc_addresses_db_add_address function, if that's even necessary (originally commented by RachelNY)

#7

freixas - March 6, 2009 - 01:15
Version:5.x-2.x-dev» 6.x-1.x-dev

Just to keep my head from hurting, let's keep this as a 6.x bug (fixed and closed) and use a new bug for the 5.x release.

And yes, I know the fix needs to be migrated to the 5.x release.

 
 

Drupal is a registered trademark of Dries Buytaert.