3

I'm creating an extension which limits the Paymentmethodes in the checkout. For this I have craeted the PlugIn MethodListPlugIn with the Methode afterGetAvailableMethods.

When I try to catch the dob or email in an guest checkout, (with getQuote() (examp. getQuote()->getDob()) of \Magento\Checkout\Model\Session) I just get null.

So my question is: How can I fetch the dob and email of an guest in the checkout?

3
  • Hi, did you achieve this issues? I need it too.
    – lpFranz
    Commented Jul 17, 2018 at 19:15
  • probably, i can't remeber. Do you have the same problem? I can look it up for you, if you need it.
    – FuFu
    Commented Jul 18, 2018 at 12:46
  • I quickly looked it up and posted it as answer
    – FuFu
    Commented Jul 18, 2018 at 13:03

1 Answer 1

1

I solved it this way (I think, not sure if it was this project as I create this question).

public function __construct(
        \Magento\Customer\Model\AddressFactory $customerAddressFactory,
    ) {
        parent::__construct($context);
        $this->_customerAddressFactory = $customerAddressFactory;
}
public function prepareAddressDataById($addressId)
{
    $address = $this->_customerAddressFactory->create()->load($addressId);
    $addressData = $address->toArray();
    $addressData['dob'] = $address->getCustomer()->getDob();

    return $this->prepareAddressData($addressData);
}

( I quickly copied this out of a pretty big file and removed anything not important. So I don't know if this is plug and play ;) )

5
  • Thanks for sharing, but where guests fill up the DOB field? In my case, on guest checkout page, the DOB field isn't there, even configured to. Did you faced that too? Thankyou again.
    – lpFranz
    Commented Jul 18, 2018 at 13:20
  • magento.stackexchange.com/questions/154587/… You can configure it in the Backend, as described in the Link: Configuration → Customers → Cusotmers Configuration → Name and Address Options
    – FuFu
    Commented Jul 19, 2018 at 12:02
  • Hi, I've setted this configuration already, but when we use anonimous (guest) checkout, the DOB field doesn't appear.
    – lpFranz
    Commented Jul 19, 2018 at 12:11
  • Then you may should open a Question for it by your self. I don't know what the problem could be, I'm not an expert.
    – FuFu
    Commented Jul 19, 2018 at 13:22
  • magento.stackexchange.com/questions/234889/…
    – lpFranz
    Commented Jul 19, 2018 at 13:27

Your Answer

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

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