Pergunta

I cannot get the postcode from Users's billing Address,this is my code, everything works fine except for the postcode, which i'm not able to pull.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

        $customer = $observer->getEvent()->getCustomer();
        $customer_email=$customer->getEmail();
        $first_name= $customer->getFirstname();
        $last_name= $customer->getLastname();
        $taxVat = $customer->getTaxvat();


        //Billing Address variables

        $billingID = $customer->getDefaultBilling();
        $billingAddress = $objectManager->create('Magento\Customer\Model\Address')->load($billingID);
        $billingCompany = $billingAddress->getCompany();
        $billingZipcode = $billingAddress->getPostCode();
        $billingCity = $billingAddress->getCity();
        $billingState = $billingAddress->getRegion();
        $billingStreet = $billingAddress->getStreet();
        $billingStreet1 = $billingStreet[0];
        $billingStreet2 = $billingStreet[1];
        $billingTelephone = $billingAddress->getTelephone();

Greetings!

Foi útil?

Solução

$billingZipcode = $billingAddress->getPostCode();

Should be

$billingZipcode = $billingAddress->getPostcode();

Outras dicas

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$billingAddress = $objectManager->create('Magento\Customer\Model\Address')->load($billingID);

 $billingPostcode = $billingAddress->getPostcode();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top