I have implemented an observer for checkout_cart_product_add_after
. I am retrieving the quote item by
$item = $observer->getEvent()->getQuoteItem();
However, I noticed, that any of the functions to retrieve the item's current price simply return NULL
. I can't even access its ID!
On further inspection I see that the quote item only has the following data attributes set:
quote_id
store_id
product
product_id
product_type
sku
name
weight
tax_class_id
base_cost
is_recurring
is_qty_decimal
is_nominal
qty_to_add
qty
qty_options
Attributes like price
, base_price
, custom_price
etc. are completely missing.
I am also observing the checkout_cart_update_items_after
event, where I get the quote item in a different way:
$cart = $observer->getEvent()->getCart();
$data = $observer->getEvent()->getInfo();
foreach( $data as $itemId => $itemInfo )
{
if( $item = $cart->getQuote()->getItemById( $itemId ) )
{
$item = $item->getParentItem() ?: $item;
…
}
}
In this case, all the relevant data is present.
Can anyone tell me, why the price data is missing for quote items in the checkout_cart_product_add_after
event?