I have to edit the quantity of some items programmatically in Magento.

Say a customer ordered for 5 kg of Apples and 10 qantity of pens. But then he rejects 1 kg of apple and 5 pens because of say poor quality or whatsoever the reason. So i need to update them in my credit memo and the price should also automatically update accordingly along with taxes and everything so that customer has to pay for 4 kg of apples and 5 pens only. How to apply this functionality to magento programmatically?

I am using magento version.

Please help me. I am a novice in magento and I am stuck at this point. Thankyou in advance!!


You should create a Refund (I mean Creditmemo) of returned items. This will automatically deduct QTY(ies) from Order/Invoice.

For that Go to admin Order grid > View Order. Now click Credit Memo button (if it's not there, that means Invoice is not generated yet).

In this Page, you can see all the Items Ordered/Invoiced. You can deduct the QTYs from Qty to Refund column and click on Update Qty's, this will show the Totals (Refund Totals).

In Refund Totals block, Adjustment Refund and Adjustment Fee are important fields also known as Positive Adjustment and Negative Adjustment respectively. Amounts entered in Adjustment Refund will be added to the totals and Adjustment Fee will be substracted from totals. So you can adjust CUSTOM Totals from these fields.

|improve this answer|||||
  • How to achieve this functionality through a code? – neerav94 Jul 28 '16 at 13:37
  • I have explained the DEFAULT magento functionality. What to build here ? – Anil Suthar Jul 28 '16 at 13:43
  • As you told Go to admin Order grid > View Order and then click on Credit Memo. Instead of doing that I want to write a code for that so that the updated order stores in the database automatically by calling some type of rest api without manually going and creating the credit memo. – neerav94 Jul 29 '16 at 19:53
  • check here: magento.stackexchange.com/questions/5569/… – Anil Suthar Jul 30 '16 at 6:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.