Serving a great shopping experience is a duty of store owner towards their Magento store customers. From landing on a store to check out of the product, the customer passes through the whole shopping funnel. Among which product page plays an important role for the customer to get detailed information about a product before making a purchase. But sometimes it’s not enough or there is information that the store owner is willing to let their customer know before making the purchase.

Recently, one of the clients suffering from the same situation where he was willing to let his customer knows some information before they add the product to their cart. The solution is simple, we have suggested them to add a block after add to cart button, so whenever a customer adds products to cart he or she can make note of it and can ensure that product is a perfect fit for them or not.

Using Block, we can display various information related to the product such as: chart, discount, offers & deals, terms and conditions or caution etc. That’s why today at MageComp blog we came up with an easy solution for adding a block on product page right after the add to cart button.

Firstly, you need to create your custom module and after that you to create block using following code into your catalog_product_view.xml file.
app\code\Vendor\Extension\view\frontend\layout\catalog_product_view.xml

Now, you need to create another file and named it as ‘File.phtml’, in which you have to add your custom code which you want to display in your custom block.
app\code\Vendor\Extension\view\frontend\templates\catalog\product\view\file.phtml

Lastly, you need to create one block ‘Enquiry.php’ file here. In Which you can add your own logical functions.
Vendor\Extension\Block\Catalog\Product\View\Enquiry.php

And that’s it! Now clear the cache and you are ready to go.
You can comment down below if you are looking for any help regarding this code.
Happy coding!

Click to rate this post!
[Total: 19 Average: 3.7]