Skip to content

Commit 26d85fb

Browse files
committed
ACP2E-703: Page refreshes when products are added to cart
1 parent af16bef commit 26d85fb

File tree

1 file changed

+21
-21
lines changed
  • app/code/Magento/PageBuilder/view/frontend/templates/catalog/product/widget/content

1 file changed

+21
-21
lines changed

app/code/Magento/PageBuilder/view/frontend/templates/catalog/product/widget/content/carousel.phtml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use Magento\Framework\App\Action\Action;
1717
* @var \Magento\Framework\Escaper $escaper
1818
*/
1919
?>
20-
<?php if ($exist = ($block->getProductCollection() && $block->getProductCollection()->getSize())) : ?>
20+
<?php if ($exist = ($block->getProductCollection() && $block->getProductCollection()->getSize())): ?>
2121
<?php
2222
$type = 'widget-product-carousel';
2323

@@ -31,7 +31,7 @@ use Magento\Framework\App\Action\Action;
3131
?>
3232
<ol class="product-items <?= /* @noEscape */ $type ?>">
3333
<?php $iterator = 1; ?>
34-
<?php foreach ($items as $_item) : ?>
34+
<?php foreach ($items as $_item): ?>
3535
<?= /* @noEscape */ ($iterator++ == 1) ? '<li class="product-item">' : '</li><li class="product-item">' ?>
3636
<div class="product-item-info">
3737
<a href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>" class="product-item-photo">
@@ -45,20 +45,20 @@ use Magento\Framework\App\Action\Action;
4545
<?= $block->escapeHtml($_item->getName()) ?>
4646
</a>
4747
</strong>
48-
<?php if ($templateType) : ?>
48+
<?php if ($templateType): ?>
4949
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
5050
<?php endif; ?>
5151

5252
<?= $block->getProductPriceHtml($_item, $type) ?>
5353

5454
<?= $block->getProductDetailsHtml($_item) ?>
5555

56-
<?php if ($showWishlist || $showCompare || $showCart) : ?>
56+
<?php if ($showWishlist || $showCompare || $showCart): ?>
5757
<div class="product-item-inner">
5858
<div class="product-item-actions">
59-
<?php if ($showCart) : ?>
59+
<?php if ($showCart): ?>
6060
<div class="actions-primary">
61-
<?php if ($_item->isSaleable()) : ?>
61+
<?php if ($_item->isSaleable()): ?>
6262
<?php $postParams = $block->getAddToCartPostParams($_item); ?>
6363
<form data-role="tocart-form" data-product-sku="<?= $block->escapeHtml($_item->getSku()) ?>" action="<?= $block->escapeUrl($postParams['action']) ?>" method="post">
6464
<input type="hidden" name="product" value="<?= $block->escapeHtmlAttr($postParams['data']['product']) ?>">
@@ -70,33 +70,33 @@ use Magento\Framework\App\Action\Action;
7070
<span><?= $block->escapeHtml(__('Add to Cart')) ?></span>
7171
</button>
7272
</form>
73-
<?php else : ?>
74-
<?php if ($_item->getIsSalable()) : ?>
73+
<script type="text/x-magento-init">
74+
{
75+
"[data-role=tocart-form], .form.map.checkout": {
76+
"catalogAddToCart": {
77+
"product_sku": "<?= $escaper->escapeJs($_item->getSku()); ?>"
78+
}
79+
}
80+
}
81+
</script>
82+
<?php else: ?>
83+
<?php if ($_item->getIsSalable()): ?>
7584
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
76-
<?php else : ?>
85+
<?php else: ?>
7786
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
7887
<?php endif; ?>
7988
<?php endif; ?>
8089
</div>
81-
<script type="text/x-magento-init">
82-
{
83-
"[data-role=tocart-form], .form.map.checkout": {
84-
"catalogAddToCart": {
85-
"product_sku": "<?= $escaper->escapeJs($_item->getSku()); ?>"
86-
}
87-
}
88-
}
89-
</script>
9090
<?php endif; ?>
91-
<?php if ($showWishlist || $showCompare) : ?>
91+
<?php if ($showWishlist || $showCompare): ?>
9292
<div class="actions-secondary" data-role="add-to-links">
93-
<?php if ($this->helper(\Magento\Wishlist\Helper\Data::class)->isAllow() && $showWishlist) : ?>
93+
<?php if ($this->helper(\Magento\Wishlist\Helper\Data::class)->isAllow() && $showWishlist): ?>
9494
<a href="#"
9595
data-post='<?= /* @noEscape */ $block->getAddToWishlistParams($_item) ?>' class="action towishlist" data-action="add-to-wishlist" title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>">
9696
<span><?= $block->escapeHtml(__('Add to Wish List')) ?></span>
9797
</a>
9898
<?php endif; ?>
99-
<?php if ($block->getAddToCompareUrl() && $showCompare) : ?>
99+
<?php if ($block->getAddToCompareUrl() && $showCompare): ?>
100100
<?php $compareHelper = $this->helper(\Magento\Catalog\Helper\Product\Compare::class);?>
101101
<a href="#" class="action tocompare" data-post='<?= /* @noEscape */ $compareHelper->getPostDataParams($_item) ?>' title="<?= $block->escapeHtmlAttr(__('Add to Compare')) ?>">
102102
<span><?= $block->escapeHtml(__('Add to Compare')) ?></span>

0 commit comments

Comments
 (0)