1

I want to change the price of a configurable product I put in my quote. I use the observer sales_quote_add_item but it won't work for configurable products. I expect the observer method to run twice (for the simple and configurable record that's put in the database) but it's only called once (for the simple product). The record for configurable still has the old prices.

Can anyone tell me how I can change the price for the complete quote-item in such a way that it will also be seen on cart overview, invoices and emails?

1 Answer 1

3

I figured it out myself. You need to observe the event checkout_cart_product_add_after. In the observer you need the following:

public function change_price(Varient_Event_Observer $observer) {
    // get the quote
    $item = $observer->getQuoteItem();

    // checks for parent item
    if ($item->getParentItem()) {
        $item = $item->getParentItem();
    }

    // your price logic here
    $new_price = 999;

    $item->setCustomPrice($new_price);
    $item->setOriginalCustomPrice($new_price);
    $item->getProduct()->setIsSuperMode(true);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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