Question

I have this function: if ($ order-> getData ('customer_email') == 'fvzqmufneovrezmv@marketplace.amazon.it')

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

Was it helpful?

Solution

$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
   }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top