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?

  • Hi, did you achieve this issues? I need it too. – lpFranz Jul 17 '18 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 Jul 18 '18 at 12:46
  • I quickly looked it up and posted it as answer – FuFu Jul 18 '18 at 13:03
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 ;) )

  • 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 Jul 18 '18 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 Jul 19 '18 at 12:02
  • Hi, I've setted this configuration already, but when we use anonimous (guest) checkout, the DOB field doesn't appear. – lpFranz Jul 19 '18 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 Jul 19 '18 at 13:22

Your Answer

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

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