Skip to content

Commit

Permalink
CC-34501: Initialisation Order Amendment Process (#11163)
Browse files Browse the repository at this point in the history
CC-34501 Initialisation Order Amendment Process
  • Loading branch information
dmiseev authored Nov 15, 2024
1 parent 420f83a commit cce0227
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"require": {
"php": ">=8.2",
"spryker/cart-extension": "^1.5.0 || ^2.1.0 || ^4.0.0",
"spryker/cart-reorder-extension": "^1.0.0",
"spryker/category": "^3.0.0 || ^4.0.0 || ^5.0.0",
"spryker/kernel": "^3.33.0",
"spryker/messenger": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,12 @@
<property name="nbResults" type="int"/>
</transfer>

<transfer name="CartReorder" strict="true">
<property name="quote" type="Quote"/>
<property name="orderItems" type="Item[]" singular="orderItem"/>
</transfer>

<transfer name="CartReorderRequest" strict="true">
</transfer>

</transfers>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/

namespace Spryker\Zed\ProductList\Communication\Plugin\CartReorder;

use Generated\Shared\Transfer\CartReorderRequestTransfer;
use Generated\Shared\Transfer\CartReorderTransfer;
use Generated\Shared\Transfer\QuoteTransfer;
use Spryker\Zed\CartReorderExtension\Dependency\Plugin\CartPreReorderPluginInterface;
use Spryker\Zed\Kernel\Communication\AbstractPlugin;

/**
* @method \Spryker\Zed\ProductList\Business\ProductListFacadeInterface getFacade()
* @method \Spryker\Zed\ProductList\ProductListConfig getConfig()
*/
class ProductListRestrictedItemsCartPreReorderPlugin extends AbstractPlugin implements CartPreReorderPluginInterface
{
/**
* {@inheritDoc}
* - Filters out restricted items from the cart reorder request.
* - Adds note to messages about removed items.
*
* @api
*
* @param \Generated\Shared\Transfer\CartReorderRequestTransfer $cartReorderRequestTransfer
* @param \Generated\Shared\Transfer\CartReorderTransfer $cartReorderTransfer
*
* @return \Generated\Shared\Transfer\CartReorderTransfer
*/
public function preReorder(
CartReorderRequestTransfer $cartReorderRequestTransfer,
CartReorderTransfer $cartReorderTransfer
): CartReorderTransfer {
$quoteTransfer = (new QuoteTransfer())
->setCustomer($cartReorderTransfer->getQuoteOrFail()->getCustomer())
->setItems($cartReorderTransfer->getOrderItems());

$quoteTransfer = $this->getFacade()->filterRestrictedItems($quoteTransfer);

return $cartReorderTransfer->setOrderItems($quoteTransfer->getItems());
}
}

0 comments on commit cce0227

Please sign in to comment.