At the end of checkout we got this error:
Notice: Undefined index: last-name în uc_order_tokens() (lie 248 din /[site_path]/modules/ubercart/uc_order/uc_order.tokens.inc).
The problem seems to be in file uc_order.token.inc at hook_tokens:

function uc_order_tokens($type, $tokens, $data = array(), $options = array()) {
...
        case 'first-name':
        case 'last-name':
          if (variable_get('uc_customer_list_address', 'billing') == 'shipping') {
            $replacements[$tokens['first-name']] = $sanitize ? check_plain($order->delivery_first_name) : $order->delivery_first_name;
            $replacements[$tokens['last-name']] = $sanitize ? check_plain($order->delivery_last_name) : $order->delivery_last_name;
          }
          else {
            $replacements[$tokens['first-name']] = $sanitize ? check_plain($order->billing_first_name) : $order->billing_first_name;
            $replacements[$tokens['last-name']] = $sanitize ? check_plain($order->billing_last_name) : $order->billing_last_name;
          }
          break;
...
}

If we modify it to something like this is working fine (no error notice):

function uc_order_tokens($type, $tokens, $data = array(), $options = array()) {
...
case 'first-name':
          if (variable_get('uc_customer_list_address', 'billing') == 'shipping') {
            $replacements[$tokens['first-name']] = $sanitize ? check_plain($order->delivery_first_name) : $order->delivery_first_name;
          }
          else {
            $replacements[$tokens['first-name']] = $sanitize ? check_plain($order->billing_first_name) : $order->billing_first_name;
          }
          break;
        case 'last-name':
          if (variable_get('uc_customer_list_address', 'billing') == 'shipping') {
            $replacements[$tokens['last-name']] = $sanitize ? check_plain($order->delivery_last_name) : $order->delivery_last_name;
          }
          else {
            $replacements[$tokens['last-name']] = $sanitize ? check_plain($order->billing_last_name) : $order->billing_last_name;
          }
          break;
...
}

So I think the problem is that $tokens['last-name'] is not passed yet to function uc_order_tokens when $tokens['first-name'] is passed.

Patch will follow.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SilviuChingaru’s picture

This patch solves the error.

SilviuChingaru’s picture

Status: Active » Needs review
longwave’s picture

Status: Needs review » Needs work

Please reupload the patch, it is an empty file.

SilviuChingaru’s picture

Status: Needs work » Active
SilviuChingaru’s picture

This patch solves the error. Sorry for empty patch (I forgot that I hard reseted my git :-) ).

SilviuChingaru’s picture

Status: Active » Needs review
longwave’s picture

Status: Needs review » Fixed

Committed #5 without the first two whitespace changes, and using $original in the same way as the rest of the code in the function. Thanks for the patch!

SilviuChingaru’s picture

You're welcome, thank you for great work. I'll do all I can to help you guys on this great project. I'm using latest stable build, 3.0, on a production site and if I'll find a solution for #1413372: Admin order shipping method not set and order data reset when shipping quote applied to order this is rock solid and suitable for any production site. Thanks again.

Status: Fixed » Closed (fixed)

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