Skip to content

Instantly share code, notes, and snippets.

@magevision
Created May 6, 2022 12:38
Show Gist options
  • Save magevision/be38f3731558f508af03f2a667701317 to your computer and use it in GitHub Desktop.
Save magevision/be38f3731558f508af03f2a667701317 to your computer and use it in GitHub Desktop.
DisableCustomerWelcomeEmail
<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>
<?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