1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace Dotdigitalgroup\Email\Plugin;
/**
* Disable customer email depending on settings value.
*/
class CustomerPlugin
{
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
public $scopeConfig;
/**
* CustomerPlugin constructor.
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
) {
$this->scopeConfig = $scopeConfig;
}
/**
* @param \Magento\Customer\Model\Customer $customer
* @param callable $proceed
* @param string $type
* @param string $backUrl
* @param string $storeId
*
* @return mixed
*/
public function aroundSendNewAccountEmail(
\Magento\Customer\Model\Customer $customer,
callable $proceed,
$type = 'registered',
$backUrl = '',
$storeId = '0'
) {
$storeId = $customer->getStoreId();
if (! $this->scopeConfig->getValue(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_DISABLE_CUSTOMER_SUCCESS,
'store',
$storeId
)
) {
return $proceed($type, $backUrl, $storeId);
}
}
}