-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 #5425 from magento-mpi/MC-29276
MC-29276: Discount fixed amount whole cart applied mutiple time when customer use Check Out with Multiple Addresses
- Loading branch information
Showing
8 changed files
with
393 additions
and
20 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
24 changes: 24 additions & 0 deletions
24
app/code/Magento/SalesRule/Model/Rule/QuoteResetAppliedRules.php
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,24 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\SalesRule\Model\Rule; | ||
|
||
use Magento\SalesRule\Model\Spi\QuoteResetAppliedRulesInterface; | ||
|
||
/** | ||
* Reset applied rules to quote | ||
*/ | ||
class QuoteResetAppliedRules implements QuoteResetAppliedRulesInterface | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function execute(\Magento\Quote\Api\Data\CartInterface $quote): void | ||
{ | ||
$quote->setCartFixedRules([]); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
app/code/Magento/SalesRule/Model/Spi/QuoteResetAppliedRulesInterface.php
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,22 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\SalesRule\Model\Spi; | ||
|
||
/** | ||
* Reset applied rules to quote | ||
*/ | ||
interface QuoteResetAppliedRulesInterface | ||
{ | ||
/** | ||
* Reset applied rules to quote | ||
* | ||
* @param \Magento\Quote\Api\Data\CartInterface $quote | ||
* @return void | ||
*/ | ||
public function execute(\Magento\Quote\Api\Data\CartInterface $quote): void; | ||
} |
39 changes: 39 additions & 0 deletions
39
app/code/Magento/SalesRule/Observer/QuoteResetAppliedRulesObserver.php
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,39 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\SalesRule\Observer; | ||
|
||
use Magento\Framework\Event\Observer; | ||
use Magento\Framework\Event\ObserverInterface; | ||
use Magento\SalesRule\Model\Spi\QuoteResetAppliedRulesInterface; | ||
|
||
/** | ||
* Reset applied rules to quote before collecting totals | ||
*/ | ||
class QuoteResetAppliedRulesObserver implements ObserverInterface | ||
{ | ||
/** | ||
* @var QuoteResetAppliedRulesInterface | ||
*/ | ||
private $resetAppliedRules; | ||
|
||
/** | ||
* @param QuoteResetAppliedRulesInterface $resetAppliedRules | ||
*/ | ||
public function __construct(QuoteResetAppliedRulesInterface $resetAppliedRules) | ||
{ | ||
$this->resetAppliedRules = $resetAppliedRules; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function execute(Observer $observer) | ||
{ | ||
$this->resetAppliedRules->execute($observer->getQuote()); | ||
} | ||
} |
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
Oops, something went wrong.