Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

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

    Bug Report
    1
    1
    247
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      profner last edited by

      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 );
      

      Thanks
      Peter

      1 Reply Last reply Reply Quote 0
      • First post
        Last post