-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from magmodules/release/1.5.3
Release/1.5.3
- Loading branch information
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
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; | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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