Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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.
Comment | File | Size | Author |
---|---|---|---|
#5 | undefined_index_last-name_token-1432532-2.patch | 1.93 KB | SilviuChingaru |
#1 | undefined_index_last-name_token-1432532-1.patch | 0 bytes | SilviuChingaru |
Comments
Comment #1
SilviuChingaru CreditAttribution: SilviuChingaru commentedThis patch solves the error.
Comment #2
SilviuChingaru CreditAttribution: SilviuChingaru commentedComment #3
longwavePlease reupload the patch, it is an empty file.
Comment #4
SilviuChingaru CreditAttribution: SilviuChingaru commentedComment #5
SilviuChingaru CreditAttribution: SilviuChingaru commentedThis patch solves the error. Sorry for empty patch (I forgot that I hard reseted my git :-) ).
Comment #6
SilviuChingaru CreditAttribution: SilviuChingaru commentedComment #7
longwaveCommitted #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!
Comment #8
SilviuChingaru CreditAttribution: SilviuChingaru commentedYou'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.