-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CC-13685: Updated product quantity and total in Mini Cart Widget from…
… catalog AJAX add-to-cart action. (#2517) Updated product quantity and total in Mini Cart Widget from catalog AJAX add-to-cart action.
- Loading branch information
Showing
7 changed files
with
195 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
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
59 changes: 59 additions & 0 deletions
59
src/SprykerShop/Yves/CartPage/Expander/MiniCartViewExpander.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,59 @@ | ||
<?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 SprykerShop\Yves\CartPage\Expander; | ||
|
||
use Generated\Shared\Transfer\MiniCartViewTransfer; | ||
use Generated\Shared\Transfer\QuoteTransfer; | ||
use SprykerShop\Yves\CartPage\CartPageConfig; | ||
use Twig\Environment; | ||
|
||
class MiniCartViewExpander implements MiniCartViewExpanderInterface | ||
{ | ||
/** | ||
* @var \Twig\Environment | ||
*/ | ||
protected Environment $twigEnvironment; | ||
|
||
/** | ||
* @var \SprykerShop\Yves\CartPage\CartPageConfig | ||
*/ | ||
protected CartPageConfig $cartPageConfig; | ||
|
||
/** | ||
* @param \Twig\Environment $twigEnvironment | ||
* @param \SprykerShop\Yves\CartPage\CartPageConfig $cartPageConfig | ||
*/ | ||
public function __construct(Environment $twigEnvironment, CartPageConfig $cartPageConfig) | ||
{ | ||
$this->twigEnvironment = $twigEnvironment; | ||
$this->cartPageConfig = $cartPageConfig; | ||
} | ||
|
||
/** | ||
* @param \Generated\Shared\Transfer\MiniCartViewTransfer $miniCartViewTransfer | ||
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer | ||
* | ||
* @return \Generated\Shared\Transfer\MiniCartViewTransfer | ||
*/ | ||
public function expand( | ||
MiniCartViewTransfer $miniCartViewTransfer, | ||
QuoteTransfer $quoteTransfer | ||
): MiniCartViewTransfer { | ||
$cartBlockMiniCartViewTemplatePath = $this->cartPageConfig->getCartBlockMiniCartViewTemplatePath(); | ||
if ($cartBlockMiniCartViewTemplatePath && !$miniCartViewTransfer->getCounterOnly()) { | ||
$content = $this->twigEnvironment->render( | ||
$cartBlockMiniCartViewTemplatePath, | ||
['quote' => $quoteTransfer], | ||
); | ||
|
||
$miniCartViewTransfer->setContent($content); | ||
} | ||
|
||
return $miniCartViewTransfer; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/SprykerShop/Yves/CartPage/Expander/MiniCartViewExpanderInterface.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,25 @@ | ||
<?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 SprykerShop\Yves\CartPage\Expander; | ||
|
||
use Generated\Shared\Transfer\MiniCartViewTransfer; | ||
use Generated\Shared\Transfer\QuoteTransfer; | ||
|
||
interface MiniCartViewExpanderInterface | ||
{ | ||
/** | ||
* @param \Generated\Shared\Transfer\MiniCartViewTransfer $miniCartViewTransfer | ||
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer | ||
* | ||
* @return \Generated\Shared\Transfer\MiniCartViewTransfer | ||
*/ | ||
public function expand( | ||
MiniCartViewTransfer $miniCartViewTransfer, | ||
QuoteTransfer $quoteTransfer | ||
): MiniCartViewTransfer; | ||
} |
40 changes: 40 additions & 0 deletions
40
src/SprykerShop/Yves/CartPage/Plugin/CartPage/CartBlockMiniCartViewExpanderPlugin.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,40 @@ | ||
<?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 SprykerShop\Yves\CartPage\Plugin\CartPage; | ||
|
||
use Generated\Shared\Transfer\MiniCartViewTransfer; | ||
use Generated\Shared\Transfer\QuoteTransfer; | ||
use Spryker\Yves\Kernel\AbstractPlugin; | ||
use SprykerShop\Yves\CartPageExtension\Dependency\Plugin\MiniCartViewExpanderPluginInterface; | ||
|
||
/** | ||
* @method \SprykerShop\Yves\CartPage\CartPageConfig getConfig() | ||
* @method \SprykerShop\Yves\CartPage\CartPageFactory getFactory() | ||
*/ | ||
class CartBlockMiniCartViewExpanderPlugin extends AbstractPlugin implements MiniCartViewExpanderPluginInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
* - Expands the provided `MiniCartView.content` with mini cart view. | ||
* | ||
* @api | ||
* | ||
* @param \Generated\Shared\Transfer\MiniCartViewTransfer $miniCartViewTransfer | ||
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer | ||
* | ||
* @return \Generated\Shared\Transfer\MiniCartViewTransfer | ||
*/ | ||
public function expand( | ||
MiniCartViewTransfer $miniCartViewTransfer, | ||
QuoteTransfer $quoteTransfer | ||
): MiniCartViewTransfer { | ||
return $this->getFactory() | ||
->createMiniCartViewExpander() | ||
->expand($miniCartViewTransfer, $quoteTransfer); | ||
} | ||
} |
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