2

I would like to add some extra labels to html code from the address , like in the image: enter image description here

Right after the street address I would like to add some labels. Right now I added via jQuery, but I have to change a lot , when there is an address when you want to add a new address etc .

I know that this class method: Mage_Adminhtml_Block_Customer_Edit_Tab_Addresses::initForm is responsible for getting displayed those inputs. And in the customer/tab/addresses.phtml there is a big js, which is also responsabile for it. The fact is that everyhing that I change is a dead end. Is it possible to add those labels ? maybe If I rewrite the block and change smth in it . Any idea how can I do that ?

2
  • Check this it may be helpful
    – Piyush
    Commented Dec 12, 2017 at 9:18
  • 1
    @Piyush That is different, it adds a new attribute. I don't need that . I need to edit the existing default one : address, which is divide in 4 parts. Commented Dec 12, 2017 at 9:27

1 Answer 1

1

In the end I still end up using jQuery for the customer address and for the sales order address I used prototype. First I rewrite the data.phtml . here is the xml code:

   <adminhtml_sales_order_create_load_block_data>
       <reference name="data">
           <action method="setTemplate"><file>mynamespace_mymodule/sales/order/create/data.phtml</file></action>
       </reference>
   </adminhtml_sales_order_create_load_block_data> 

   <adminhtml_sales_order_create_index>
        <reference name="data">
            <action method="setTemplate"><file>mynamespace_mymodule/sales/order/create/data.phtml</file></action>
        </reference>
    </adminhtml_sales_order_create_index>

and in the end of the file I added this js code:

<script type="text/javascript">
    // adding additional labels in the sales order new or sales order edit page
    var elements = ['[for="order-billing_address_street0"]', '[for="order-shipping_address_street0"]', '[for="_item1street0"]', '[for="_item2street0"]', '[for="_item3street0"]'];
    htmlLabels = '<label for="streetlabel1"><?php echo Mage::helper('mynamespace_mymodule')->__('Housenumber') ?></label><label for="streetlabel2"><?php echo Mage::helper('mynamespace_mymodule')->__('Housenumber addition') ?></label><label for="streetlabel3"><?php echo Mage::helper('mynamespace_mymodule')->__('Appt') ?></label>';
    for (var i = 0; i < elements.length; i++) {
        var elementAfter = document.querySelector(elements[i]);
        if (elementAfter != null) {
            //insert html content after element X
            elementAfter.insertAdjacentHTML('afterEnd', htmlLabels);
        }
    }
</script>

The js script is only made for the sales orders create address. I'm not happy with it, but it s working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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