Pages

Friday 4 July 2014

Advanced Shipping Method Module Part - 2 in magento

This tutorial is in continuation of a previous tutorial written, so please go through it before reading this one. The basic files need for creating a shipping method is not explained here since its already done in the previous tutorial.

Now let's see how to create front-end and back-end structure.

from config.xml add front-end layout.xml file

<frontend>
        <layout>
            <updates>
                <msmultiflat>
                    <file>pickup.xml</file>
                </msmultiflat>
            </updates>
        </layout>
    </frontend>


and we need to add below code on pickup.xml file

 <sales_order_view>
        <reference name="my.account.wrapper">
            <!--  <block name="custom.order" type="msmultiflat/pickup_order" template="pickup/Order.phtml"></block>-->
            <reference name="sales.order.info">
                <action method="setTemplate">
                    <template>pickup/Order.phtml</template>
                </action>
            </reference>
        </reference>
    </sales_order_view>


Next the we need to add code to the pickup/order.phtml file to show our form. We will place this in shipping method section.

 <div class="col-2">
                <div class="info-box">
                    <h2 class="box-title"><?php echo $this->__('Shipping Method') ?></h2>
                    <div class="box-content">
                        <?php  $shp_method = $_order->getShippingMethod(true) ?>
                        <?php if($shp_method['method'] == "msmultiflat" ){?>
                        <?php if ($_order->getShippingDescription()): ?>
                            <?php echo $this->escapeHtml($_order->getShippingDescription()) ?>
                                <?php

                                echo '</br></br>';
                                echo '<b>Account Number     </b>: ' . $this->escapeHtml($_order->getThirdpartyAccountNo());
                                echo '</p>';
                                echo '<b>Phone Number        </b>:' . $this->escapeHtml($_order->getThirdpartyPhoneNo());
                                echo '</p>';
                                echo '<b>Special Instructions</b>:' . $this->escapeHtml($_order->getThirdpartyComment());

                                ?>
                        <?php else: ?>
                            <?php echo $this->helper('sales')->__('No shipping information available'); ?>
                        <?php endif; ?>
                        <?php }else{ ?>
                            <?php if ($_order->getShippingDescription()): ?>
                                <?php echo $this->escapeHtml($_order->getShippingDescription()) ?>
                            <?php else: ?>
                                <?php echo $this->helper('sales')->__('No shipping information available'); ?>
                            <?php endif; ?>
                        <?php }?>
                    </div>
                </div>
            </div>

if we see from front-end look like below image.


Advanced Shipping Method Module



Now let's create back end layout.xml file for that we need to declare layout file in config.xml file look like this

 <adminhtml>
        <layout>
            <updates>
                <msmultiflat>
                    <file>easylife/pickup.xml</file>
                </msmultiflat>
            </updates
>
        </layout>
    </adminhtml>


and pickup.xml file code look like below

<?xml version="1.0"?>
<layout version="0.1.0">
    <adminhtml_sales_order_view>
        <reference name="order_info">
            <action method='setTemplate'>
                <template>easylife/pickup/sales/order/info.phtml</template>
            </action>
            <block type="adminhtml/sales_order_view_info" name="order_info2"
                   template="sales/order/view/info.phtml"></block>
            <block type="msmultiflat/adminhtml_order" name="custom.order" template='easylife/pickup/order.phtml'/>
        </reference>
    </adminhtml_sales_order_view>
</layout>


and we need to write pickup/sales/order.phtml below code

<?php $_order = $this->getOrder() ?>
<div class="box-left">
    <div class="entry-edit">
        <div class="entry-edit-head">
            <h4 class="icon-head head-account"><?php echo Mage::helper('sales')->__('Third Party Shipper Details') ?></h4>
        </div>
        <div class="fieldset">
            <table cellspacing="0" class="form-list">
                <tr>
                    <td style="width:20%" class="label"><strong>
                            <?php echo Mage::helper('sales')->__('Account No') ?></strong></td>
                    <td class="value"><?php echo $this->getOrder()->getThirdpartyAccountNo(); ?></td>
                </tr>
                <tr>
                    <td style="width:20%" class="label"><strong><?php echo Mage::helper('sales')->__('Phone No') ?></strong></td>
                    <td class="value"><?php echo $this->getOrder()->getThirdpartyPhoneNo(); ?></td>
                </tr>
                <tr>
                    <td style="width:20%" class="label"><strong><?php echo Mage::helper('sales')->__('Comments') ?></strong></td>
                    <td class="value"><?php echo $this->getOrder()->getThirdpartyComment(); ?></td>
                </tr>
            </table>
        </div>
    </div>
</div>
<div class="clear"></div>


and we need to write pickup/sales/order/info.phtml below code

<?php echo $this->getChildHtml('order_info2'); ?>
<?php echo $this->getChildHtml('custom.order');?>

and finally we need to copy sales/order/view/tab/info.phtml to paste pickup/sales/order/view/tab/info.phtml .



Advanced Shipping Method Module
If you have any queries leave a comment.

No comments:

Post a Comment