4

I created previously custom payment methods.For that I added successfully extra fields using following code in my model logic.

protected $_formBlockType = 'newmodule/purchaseorder';
protected $_infoBlockType = 'newmodule/purchaseorderinfo';

But magento didn't provide any logic for creating forms in shipping module. Please give me some direction to this?

2

It's not intended. If you look at the template app/design/frontend/base/default/template/checkout/onepage/shipping_method/available.phtml which shows the available shipping methods, no additional blocks are loaded and there is no kind of hook to change the HTML either. You would have to replace this template and implement something on your own.

Another possibility is to add custom fields to the shipping_method form that are not related to a specific shipping method, in the block checkout.onepage.shipping_method.additional. Unfortunately this one doesn't render its children by default, like I would expect from an "additional" block, but this requires only little change:

Copy app/design/frontend/base/default/template/checkout/onepage/shipping_method/additional.phtml, add echo $this->getChildHtml() at the end and replace it in your modules layout XML file.

Then you can add new blocks inside it with anything you want. You could also use JavaScript to display the form only if a specific shipping method is selected.

1

Now we can create brst_shipping.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Brst_Shipping>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Shipping />
            </depends>
        </Brst_Shipping>
    </modules>
</config>

let’s make our module configurable in the admin panel by copying the following into app/code/local/Brst/Shipping/etc/system.xml: Smashing Magazine Carrier text 2 1 1 1

                        This shipping carrier abstract checks
                        this value to determine whether
                        the carrier should be shown.
                    -->
                    <active translate="label">
                        <label>Enabled</label>
                        <frontend_type>select</frontend_type>
                        <source_model>adminhtml/system_config_source_yesno</source_model>
                        <sort_order>1</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>0</show_in_store>
                    </active>
                    <!--
                        This value can be used to specify a
                        custom title for our method.
                    -->
                    <title translate="label">
                        <label>Title</label>
                        <frontend_type>text</frontend_type>
                        <sort_order>2</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </title>
                    <!--
                        The sort order is used in Magento
                        to determine what order the carrier
                        will appear in relative to the
                        other carriers available.
                    -->
                    <sort_order translate="label">
                        <label>Sort Order</label>
                        <frontend_type>text</frontend_type>
                        <sort_order>100</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>0</show_in_store>
                    </sort_order>
                    <!--
                        This value is used to specify whether
                        the carrier is available only for
                        specific countries or all countries
                        available in the current Magento
                        installation.
                    -->
                    <sallowspecific translate="label">
                        <label>Ship to Applicable Countries</label>
                        <frontend_type>select</frontend_type>
                        <sort_order>90</sort_order>
                        <frontend_class>shipping-applicable-country</frontend_class>
                        <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>0</show_in_store>
                    </sallowspecific>
                    <!--
                        If 'specific countries' is chosen
                        in the previous option, then this field
                        allows the administrator to specify
                        which specific countries this carrier
                        should be available for.
                    -->
                    <specificcountry translate="label">
                        <label>Ship to Specific Countries</label>
                        <frontend_type>multiselect</frontend_type>
                        <sort_order>91</sort_order>
                        <source_model>adminhtml/system_config_source_country</source_model>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>0</show_in_store>
                        <can_be_empty>1</can_be_empty>
                    </specificcountry>
                </fields>
            </brst_shipping>
        </groups>
    </carriers>
</sections>

You can creating forms in shipping module by the above system.xml file. Hope this will help you.

  • thanks for your response.But you misunderstood my question.I'm asking custom form fields at shipping method(checkout) in front end – sivakumar Jul 10 '14 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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