How to Add Block Before Add to Cart Button in Magento 2 Product Page

From landing on a product page to completing the whole buying cycle, product page plays a vital role in conversion. Hence the product page must be designed in such a way that can provide enough information prior to making a purchase, impress the visitors, push them for conversion and be customer friendly for online purchases!

You may sometimes need to tweak the default Magento 2 product page a bit here and there. You may want to add a little notice that you want your customer to see before adding the product to cart or may want to convey essential details before they proceed to checkout! To serve the purpose, you need to add block before Add to Cart button in Magento 2 product page. Use the below code the right way and you are done!

Method to Add Block Before Add to Cart Button in Magento 2 Product Page:

  1. Add the below code in your catalog_product_view.xml file at Vendor\Extension\view\frontend\layout
  2. Create new view.phtml file at Vendor\Extension\view\frontend\templates\catalog\product
  3. Create View.php file at Vendor\Extension\Block\Catalog\Product

That was all!

Another amazing thing you can do while customizing the product page is to use custom price template in Magento 2 to change the way prices are displayed to the customers.

Ain’t the tutorial an easy-to-follow type? 😃

However, you may point out your doubts in the Comments section below and I’d be happy to help 😊

Thank you!

5
(based on 14 Reviews)
How to Add Block Before Add to Cart Button in Magento 2 Product PageAuthor Magento Badge

Sanjay Jethva

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

1 Comment

  • Syed Muneeb Ul Hasan

    Thanks for posting this useful tutorial

    Well, I think it would be more great if you can share the screenshot of the desired result at the bottom of the guide.

Leave a Reply

Your email address will not be published.