checkout_cart_add_product_complete – How to Get Quote Item

cartevent-observer

I'm trying to perform an action after i add a product to my cart.

I tried the observer
checkout_cart_product_add_after
but this does not enter a new line in the quote until after, thus my quote item is empty.

I need to have the line item created for the quote.

So i thought i would use "checkout_cart_add_product_complete" and this does create a line item in the quote, but i don't know what the new line item entity_id is from the "checkout_cart_add_product_complete", i tried looking at the object but it is way to big for me to find it….

Anyway so all i want after adding a product to the cart, is get the new line item id, this DOES NOT have to be from my observer object if not possible…

Best Answer

I tested some code here, and I am finding that checkout_cart_product_add_after does include the quote item, after it has been added:

$item = $observer->getQuoteItem();
$quote = $item->getQuote();

echo $item->getId();