Question

We process a lot of B2B orders (mostly by mail and phone) through the Magento Admin Panel, works fine, but what we are missing is an option to give a discount or extra fee to a customer.

In the ideal world we'd like to add an extra order line which has a custom description, custom price and a custom qty. This currently isn't possible because it expects a product.

To work around this we created a dummy product which can be added to the order, we change the price and qty and voila we have an extra order line. I've added a custom option (textfield) to the product which allows us to add a nice description for the customer.

This way we can add extra charges to the order, that's great. We also want to various discount order lines to the order. To do this I need to create order lines with a negative price in the admin panel.

Is there a relatively save modification to make to allow this?

Maybe as an alternative, maybe a custom discount could also be an option, but since this only allows for one discount to be added this isn't ideal. Any suggestions for that?

Was it helpful?

Solution

There is no easy way to create a negative row in the order because the Magento core is full of code like $value = max(0, $value) when it's about prices. This doesn't mean it's not possible.

First you need to override this method: Mage_Adminhtml_Model_Sales_Order_Create::_parseCustomPrice. THere is a line in there that checks if the price is at least 0. It needs to be removed.

price = $price>0 ? $price : 0;

The you need to look in the code for the text max( and see if the lines related to checkout.
For example there is this in Mage_Tax_Block_Sales_Order_Tax::_initSubtotal

subtotalIncl = max(0, $subtotalIncl);
$baseSubtotalIncl = max(0, $baseSubtotalIncl);

You may need to remove a lot of these kind of lines.
I don't know if this is the way to go but I'm sure it's possible.

What I would do in your place is to create a discount rule each time I need something like this with the full amount usable only once, with a strange coupon code, and apply it to your order. Not sure if this fits your needs (probably not) but this is what I got so far.

OTHER TIPS

This is unnecessary. The admin panel of Magento allows you to set custom product prices when placing orders from the backend:

Before:

enter image description here

After:

enter image description here

All I needed to do was check "custom price" and click "update items and qtys".

Cheers.

You could try and do the following (Don't know whether this will work though...)

  • Create a simple "discount product" with a price of 1 EUR
  • Create a price rule that gives a 200% discount (Don't know whether this will work...) of the amount of the product.
  • Whenever you add that product to the cart you can define the discount you want to give via qty.

Just a random idea that is worth a shot as it would require no coding at all...

I've accomplished this on one of our sites which had discount and charge requirements due to the need to integrate to a custom CRM by extending the quote, order, invoice and credit memo items to include a discount and charge field.

I then added an input field for each into the item row on the edit page in the admin area.

The subtotal and tax total collectors needed to be over-ridden to take the discount and charge into account as well as the row total calculation on each of the items. Including, but not limited to:

Mage_Sales_Model_Order_Creditmemo_Total_Subtotal
Mage_Sales_Model_Order_Creditmemo_Total_Tax
Mage_Sales_Model_Order_Creditmemo_Item::calcRowTotal

Also,

Mage_Sales_Model_Service_Order::prepareCreditmemo
Mage_Sales_Model_Service_Order::prepareInvoice
Mage_Adminhtml_Model_Sales_Order_Create::initFromOrder

All need to be over-ridden to move the extra fields around when orders are cancelled or invoiced.

All of the display points for the items need to be adjusted to take the charge and discount fields in to account.

All in all a pretty serious development undertaking, and not for the faint of heart, but it's workable.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top