Web Analytics

Fill the form & Get Installation Support

In Magento 2, how to set custom price for products in cart?

Firstly, we have to create a custom module.

Then, we have to declare a file named events.xml to catch an event that takes place after a product is added to the cart.

Create events.xml file at the following path Magemonkeys/CustomPriceInCart/etc/frontend/events.xml

The next step is to create the observer to make changes to the price.

Create CustomPriceInCart.php file at the following path Magemonkeys/CustomPriceInCart/Observer/CustomPriceInCart.php

By turning on super mode to the product through function setIsSuperMode(true), we can stop the system generating the price.

Then we can set the custom prices for products in the cart.

Fill the below form if you have any Magento programming need.





    Recent Articles

    Author Info

    Author Image

    Magento Certified Developer

    Hire J. Lakum

    Get a Free Quote





      /* second popup */

      Connect With Us