For the record, I am utterly unable to reproduce this bug on any browser or system, yet I've received several screenshots like the one attached, so I know it is occurring. Basically, the checkout form requires delivery information but does not provide the required form fields for the user to complete. The products are indeed shippable and as stated, the forms work fine on any environment I use.

The screenshot is attached and if anyone wants to try themselves, they can visit http://www.nala.ie/publications and try to purchase something.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Island Usurper’s picture

Category: bug » support
Status: Active » Fixed

I don't see a screenshot, but that site seems to have all its fields on the checkout screen. If it still comes up, make sure the delivery information checkout pane is enabled in the Checkout settings. And then reprimand whoever turned it off.

Dr Jay’s picture

FileSize
24.01 KB

Right-on, I must have missed that attachment. Here it is. Unfortunately, this comes from the person I reprimanded! As I said, it all works for me as well (and I've tried multiple machines/browsers), so it's just frustrating that I can't seem to find a common denominator among those who are experiencing it. Either way, I appreciate you trying.

js’s picture

I have the same problem.

The "Delivery Information" is enabled here:
/admin/store/settings/checkout/edit/panes. I tried toggling it on and off.

$form['panes']['delivery'] is missing in dsm()

I am not sure what I did or how to fix it. I would appreciate knowing what to check in the database.

Thanks, Jerry

Dr Jay’s picture

Status: Fixed » Postponed (maintainer needs more info)

Hopefully you won't mind me changing the status on this. Even though I can't duplicate the problem, it is definitely happening (based on the complaints/screenshots I'm getting) and it appears from #3 that I'm not alone.

TR’s picture

Are your products marked shippable? Delivery information won't show unless you have shippable items in your cart.

Dr Jay’s picture

Thanks TR - they are indeed.

TR’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Marking this as cannot reproduce. If you can provide further information that might help us reproduce this, feel free to re-open the issue.

adamdicarlo’s picture

Version: 6.x-2.3 » 6.x-2.4
FileSize
545 bytes

I'm experiencing this issue too. I've been stepping through the code and something really doesn't make sense here.

uc_cart_is_shippable() calls uc_cart_get_contents(), which loads product nodes like this:

      $product = node_load($item->nid);
      $item->cost = $product->cost;
      $item->price = $product->sell_price;
      $item->weight = $product->weight;
      $item->data = unserialize($item->data);
      $item->module = $item->data['module'];
      $item->model = $product->model;

it ditches the node ($product). The "shippable" flag is present at $product->shippable (its value is "1"). But it is not present in the item's data array.

uc_cart_is_shippable() receives the array of $items back from uc_cart_get_contents(). It has no way of accessing the "shippable" flag -- it's simply gone.

So, uc_cart_is_shippable() iterates through its array of items (with no shippable flags), and calls uc_cart_product_is_shippable() on each:

function uc_cart_product_is_shippable($product) {
  // Return FALSE if the product form specifies this as not shippable.
  if ($product->data['shippable'] == FALSE) {
    return FALSE;
  }
  ...

Because $product->data['shippable'] isn't even SET, and == (rather than ===) is used, the if statement evaluates to TRUE, and FALSE gets returned.

So, the code after that (in uc_cart_product_is_shippable()) is never reached, and thus no other modules have a chance to declare the product is shippable. BLEH.

Here's my suggestion, in a patch (rolled from 2.4).

adamdicarlo’s picture

Category: support » bug
Status: Closed (cannot reproduce) » Needs review
adamdicarlo’s picture

Whoops, rolled that wrong. Trying again.

To be clear, this patch solves the problem for me. Ubercart checks whether there are any shippable items when "Hide the delivery info pane if there are no shippable items" option is on, so the problem was breakage when trying to determine if there are shippable items.

I'll try to do more testing. Perhaps one has to create a product, save it, THEN check "Product and its derivatives are shippable," and save again, in order for $data['shippable'] not to be set? Not sure.

TR’s picture

Status: Needs review » Postponed (maintainer needs more info)

I can't verify the patch fixes the problem unless I can reproduce the problem. See #7. Please provide the steps needed to cause the error, then I can test your patch.

adamdicarlo’s picture

Status: Active » Postponed (maintainer needs more info)

Tracked this nasty bug down. This problem occurs when you add items to the cart yourself using uc_cart_add_item(), without calling module_invoke_all('add_to_cart_data', ...).

This means the uc_cart_add_item() API is extremely nasty...this is one hell of a gotcha.

Have a look at these functions from uc_product.module:

/**
 * @see uc_product_add_to_cart_form()
 */
function uc_product_add_to_cart_form_submit($form, &$form_state) {
  $form_state['redirect'] = uc_cart_add_item($form_state['values']['nid'], $form_state['values']['qty'],  module_invoke_all('add_to_cart_data', $form_state['values']), NULL, variable_get('uc_cart_add_item_msg', TRUE));
}

/**
 * Implementation of hook_add_to_cart_data().
 */
function uc_product_add_to_cart_data($form_values) {
  $node = node_load($form_values['nid']);
  return array('shippable' => $node->shippable);
}

So the problem is that if you simply call uc_cart_add_item(), you're screwed. You have to replicate the pattern shown in uc_product_add_to_cart_form_submit() so that the 'shippable' entry gets added to the $item['data'] array.

This warrants a lengthy "WARNING" comment in the header of uc_cart_add_item()....

adamdicarlo’s picture

Status: Postponed (maintainer needs more info) » Active
Saoirse1916’s picture

Status: Postponed (maintainer needs more info) » Active

I've run into this problem as well as I'm using a custom variant of the UC_Event_Registration module which uses uc_cart_add_item(). Based on a thread over at Ubercart (http://www.ubercart.org/forum/support/11851/delivery_information_not_sho...) I've come up with the following modification which, to my eye, should work but doesn't.

<?php
//get ubercart attributes
$attributes = array();
if (isset($form_state['uc_membership_attributes'])) {
  $att_build = array();
  foreach($form_state['uc_membership_attributes'] as $key => $value){
	$att_build['aid'][] = $key;
	$att_build['oid'][] = $value;
  }
  //get results into the expected format
  $attributes = array_combine($att_build['aid'], $att_build['oid']);
}

//add it to the cart
//$data = array('nid' => $node->nid);
$data = array('nid' => $node->nid, 'attributes' => $attributes);
dsm($data);
uc_cart_add_item($node->nid, $uc_membership_quantity, module_invoke_all('add_to_cart_data', $data));
//uc_cart_add_item($node->nid, $uc_membership_quantity, array('attributes' => $attributes, 'uc_membership' => array('sid' => $sid_value)));

//redirect to checkout
$form_state['redirect'] = 'cart/checkout';
?>

My dsm($data); indicates that I get what appears to be the appropriate result, with the nid and two attributes in an array, but I still get no delivery information. If I remove the attributes from the $data array I get delivery information but no attributes, of course.

longwave’s picture

See #613498-46: uc_product_add_to_cart_data does not respect non-shippable attributes for a full diagnosis of this problem, and a patch that (hopefully) fixes it. Reviews and testing are more than welcome!

Leaving this open for now, as this issue is subtly different, but I think the fix is the same.

longwave’s picture

Status: Active » Closed (duplicate)

Duplicate of issue linked in #15