Here in my custom module:

enter image description here

This product with 50 quantities price is 6,000

But when I add to cart this multiplies

So how I can fix this?

enter image description here

Can I use observer to change this or are there any other best way?

 if ($quoteId != 0 && ($priceOne!=$item->getCustomPrice() || $quoteQty!=$item->getQty())) {
                $flag = 1;
                //$item->setRowTotal($priceOne * $quoteQty);
                $item->setRowTotal($priceOne * 1);
                if ($helper->checkAndUpdateForDiscount($item)) {
                } else {
                        "You can't edit quote items"
  • I'm not understanding what is trying to be achieved. What is the price for a single unit? Are you trying to provide a tier pricing structure that has discounts for bulk purchases?
    – Ian at SSU
    Feb 20, 2019 at 13:35
  • hi i want to send price to cart Feb 20, 2019 at 14:05
  • but we are giving quantities is 50s price 6,000 when add to cart it's multiplying we not need this for this module only Feb 20, 2019 at 14:07
  • I'm still not understanding what is trying to be achieved. What is the price for a single unit, 10 units, 100 units? Seem like you're trying to use the qty field incorrectly and might be able to configure the product catalog to achieve goals without custom code. For example, use an attribute to show the number of units in a package. That said, I've used the event sales_quote_product_add_after to add custom pricing logic when an item is added to cart.
    – Ian at SSU
    Feb 20, 2019 at 14:24
  • i will explain. Feb 20, 2019 at 14:25

1 Answer 1


I still think you probably want to set price to $120 and then control available qty's via the frontend. Then you might want to enforce qty's allowed in cart via a quote observer/interceptor.

To provide you an answer to the question of how to manipulate price for products in the cart a method I've used before is to observe the sales_quote_product_add_after event. Below is a basic idea of the concept:


<event name="sales_quote_product_add_after">
    <observer name="company_module_quote_product_add_after"
              instance="Company/Module/Observer/QuoteProductAddAfterObserver" />


class QuoteProductAddAfterObserver implements ObserverInterface
    public function execute(\Magento\Framework\Event\Observer $observer)
        $items = $observer->getEvent()->getData('items');
        foreach ($items as $quoteItem) {
           //...custom logic to...
  • but also quantities not show as 1 Feb 20, 2019 at 14:57
  • The answer provides a way to "How to change price, the price calculation in cart through custom module Magento 2?"
    – Ian at SSU
    Feb 20, 2019 at 15:00
  • can i get price and divided by the total number of quantities Feb 20, 2019 at 15:01
  • i added code............. Feb 20, 2019 at 15:04
  • The event provides access to an array of \Magento\Quote\Model\Quote\Item. If the provided information is not enough to get you working toward a solution you might want to consider looking for a third-party extension to meet your needs.
    – Ian at SSU
    Feb 20, 2019 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.