Recent Topics

Event checkout.cart.add.after should return product not whole cart?

  • When listening to the checkout.cart.add events being dispatched in Cart.php addProduct() function, the before event dispatches with the $product object, but the after event dispatches with the entire $cart object.

    Does it not make sense to dispatch the event with $parentCartItem since the function is more relating to a single product being added rather than the whole cart?

    If one needs to listen for the whole cart, the event checkout.cart.collect.totals.after dispatched in collectTotals() seems more appropriate.

    In Webkul\Checkout\src\Cart.php ~Line 186:

            --Event::dispatch('checkout.cart.add.after', $cart);
            ++Event::dispatch('checkout.cart.add.after', $parentCartItem );


Log in to reply