I have a custom module with a custom section in Checkout Payment Step.
I want to display the xip code of the customer in the custom section ( both customer logged in and logged out case).
I have used the below code
if ($this->customerSession->isLoggedIn()) {
if ($customer) {
$billingAddress = $customer->getDefaultBillingAddress();
if ($billingAddress) {
return $billingAddress->getPostcode();
}
}
} else {
$postCode = $this->checkoutsession->getQuote()->getShippingAddress()->getPostcode();
return $postCode;
}
But in the logged out case, not getting the zip code in the payment step. When I refresh the page, it displays.
Please help.