Magento - Credit Memo: Set quantity to 0 button

Magento - Credit Memo: Set quantity to 0 button

If you create a Credit Memo in Magento the default quantities to refund are equal to the amount which was initially ordered. If you have a large number of items which have been ordered and you only want to refund one of them it is very tiring to set all the quantities to 0. Especially if you are processing a lot of orders per day. Below is a small unobtrusive Javascript snippet (based on Prototype) which adds a "Set Qty´s to 0" button on the credit memo form. Simple upload the .js file (e.g. in folder youddomain/js/someDir/) and add it to the sales.xml file of your theme.

Download JS

document.observe("dom:loaded", function() { 
 if($$('#creditmemo_item_container .data.order-tables .update-button')[0]){

var YourName = {
    init : function(){
        var my_div = document.createElement('div');
           marginLeft: '3px'
        my_div.innerHTML ='Set Qtys to 0';
        my_div.observe('click', YourName.refresh);
        $$('#creditmemo_item_container .data.order-tables .update-button')[0].insert({after:my_div});
    refresh : function(){
        $$('input.input-text.qty-input').each(function(item) {     
  $$('#creditmemo_item_container .data.order-tables .update-button').each(function (elem) {elem.disabled=false;elem.removeClassName('disabled');});
        $$('#creditmemo_item_container .data.order-tables .update-button')[0].click();

Add it to sales.xml

        <reference name="head">
            <action method="addJs"><script>someDir/cm.js</script></action>

Oops, an error occurred! Code: 20211028012746376c0b3f