Hello Magento Friends,

Today’s Magento solution is on Magento 2: How to Add Custom Button in Minicart.

A small cart icon on the top-right of the webpage is a mini cart that displays the summary of the products added to the cart. The customers can view their cart items without leaving the shopping process.

Although you can customize the mini cart according to your requirements in Magento 2. Sometimes the admin needs to add a custom button in the mini cart and perform some action on this button. Adding a custom button to the mini cart increases the user experience as the customers can perform actions without leaving their buying process.

Follow the below steps to Add a Custom Button in Minicart of your Magento 2 Store.

Steps to Add Custom Button in Minicart in Magento 2:

Step 1: First, we need to create a “default.xml” file inside the extension at the following path.

app\code\Vendor\Extension\view\frontend\layout\

Now add the below code

Step 2: After that, we need to create a “requirejs-config.js” file inside the extension at the following path.

app\code\Vendor\Extension\view\frontend\

And add the code as mentioned below

Step 3: After that, we need to create a “minicart-mixin.js” file inside the below path 

app\code\Vendor\Extension\view\frontend\web\js\view\

Then, add the below-mentioned code

Step 4: After that, we need to create a “content.html” file inside the below path

app\code\Vendor\Extension\view\frontend\web\template\minicart\

After that, include the code as follows

Step 5: Finally, after adding the code you need to run Magento upgrade and deploy commands.

Once you implement the above steps, your custom button is successfully added to the mini cart of your Magento 2 store.

Conclusion:

This way you can successfully Add Custom Button in Minicart in Magento 2. You can also implement other customizations with your mini cart in order to increase the customer experience.

Just in case you are stuck anywhere with the implementation of the above steps, let me know via the comment box. Share the article with your friends and stay in touch with us for more solutions.

Happy Coding!

Click to rate this post!
[Total: 9 Average: 4.6]