1

I've build a module for changing the price while adding the product to the cart. This with the observer checkout_cart_product_add_after

Price is changing right, but I also want to change the weight for right calculation of shipping costs.

My Code:

<checkout_cart_product_add_after>
    <observers>
        <zeo_framecalculator_model_observer>
            <type>singleton</type>
            <class>Zeo_FrameCalculator_Model_Observer</class>
            <method>updatePrice</method>
        </zeo_framecalculator_model_observer>
    </observers>
</checkout_cart_product_add_after>

public function updatePrice(Varien_Event_Observer $observer) {
    $item = $observer->getQuoteItem();
    $item = ( $item->getParentItem() ? $item->getParentItem() : $item );

    $item->setCustomPrice($vavatexOrder['custom-price']);
    $item->setOriginalCustomPrice($vavatexOrder['custom-price']);

    $item->getProduct()->setIsSuperMode(true);
    $item->setWeight(10);
}
1
  • I can see you are setting weight already, is it not working? Commented Jul 14, 2016 at 0:03

1 Answer 1

1

Use event sales_quote_item_set_product. I tried your code and it worked perfectly fine then.

3
  • Forget to say taht I cahnge the weight on product view.. Commented Jul 18, 2016 at 12:38
  • How are you changing the weight on product view? Its not possible until the quote is generated for the customer.
    – Twinkal
    Commented Jul 18, 2016 at 12:41
  • So when I try to change the weight after add to quote it should work? Commented Jul 19, 2016 at 13:18

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.