2

I have a custom module with a custom section in Checkout Payment Step.

enter image description here

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.

2
  • You can try using javascript functions to set the payment method area zip code. Use the javascript function to get the zip code field value from shipping area html and assign this value to the payment method area, zip code html element.
    – MGento
    Feb 18, 2019 at 5:41
  • @MGento I want to get it in my config provider
    – Vindhuja
    Feb 18, 2019 at 6:18

1 Answer 1

0

jQuery Solution

$( "button[data-role='opc-continue']" ).on( "click", function() {

        $(".yourclass").html($("input[name='postcode']").val());
});

1
  • I want to get the value in my config provider.
    – Vindhuja
    Feb 18, 2019 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.