Hi,

I had found that Street Address 2 label was never appearing (in delivery or billing), even if I put a label in the configuration.

So I found this piece of code in the theme function at the file uc_cart_checkout_pane.inc:

      if (substr($field, -7) == 'street1') {
        $title = uc_get_field_name('street') .':';
      }
      elseif (substr($field, -7) == 'street2') {
        $title = ' ';
      }

That I couldn't understand why it's there. If the needing was to try to have optionally one label (street) for the 2 fields (street1 and street2) for any reason (system admin decides), then the code needs to be reviewed to test if 'street' is not empty (and not to test street1 or street2).

But that's a great module, and I know that I'll use it a lot! Thanks!

CommentFileSizeAuthor
#7 opzioni.png39.75 KBScorpio26

Comments

alpritt’s picture

Version: 5.x-1.5 » 6.x-2.x-dev

Applies to 6.x.2.x too.

For clarity here are some screenshots.

At admin/store/settings/checkout/edit/fields
Only local images are allowed.

At cart/checkout
Only local images are allowed.

So we should either remove the option to customise, or make sure customisations are shown on the form. IMO we should remove the option.

alpritt’s picture

Category: support » bug

It's a usability bug

rszrama’s picture

Hmm... good point. I'll see what I can do here... I wouldn't be against this change as long as I can default the custom name to ''. : )

Also... Skitch ftw!

Vuds’s picture

I'd suggest just that those lines should be suppressed from the code (for my configuration, I had commented them to work normally). And then maybe the 'street' label field could disappear because it'd become useless.

I'd not suggest to take off any of fields that already exists, since for my use case for example I'm having lacking of fields (I'd need to have 2 more fields to work perfectly indeed, but I snipped some code in the payment gateway that I'm working in to have some satisfactory results to receive 2 contents in only one field).

I believe that, beyond my case, for some other countries (or payment gateways), sometimes the address thing should be informed to their systems much more grained than Ubercart can actually support.

rszrama’s picture

Assigned: Unassigned » rszrama
rszrama’s picture

Status: Active » Closed (works as designed)

So, I really think for now I'm not going to make any change here. The address system as a whole needs to be more flexible, and the way it works now covers a large majority of our users. However, I will say that since this is happening in a theme function, you can override it in your theme with a function like the following to not filter out the street address labels:

<?
// Theme the delivery/billing address forms in tables.
function phptemplate_address_pane($form) {
$req = '*';

if (isset($form['copy_address'])) {
$output = drupal_render($form['copy_address']);
}

$output .= '

';

foreach (element_children($form) as $field) {
if (substr($field, 0, 9) == 'delivery_' || substr($field, 0, 8) == 'billing_') {
$title = $form[$field]['#title'] .':';
unset($form[$field]['#title']);
$output .= '

';
}
}
$output .= '

';
if ($form[$field]['#required']) {
$output .= $req;
}
$output .= $title .'
'. drupal_render($form[$field]) .'

';

foreach (element_children($form) as $element) {
$output .= drupal_render($form[$element]);
}

return $output;
}
?>

Not ideal, but it works for now.

Scorpio26’s picture

StatusFileSize
new39.75 KB

Hallo
I have the same promblem.

I Change in uc_cart_checkout_pane.inc:

      if (substr($field, -7) == 'street1') {
        $title = uc_get_field_name('street') .':';
      }
      elseif (substr($field, -7) == 'street2') {
        $title = ' ';
      }

in

      if (substr($field, -7) == 'street1') {
        $title = uc_get_field_name('street1') .':';
      }
      elseif (substr($field, -7) == 'street2') {
        $title = uc_get_field_name('street2') .':';
      }

because I need to show the labels aggigned by administrator in admin/store/settings/checkout/edit/fields.
As show by alpritt, not only the lablel "Custom street address" disappear, but also the label "Street address 1" assigned in the field "Street address 1" is changeg in "Street address".

Thank you

fictionindustries’s picture

#7 worked for me. Now the address label shows like it should!... untill I update my ubercart again ;)
hint hint...

valderama’s picture

seems like this isn't fixed yet in the current version. any reasons for that?

I also applied the changes as in #7 in my code, and it seems to not break something..

best,
walter

mattcasey’s picture

For Drupal 6 Ubercart 2.x-dev I used a combination of the above, I changed the lines but copied the theme function into my template.php, so I can always update Ubercart if needed.

/**
 * Theme the delivery/billing address forms in tables.
 *
 * @ingroup themeable
 * @see
 *   uc_checkout_pane_delivery()
 *   uc_checkout_pane_billing()
 */
function themename_address_pane($form) {
  $output = '';
  $req = '<span class="form-required">*</span>';

  if (isset($form['copy_address'])) {
    $output .= drupal_render($form['copy_address']);
  }

  $output .= '<div class="address-pane-table"><table>';

  foreach (element_children($form) as $field) {
    if (substr($field, 0, 9) == 'delivery_' || substr($field, 0, 8) == 'billing_') {
      $title = $form[$field]['#title'] .':';
      unset($form[$field]['#title']);
      if (substr($field, -7) == 'street1') {
        $title = uc_get_field_name('street1') .':';
      }
      elseif (substr($field, -7) == 'street2') {
        $title = uc_get_field_name('street2') .':';
      }
      $output .= '<tr><td class="field-label">';
      if ($form[$field]['#required']) {
        $output .= $req;
      }
      $output .= $title .'</td><td>'. drupal_render($form[$field]) .'</td></tr>';
    }
  }
  $output .= '</table></div>';

  foreach (element_children($form) as $element) {
    $output .= drupal_render($form[$element]);
  }

  return $output;
}