Created
May 6, 2022 12:38
-
-
Save magevision/be38f3731558f508af03f2a667701317 to your computer and use it in GitHub Desktop.
DisableCustomerWelcomeEmail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | |
<type name="Magento\Customer\Model\EmailNotification"> | |
<plugin name="magevision_disable_welcome_email" type="MageVision\Blog75\Plugin\Customer\Model\EmailNotificationPlugin"/> | |
</type> | |
</config> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MageVision\Blog75\Plugin\Customer\Model; | |
use Magento\Customer\Api\Data\CustomerInterface; | |
use Magento\Customer\Model\EmailNotification; | |
class EmailNotificationPlugin | |
{ | |
/** | |
* @param EmailNotification $subject | |
* @param \Closure $proceed | |
* @param CustomerInterface $customer | |
* @param string $type | |
* @param string $backUrl | |
* @param null $storeId | |
* @param null $sendemailStoreId | |
*/ | |
public function aroundNewAccount( | |
EmailNotification $subject, | |
\Closure $proceed, | |
CustomerInterface $customer, | |
$type = EmailNotification::NEW_ACCOUNT_EMAIL_REGISTERED, | |
$backUrl = '', | |
$storeId = null, | |
$sendemailStoreId = null | |
) { | |
//Disable all welcome emails | |
return; | |
//Disable Welcome email, when confirmation is not enabled and customer set already a password (default) | |
if ($type === EmailNotification::NEW_ACCOUNT_EMAIL_REGISTERED) { | |
return; | |
} | |
//Disable Welcome email, when password setting is required | |
if ($type === EmailNotification::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD) { | |
return; | |
} | |
//Disable Welcome email, when confirmation is enabled | |
if ($type === EmailNotification::NEW_ACCOUNT_EMAIL_CONFIRMATION) { | |
return; | |
} | |
//Disable Confirmation email, when account is confirmed | |
if ($type === EmailNotification::NEW_ACCOUNT_EMAIL_CONFIRMED) { | |
return; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment