The Buy Now extension for Magento 2 enhances the shopping experience by allowing customers to make instant purchases with a single click. It adds a “Buy Now” button to product pages, enabling customers to bypass the cart and proceed directly to the checkout page.
Admin Configuration: Admin > Stores > Configuration > MagePrince > Buy Now
Run the following command in the Magento 2 root folder:
composer require mageprince/module-buynow
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
Copy the content of the repo to the app/code/Mageprince/BuyNow folder and run the following command in the Magento 2 root folder:
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
We do not provide support for placing the Buy Now button on related, upsell, wishlist, or any other locations, as it requires overriding core phtml files, which isn’t a good idea for an extension. Please be aware that many paid or free versions of the Buy Now module override these core files. Instead, use this piece of code to add the Buy Now button to custom product templates.
$buyNowBtnHtml = $this->getLayout()
->createBlock(\Mageprince\BuyNow\Block\Product\ListProduct::class)
->setProduct($_item)
->setButtonTitle('Buy Now')
->setTemplate('Mageprince_BuyNow::buynow.phtml')
->toHtml();
echo $buyNowBtnHtml;
Change $_item
to current product object.
You can use the code above to display the Buy Now button wherever you want on your product page. Just remember not to paste this code into the add to cart form or any other form. Put the code after </form>
tag. Below is a screenshot showing how to use the code.
Sample template: vendor/magento/module-catalog/view/frontend/templates/product/list/items.phtml
Want to contribute to this extension? The quickest way is to open a pull request on GitHub.
If you encounter any problems or bugs, please open an issue on GitHub.