Skip to content

Commit

Permalink
Merge pull request #12 from magmodules/release/1.5.3
Browse files Browse the repository at this point in the history
Release/1.5.3
  • Loading branch information
Marvin-Magmodules authored Oct 31, 2022
2 parents 7bbc740 + 5b7c8de commit a0513b1
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
66 changes: 66 additions & 0 deletions Plugin/Customer/SaveEmail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* Copyright © Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magmodules\Reloadify\Plugin\Customer;

use Magento\Customer\Model\AccountManagement as Subject;
use Magento\Checkout\Model\Session as CheckoutSession;
use Magento\Quote\Api\CartRepositoryInterface;

/**
* SaveEmail Plugin
* Save guest email to quote after customer first time fill it on shipping step (needed for abandoned carts)
*/
class SaveEmail
{
/**
* @var CheckoutSession
*/
private $checkoutSession;
/**
* @var CartRepositoryInterface
*/
private $quoteRepository;

/**
* SaveEmail constructor.
* @param CheckoutSession $checkoutSession
* @param CartRepositoryInterface $quoteRepository
*/
public function __construct(
CheckoutSession $checkoutSession,
CartRepositoryInterface $quoteRepository
) {
$this->checkoutSession = $checkoutSession;
$this->quoteRepository = $quoteRepository;
}

/**
* Save email to quote
*
* @param Subject $subject
* @param bool $result
* @param string $customerEmail
* @param null $websiteId
* @return bool
*/
public function afterIsEmailAvailable(
Subject $subject,
bool $result,
string $customerEmail
): bool {
try {
$quote = $this->checkoutSession->getQuote();
$quote->setCustomerEmail($customerEmail);
$this->quoteRepository->save($quote);
} catch (\Exception $e) {
return $result;
}

return $result;
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magmodules/magento2-reloadify",
"description": "Reloadify extension for Magento 2",
"type": "magento2-module",
"version": "1.5.2",
"version": "1.5.3",
"license": [
"BSD-2-Clause"
],
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<default>
<magmodules_reloadify>
<general>
<version>v1.5.2</version>
<version>v1.5.3</version>
<enable>0</enable>
<debug>0</debug>
</general>
Expand Down
4 changes: 4 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,8 @@
<argument name="collectionProcessor" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\ProductCollectionProcessor</argument>
</arguments>
</type>

<type name="Magento\Customer\Model\AccountManagement">
<plugin name="saveEmailQuote" type="Magmodules\Reloadify\Plugin\Customer\SaveEmail" sortOrder="1" disabled="false" />
</type>
</config>

0 comments on commit a0513b1

Please sign in to comment.