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);
}
| improve this question | | | | |
  • I can see you are setting weight already, is it not working? – Adarsh Khatri Jul 14 '16 at 0:03
1

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

| improve this answer | | | | |
  • Forget to say taht I cahnge the weight on product view.. – Christiaan Jansen Jul 18 '16 at 12:38
  • How are you changing the weight on product view? Its not possible until the quote is generated for the customer. – Twinkal Jul 18 '16 at 12:41
  • So when I try to change the weight after add to quote it should work? – Christiaan Jansen Jul 19 '16 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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