Magento – Allowing for a negative order, with Grand Total less than 0

checkoutgrand-total

One of our clients has asked for the ability for its order entry personnel to submit orders with a negative order total. The application already allows negative line items, which works fine as long as the rest of the order makes a positive Grand Total.

It seems that Magento tries very hard to not have a negative order total. Looking at the collected totals shows that Magento will apply a gift card for the inverse amount. If I disable the gift card, then it applies Store Credit (even if credit does not exist). I suspect this is just a quirk (and possibly a red herring).

Can anyone help pinpoint where Magento forces 0 as its maximum Grand Total amount, and how we might go about fulfilling the request? I don't want to simply force-set the total, as I want Magento to calculate everything normally, just with the allowance of a negative Grand Total.

The spirit of the question is the technical feasibility, but once that is addressed, I'm interested in any 'gotchas' or thoughts that might dissuade the use of negative order totals from a non-technical standpoint.

Best Answer

This seems like a very risky decision. If you implemented it you would need to override too much of the core, making the site extremely difficult to upgrade and support.

Performing a search in the Magento core for max(0 returns results in the following areas:

  • Enterprise_CustomerBalance_Model_Observer::creditmemoDataImport()
  • Enterprise_GiftCard_Model_Catalog_Product_Price_Giftcard::getFinalPrice()
  • Mage_Bundle_Model_Product_Price::getFinalPrice()
  • Mage_Catalog_Model_Product_Type_Price::getFinalPrice()
  • Mage_Catalog_Model_Product_Type_Configurable_Price::getFinalPrice()
  • Mage_Catalog_Model_Product_Type_Grouped_Price::getFinalPrice()
  • Mage_CatalogRule_Helper_Data::calcPriceRule()
  • Mage_Downloadable_Model_Product_Price::getFinalPrice()
  • Mage_SalesRule_Model_Validator::process()
  • Mage_Tax_Block_Sales_Order_Tax::_initSubtotal()
  • Mage_Tax_Model_Sales_Total_Quote_Tax (multiple uses)

And many more in templates in the adminhtml and frontend areas. You may need to rewrite many of these models to achieve the desired functionality.

You may want to consider the alternatives below:

  • Give the sales people logins to the Magento admin area and allow them to create orders from there - full control over item pricing etc
  • Use store credit if the customer should be getting credit back (I assume this is what an order with negative total would be for?)

If you provide a scenario where an order would end with a negative total, and also the reasoning behind it then the community will be able to give you a better answer. It's hard to solve a problem like this until you understand the business value behind the decision.

Related Topic