0

When we choose one of the option below, the field 'title' automatically filled with selected value from carrier options.

I want to do the same for 'number' field, it would be filled with something when I choose my custom carrier. Is there any way to modify this tracking form? If yes, how? tracking form

Thank's in advance

may
  • 675
  • 1
  • 10
  • 26
  • You can do your work by adding a javascript code. Bind on change event of carrier dropdown and fill respective row with your data. And you can use `adminhtml_block_html_before` event observer to bind that js code. – Gulshan Maurya Sep 13 '16 at 06:29
  • where should i add the js code? is it inside dropdown function? As additional, I added my custom carrier in dropdown using `isTrackingAvailable() { return true; }` – may Sep 13 '16 at 06:58

2 Answers2

0

Look in the file app/design/adminhtml/default/default/layout/sales.xml, tracking.phtml is used several times. If this change is for a module then create a layout file 'yourmodule.xml' and enable it from your config file. Otherwise name it 'local.xml'. It's contents will have to be an update something like this:

<?xml version="1.0"?>
<layout>
    <adminhtml_sales_order_shipment_new>
        <reference name="shipment_tracking">
            <action method="setTemplate">
                <template>your/new/tracking.phtml</template>
            </action>
        </reference>
    </adminhtml_sales_order_shipment_new>
</layout>

Also if you want to minimize number of copypasted layout statements you can use <update handle="handle_name" /> inside different controller action handles. For example:

    <my_handle_name>
 <reference name="shipment_tracking"> 
<action method="setTemplate"> 
<template>your/new/tracking.phtml</template>
 </action> 
</reference> 
</my_handle_name> 
<adminhtml_sales_order_shipment_new>
 <update handle="my_handle_name"/>
 </adminhtml_sales_order_shipment_new> 
Arjun
  • 85
  • 1
  • 1
  • 10
0

Add following observer in your module's config.xml

             <events>
                <adminhtml_block_html_before>
                    <observers>
                        <add_script_on_shipment>
                            <class>yourmodule/observer</class>
                            <method>addScript</method>
                        </add_script_on_shipment>
                    </observers>
                </adminhtml_block_html_before>
            </events>

Put following code in Observer.php

public function addScript($observer) {
    $block = $observer->getEvent()->getBlock();
    if (($block instanceof Mage_Adminhtml_Block_Sales_Order_Shipment_View_Tracking) && $block->getType() != 'core/template' /*&& is your carrier active*/) {
        $shipment = $block->getShipment();
        $_child = clone $block;
        $_child->setType('core/template');
        $block->setChild('calling_block', $_child);
        $block->setTemplate('yourmodule/custom_script.phtml');
    }
}

add following code with required modifications in custom_script.phtml

<?php echo $this->getChildHtml('calling_block');?>
<script type="text/javascript">
     /*your custom javascript code to bind onchange event*/
</script>
Gulshan Maurya
  • 1,010
  • 11
  • 22