0

I´m trying to get Customer data and insert it into some hidden inputs on a form. It checks if there is a customer logged in, but the data is from another customer, and it doesn't change even if I log in with other accounts. Cacheable is set on false, but I have to set FPC on the admin panel in order to make this work.

public function isCustomerLoggedIn(){
    $this->customer = $this->_customerSession->create();

    return $this->customer->isLoggedIn();
}
public function getCustomerInfo(){
    $this->address = array();

    $id = $this->customer->getCustomer()->getId();
    $this->customerInfo = $this->customerRepository->getById($id);
    $this->firstName = $this->customerInfo->getFirstname();
    $this->lastName = $this->customerInfo->getLastname();
    $this->email = $this->customerInfo->getEmail();
    $this->companyName = $this->customerInfo->getCustomAttribute('company');
    $billingAddress=$this->addressRepository->getById($this->customerInfo->getDefaultBilling());
    $this->address = $billingAddress->getStreet();
    $this->city = $billingAddress->getCity();
    $this->state = $billingAddress->getRegionId();
    $this->zip = $billingAddress->getPostcode();
    $this->phone = $billingAddress->getTelephone();
}

Is there something wrong in the layout?

<block name="form" class="Transom\Test2\Block\SellEquipment" template="Transom_Test2::form.phtml" cacheable="false"/>
| improve this question | | | | |
  • please explain briefly, not cleared.. – Manjunath Oct 2 '19 at 6:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.