-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove 'spend_points' from session after order placement
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 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,36 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* @copyright Copyright (c) Vendic B.V https://vendic.nl/ | ||
*/ | ||
|
||
namespace Vendic\HyvaCheckoutMirasvitRewards\Plugin; | ||
|
||
use Magento\Checkout\Model\Session; | ||
use Magento\Quote\Api\CartManagementInterface; | ||
|
||
class RemoveSpendPointsFromSession | ||
{ | ||
|
||
private const SPEND_POINTS = 'spend_points'; | ||
|
||
public function __construct(private Session $checkoutSession) | ||
{ | ||
} | ||
|
||
/** | ||
* After an order is placed, the spent points should be | ||
* reset to zero on the session so that the old spent points won't | ||
* be displayed again on the checkout page. | ||
* | ||
* @param CartManagementInterface $subject | ||
* @param int $result | ||
* @return int | ||
*/ | ||
public function afterPlaceOrder( | ||
CartManagementInterface $subject, | ||
$result, | ||
) { | ||
$this->checkoutSession->setData(self::SPEND_POINTS, 0); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* @copyright Copyright (c) Vendic B.V https://vendic.nl/ | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="Magento\Quote\Api\CartManagementInterface"> | ||
<plugin name="vendic_remove_spend_points_from_checkout_session" | ||
type="Vendic\HyvaCheckoutMirasvitRewards\Plugin\RemoveSpendPointsFromSession"/> | ||
</type> | ||
</config> |