If a customer changes the address at checkout_shipping_address.php, it works fine, but if a customer changes the address at checkout_payment_address.php, it throws a fatal error.
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Text::input() must be of the type string, null given, called in ... includes/modules/customer_data/cd_firstname.php on line 102 and defined in ... includes/system/versioned/1.0.8.2/text.php:34
The offending line in checkout_payment_address.php is:
Code: Select all
$customer_details = $customer_data->process($customer_data->get_fields_for_page('address_book'));
The same line in checkout_shipping_address.php is fine.
The reason the error is showing up in cd_firstname.php is because I already added (string) to the relevant places in cd_country.php and cd_company.php which forced the null to become a string before being passed to the Text::input() function.
The problem was actually in line 54 of templates/default/includes/pages/checkout_payment_address.php where the value given was "submit" rather than "select." Change that to "select" and the issue disappears.
The checkout_shipping_address.php template adds that hidden input element right after the form tag, and does it correctly. Making the two templates more like each other in the next release might be a good idea, or else line 54 could be permanently changed in just the checkout_payment_address.php template.
Additionally, ./checkout_payment_address.php itself must be made more like ./checkout_shipping_address.php
Code: Select all
} elseif (isset($_POST['address'])) {
// process the selected billing destination
$reset_payment = isset($_SESSION['billto']) && ($_SESSION['billto'] != $_POST['address']) && isset($_SESSION['payment']);
$_SESSION['billto'] = $_POST['address'];
if ($customer->fetch_to_address($_SESSION['billto'])) {
if ($reset_payment) {
unset($_SESSION['payment']);
}
Href::redirect($Linker->build('checkout_payment.php'));
} else {
unset($_SESSION['billto']);
}
}
}
should be changed to:
Code: Select all
}
} elseif (isset($_POST['address']) && Form::validate_action_is('select')) {
// process the selected billing destination
$reset_payment = isset($_SESSION['billto']) && ($_SESSION['billto'] != $_POST['address']) && isset($_SESSION['payment']);
$_SESSION['billto'] = $_POST['address'];
if ($customer->fetch_to_address($_SESSION['billto'])) {
if ($reset_payment) {
unset($_SESSION['payment']);
}
Href::redirect($Linker->build('checkout_payment.php'));
} else {
unset($_SESSION['billto']);
}
}