0

I have this function: if ($ order-> getData ('customer_email') == '[email protected]')

I do not want to put a specific email but emails ending in '@marketplace.amazon.it'

How to proceed ? I tried if ($ order-> getData ('customer_email') == '@marketplace.amazon.it')

Thanks for your help

1 Answer 1

0
$customerEmail = $order->getData('customer_email');
if (preg_match("/@marketplace.amazon.it$/", $customerEmail)) {
   // do something
}

LE based on commnent

if you want to check if the email is one of marketplace.amazon.it OR marketplace.amazon.de then this is the code:

$customerEmail = $order->getData('customer_email');
$needles = ['@marketplace.amazon.it', '@marketplace.amazon.de'];

foreach ($needles as $needle) {
   if (preg_match("/{$needle}$/", $customerEmail)) {
      // do something
   }
}
4
  • Thank you very much. What if I also want @ marketplace.amazon.de?
    – user95530
    Commented Apr 9, 2021 at 16:25
  • check my updated answer above
    – Diana
    Commented Apr 9, 2021 at 16:31
  • Thank you for your kind assistance
    – user95530
    Commented Apr 9, 2021 at 16:32
  • you're most welcome. please consider accepting this as solution if it suits your needs. cheers and good luck!
    – Diana
    Commented Apr 9, 2021 at 16:33

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.