[4.1.x.x] Checkout default address not loaded
Author: tongo-angelovCreated Sep 27, 2026Updated Sep 28, 2026
What version of OpenCart are you reporting this for? 4.1.x.x
Describe the bug Even if user already has default address set in profile, its not loaded by default on checkout page
To Reproduce Steps to reproduce the behavior:
- Create new user
- Add default address
- Add any product to cart and go to checkout
Expected behavior Default address should be selected in dropdown
Screenshots / Screen recordings
Server / Test environment (please complete the following information):
- Ubuntu Server
- PHP v8.3
- Apache/2.4.58
Additional context We need to set address_id in session to default's address_id if none was set, this way if user changes dropdown value and goes back to checkout the new address is shown instead of default
// Shipping Address
$this->load->model('account/address');
$data['addresses'] = $this->model_account_address->getAddresses($this->customer->getId());
// Check if user has set default address if none is found in session
if (!isset($this->session->data['shipping_address']['address_id'])) {
$address_id = $this->customer->getAddressId();
if ($address_id) {
$address_info = $this->model_account_address->getAddress($this->customer->getId(), $address_id);
if ($address_info) {
$this->session->data['shipping_address'] = $address_info;
}
}
}
if (isset($this->session->data['shipping_address']['address_id'])) {
$data['address_id'] = $this->session->data['shipping_address']['address_id'];
} else {
$data['address_id'] = 0;
}Same issue exists in payment_address
// Payment Address
$this->load->model('account/address');
$data['addresses'] = $this->model_account_address->getAddresses($this->customer->getId());
// Check if user has set default address if none is found in session
if (!isset($this->session->data['payment_address']['address_id'])) {
$address_id = $this->customer->getAddressId();
if ($address_id) {
$address_info = $this->model_account_address->getAddress($this->customer->getId(), $address_id);
if ($address_info) {
$this->session->data['payment_address'] = $address_info;
}
}
}
if (isset($this->session->data['payment_address']['address_id'])) {
$data['address_id'] = $this->session->data['payment_address']['address_id'];
} else {
$data['address_id'] = 0;
}Source: opencart/opencart