Hello, Magento Friends!

Magento Custom Development is a must-have for any business to fill the needs and save time and efforts to serve an excellent shopping experience to the shoppers. With the aid of smooth modifications and amalgamations in the frontend as well as backend, the Magento 2 E-commerce can provide a first-class user experience where it allows the user to set the custom price while adding a product to the cart. We are making headway to appending a short fragment of code that can outweigh all the prices of products with your intended one.


Often, it happens that the store owner is willing to set a fixed product price even if multiple options/add-ons are selected by the customer from the front end for all or some specific products. At that time we need to manually code to override all store product prices with your desired custom price instead of manually editing all store products. Also, have a glance at the Magento 2 Custom Price Extension by MageComp which enables the admin to set a product price and the customer to add their desired product price.

In this tutorial blog, we will be demonstrating how you can Add Product to Cart with the Custom Price in Magento 2. This action triggers the already calculated price by Magento and lets you add your customized price.

Steps to Add Product To Cart With Custom Price in Magento 2

Step 1: First, create a file “events.xml” at the below-given path.


Now add the below code

Step 2: Now, we need one more file named “Customprice.php” that overrides our price. Go to the below path


And finally add the code as mentioned below,

That’s it!

Bottom Line:

And, bingo! Hope everyone is now aware of How to Add Product To Cart With Custom Price in Magento 2. You are free to play and manipulate this according to your need for setting a custom price for one or more products by adding conditions. Also, get the Magento Custom Extension Development Service and custom develop your Magento store as per your business needs.

Let us know by commenting below if you are facing any issues during the implementation of this code.

Happy Coding!Magento Store

Click to rate this post!
[Total: 21 Average: 4.8]