0

I am working on site where i want to add/subtract fee to cart total and grand total.I am firing this event to capture the cart details.sales_order_save_after. while in observer i got the price using this code

public function modifyPrice(Varien_Event_Observer $obs)
        {


          $getotal = Mage::helper('checkout')->getQuote()->getGrandTotal();
          $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
           $subtotal = $totals["subtotal"]->getValue();
}.

But i don't know how to add/subtract amount from total and than update accordingly.Thanks in advance

  • Here's another thread stackoverflow.com/questions/20511309/… which might be useful for you and I am guessing you need this. – Subesh Pokhrel Jan 10 '14 at 8:30
  • You DON'T want to do things with the totals yourself. You get in hell, with taxes and fees and stuff. Instead you want to implement your own total model and add the stuff through this model. – Fabian Blechschmidt Mar 11 '14 at 14:38
1

There are currently a few things odd with the information you have posted. You stated that you want to address the cart total and order total. Your observer sales_order_save_after will fire every time the order is changed (for example when the order is shipped) and I would say too late for your scenario.

Your code does not make use of the observed event at all. I would expect to see something like

$obj->getEvent()->getOrder();

Overall I suggest you revisit your current approach and implement it via a custom total - see this great introduction on how totals work in Magento by Classy Llama or at least use an event that is more targetted like sales_quote_collect_totals_after or sales_model_service_quote_submit_before.

0

I would suggest to check the answer from https://stackoverflow.com/questions/4877413/magento-adding-duties-taxes-to-a-quote-during-review Whenever quote is created, collect method is being called. Try to install duty calculator extension and modify its collect method. It will certainly help you to accomplish your task.

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.