I have some rules that change the price of product 'Z' if the quantity of products 'X' is 'Y' In the cart, how can I check the quantity of a product in the cart and change the price of that product using the checkout_cart_update_items_after event, because I need this checked after clicking the update button or whenever I change the cart also helps.

more specifically what I need to know is how to change the price and get the quantity with this event Any help is welcome!

Magento 2.3.3 Xampp Win 10


I can only give you hints and idea. You have to done it by your self :)

Make an observer. check product qty whenever this event fired. then update the price

These two links will help you :)

How To Get Product QTY

Update Product price

Try to do it by yourself so you can learn something :) Thanks

  • Thanks for the answer I am trying to do yes, I already have a way to get the quantity and price and apply the rules I need, I can change the price that displayed in the catalog using a Plugin intercepting the getPrice magento but I can not avoid saving the price I need when any cart change happens, every cart change I need to read the information and apply the rules if I need to but I don't know how to save after some change event, the second link you sent me might not help me using an event For "cart_product_add_after", I need to change the cart price after any changes to it. Dec 12 '19 at 16:53

Resolved using the "checkout_cart_save_after" event


namespace ModWay\mod\Observer;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;

class ProductCart implements ObserverInterface
     * Below is the method that will fire whenever the event runs!
     * @param Observer $observer

    public function __construct()

    public function execute(Observer $observer)

        $cart = $observer->getData('cart');
        $quote = $cart->getData('quote');
        $items = $quote->getAllVisibleItems();

        foreach($items as $item)


       // $quote->setTotalsCollectedFlag(false)->collectTotals();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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