What events to use for update of custom prices upon “Proceed to checkout” and “Submit Order”

magento.stackexchange https://magento.stackexchange.com/questions/3668

  •  16-10-2019
  •  | 
  •  

سؤال

I have made a module that sets custom prices of quote items upon a cart update. For that I use these events:

checkout_cart_product_add_after
sales_quote_remove_item
checkout_cart_update_items_after

It works fine but the problem is that the custom prices are not recalculated if user proceeds to checkout or sends the order.

I would like them to be recalculated there as well because they are derived from data that possibly might have been changed from the last cart update (user group, product base price, etc.). Magento recalculates its prices this way if a custom price is not set so I would like to achieve the same behaviour.

Are there the appropriate events to hook in to invoke the recalculation in my module?

EDIT: In fact, it seems that Magento recalculates prices even after normal page reloads in cart. I guess I don't really need this even though it is more correct.

هل كانت مفيدة؟

المحلول

I use the event salesQuoteCollectTotalsBefore set the price on the product and then it is transfered to the quoteItem:

public function salesQuoteCollectTotalsBefore(Varien_Event_Observer $observer)
{
    /* @var $quote Mage_Sales_Model_Quote */
    $quote = $observer->getQuote();
    foreach ($quote->getAllItems() as $quoteItem) {
        if (true) {
            /* @var $quoteItem Mage_Sales_Model_Quote_Item */
            $product = $quoteItem->getProduct();
            $price = $helper->getPriceWithoutTax($quoteItem);
            $product->setPrice($price);
        }
    }
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top