This is an annoying bug that is still an issue with the current version of Magento (v1.7.0.0 as of this writing). I have opened Issue #27867 with Magento and am hoping that this can finally be resolved in the core code. In the meantime, to fix this issue we need to make a tweak to Adminhtml/Model/Sales/Order/Create.php (don’t edit core code, of course, the methods below should be modified in your custom module)
Add this code above the line “if ($additionalOptions = $orderItem->getProductOptionByCode(‘additional_options’)) {” in the method… initFromOrderItem()
if (
!$this->getSession()->getReordered()
&& $orderItem->getOriginalPrice() != $orderItem->getPrice()
) {
$item->setCustomPrice($orderItem->getPrice());
$item->setOriginalCustomPrice($orderItem->getPrice());
}
This will make it so your custom price sticks on order edits. For reorders it will use the original price. Should you want it to stick on reorders as well just remove the second line “!$this->getSession()->getReordered()”.
If your Magento version is earlier than v1.4.0.0, you might also have noticed that your coupon codes aren’t sticking either (Issue #15351). To fix this, add the code below right before the line “if ($this->getQuote()->getCouponCode()) {” in the method… initFromOrder()
$orderCouponCode = $order->getCouponCode();
if ($orderCouponCode) {
$this->getQuote()->setCouponCode($orderCouponCode);
}
Thanks for this, quick and easy!
I tried implementing this and for some reason it’s not working. The custom item still switches back to $0.
I turned off the cache as well.
Any thoughts? I’ve tried it with the re-order and without and it’s not retaining the price.
Appreciate any hints you can offer.
HEre is what I have
$item = $this->getQuote()->addProduct($product, $buyRequest);
if (is_string($item)) {
return $item;
}
if ($orderItem->getOriginalPrice() != $orderItem->getPrice() )
{$item->setCustomPrice($orderItem->getPrice());}
if ($additionalOptions = $orderItem->getProductOptionByCode('additional_options')) {
Under
$item->setCustomPrice($orderItem->getPrice());
you should also add
$item->setOriginalCustomPrice($orderItem->getPrice());
Otherwise it’s not working for me either…
This works for me:
(same position in code)
//fix for keeping custom price
if (Mage::app()->getRequest()->getControllerName() == ‘sales_order_edit’)
{
$quoteItem = Mage::getModel(‘sales/quote_item’)->load($orderItem->getQuoteItemId());
$item->setCustomPrice($quoteItem->getCustomPrice());
}
//end fix
For some reason my Magento 1.7.0.2 install was also forgetting about coupon codes. Your 1.4 code added the coupon to the order, but the coupon code was only shown, not applied to the prices. Removing the coupon and reapplying it changed that so there was some issue collecting order totals.
My install also forgot about what shipping method to use on the edited order if the coupon was applied. I changed the collectTotals to have getShippingAddress before it and now it seems to work correctly:
if ($this->getQuote()->getCouponCode()) {
// old $this->getQuote()->collectTotals(); and new as follows:
$this->getQuote()->getShippingAddress()->collectTotals();
Not working for me in Ver 1.9.2.1 – We have it fine for edit orders as we also use and order edit extension.
I was trying to add this for reorders as custom pricing doesnt remain. Tried the above fix without the second line but just uses original price still.
Any ideas?
[…] found this: http://www.fetchdesigns.com/blog/magento-custom-price-lost-on-order-edit/ But it doesn’t seem to fix the problem for me, in Magento […]