1

I made custom calculation to change product price on cart page.

Product type is bundle. And bundle product price type is dynamic.

Calculation is working fine my custom calculation is display in order info but when I create invoice from order my custom calculation is not taking effect in invoice grand total and subtotal.

I know bundle product price type is dynamic so when prepareInvoice method is called for creating invoice it called $invoice->collectTotals(); and this method further recalculate associated product price so my custom calculation is not taking effect. So what is solution for this???

4

The invoice uses another set of total models (same as creditmemo).
Here is the process flow:

Mage_Sales_Model_Order_Invoice::collectTotals() calls $this->getConfig()->getTotalModels()

The config model in question is Mage::getSingleton('sales/order_invoice_config'), which is initialized using the configuration branch 'global/sales/order_invoice'.

Here are the total models getTotalModels() will return in this case:

  • sales/order_invoice_total_subtotal
  • sales/order_invoice_total_discount
  • sales/order_invoice_total_shipping
  • sales/order_invoice_total_tax
  • sales/order_invoice_total_grand
  • sales/order_invoice_total_cost

These are configured in the Mage/Sales/etc/config.xml file in the branch mentioned above. There is no extra total model for bundles.

So to add your custom calculation you will also need to add a custom invoice total model, or rewrite one of the existing ones, corresponding to how you implemented your change for the quote total models.
You probably also want to do the same for the creditmemo total models which work just like the invoice ones.

0

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.