Skip to content

Commit

Permalink
Fix #43 Buy now button change to Add to Cart
Browse files Browse the repository at this point in the history
  • Loading branch information
prince committed Jan 8, 2021
1 parent 85c2500 commit 44f8bfc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
11 changes: 6 additions & 5 deletions view/frontend/templates/buynow-list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,35 @@
?>
<?php
/** @var \Mageprince\BuyNow\Block\Product\ListProduct $block */
/** @var $escaper \Magento\Framework\Escaper */
$product = $block->getProduct();
?>
<?php $helper = $this->helper(\Mageprince\BuyNow\Helper\Data::class); ?>
<?php $buttonTitle = $helper->getButtonTitle() ?>
<?php if ($product->isSaleable()): ?>
<?php $postParams = $block->getAddToCartPostParams($product); ?>
<div class="buynow-btn">
<form action="<?= /* @noEscape */ $postParams['action']; ?>"
<form action="<?= $escaper->escapeUrl($postParams['action']); ?>"
id="product_addtocart_form_<?= /* @noEscape */ $postParams['data']['product']; ?>"
method="post">
<input type="hidden"
name="product"
value="<?= /* @noEscape */ $postParams['data']['product']; ?>">
<input type="hidden"
name="<?= /* @noEscape */ 'uenc'; ?>"
name="uenc"
value="<?= /* @noEscape */ $postParams['data']['uenc']; ?>">
<?= $block->getBlockHtml('formkey') ?>
<button type="submit"
title="<?= $block->escapeHtml(__($buttonTitle)) ?>"
title="<?= $escaper->escapeHtml(__($buttonTitle)) ?>"
class="action tocart buynow primary"
data-mage-init='
{
"Mageprince_BuyNow/js/buy-now": {
"form": "#product_addtocart_form_<?= /* @noEscape */ $postParams['data']['product'] ?>"
"form": "#product_addtocart_form_<?= $escaper->escapeHtml($postParams['data']['product']) ?>"
}
}
'>
<span><?= /* @noEscape */ __($buttonTitle) ?></span>
<span><?= $escaper->escapeHtml(__($buttonTitle)) ?></span>
</button>
</form>
</div>
Expand Down
9 changes: 5 additions & 4 deletions view/frontend/templates/buynow-view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
/** @var $escaper \Magento\Framework\Escaper */
?>
<?php $helper = $this->helper(\Mageprince\BuyNow\Helper\Data::class); ?>
<?php $formId = $helper->getAddToCartFormId(); ?>
<?php $buttonTitle = $helper->getButtonTitle() ?>
<div class="buynow-button">
<button type="submit"
title="<?= /* @noEscape */ __($buttonTitle) ?>"
title="<?= $escaper->escapeHtml(__($buttonTitle)) ?>"
id="buy-now"
class="action tocart primary"
class="action primary buy-now-btn"
data-mage-init='
{
"Mageprince_BuyNow/js/buy-now": {
"form": "#<?= /* @noEscape */ $formId; ?>"
"form": "#<?= $escaper->escapeHtml($formId); ?>"
}
}
'>
<span><?= /* @noEscape */ __($buttonTitle) ?></span>
<span><?= $escaper->escapeHtml(__($buttonTitle)) ?></span>
</button>
</div>
9 changes: 8 additions & 1 deletion view/frontend/web/css/source/_module.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@
float: left;
}

.buy-now-btn {
margin-right: 1%;
width: 49%;
line-height: 3.6rem;
}

@media(max-width: 767px){
.catalog-category-view button.buynow{
margin-top: 5px;
margin-left: 0px;
}
}
}

0 comments on commit 44f8bfc

Please sign in to comment.