문제

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

도움이 되었습니까?

해결책

$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
   }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top