Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

Magento Forum

   
Page 1 of 2
How to get shipping module to show up in frontend…
 
MunchyMonster
Member
 
Avatar
Total Posts:  71
Joined:  2008-02-05
New Hampshire, USA
 

I’ve followed the instructions in the Custom Shipping Module wiki (http://www.magentocommerce.com/wiki/how-to/create-shipping-method-module).  I’ve got my brand spanking new shipping module showing up quite nicely in the admin interface.  But I can’t seem to get it to display in the cart or checkout pages.  I’ve gone into the admin and enabled it.  I just can’t figure out why it isn’t coming up.  I know it must be a small thing, but I’m missing it. 

Of course it might be the fact that it is after 1:00am local time.  Maybe I just need a little sleep and all will be clear in the morning.

If anyone has a hint, please share.

MunchyMonster

 
Magento Community Magento Community
Magento Community
Magento Community
 
MunchyMonster
Member
 
Avatar
Total Posts:  71
Joined:  2008-02-05
New Hampshire, USA
 

Well I might as well chronical my adventures here in the hope that some wayward soul might be saved the trouble of trying the things that didn’t work.

I got a little overzealous on my first attempt.  I tried to replace Mage with my company name and replace NewModule with my module name (LocalDelivery).  Like I said before to my shock and amazement this seemed to have worked.  My LocalDelivery module showed up in the Admin section and I enabled it.  I went back to the cart and added a few items and tried to get a quote for shipping.  No Local Delivery option.  Ok, so I figured maybe it just isn’t set up right for rendering a quote.  I’ll look into the checkout and see if it shows up there.  I proceed through the multiple levels of checkout and got to the shipping method tab.  No Local Delivery option.  I thrashed about for awhile trying different things.  As I mentioned before, it was 1:00am when I gave up and went to bed.

Second try was tonight.  I saved my original stuff off in a new folder in case I wanted it back and wiped the old folders.  This time I followed the tutorial to the letter.  I called everything the same thing the tutorial did and I copied the code blocks directly from the tutorial into the appropriate files on my site.  Again everything seems to have worked in the admin panel.  The “NewModule” module has taken the place of the LocalDelivery Module that I removed.  I have activated it and I still don’t see it from the Get a Quote or Shipping Method areas of the website.

Figuring that FlatRate had to be the simplest shipping module there could be, I copied the body of flatrate.php into my ShippingMethod.php and changed all the Flatrates to Newmodules (being careful to match case in my replacements).  That didn’t help any either.  I then changed my system.xml to match the flatrate section from the “global” system.xml file.  The fields in the admin section changed just as you would expect they would, but still no luck getting the frontend to show any interest in my new module.  Caches have been cleared repeatedly and doing so hasn’t fixed anything yet.

Anybody had any luck getting a custom shipping module to show up in the frontend?  What’s the magic incantation?

MunchyMonster

 
Magento Community Magento Community
Magento Community
Magento Community
 
MunchyMonster
Member
 
Avatar
Total Posts:  71
Joined:  2008-02-05
New Hampshire, USA
 

GOOD NEWS!!!  cheese

I got something to show up on the front end and in the admin section!  Yoohoo!

Bad news downer

I cheated.  I duplicated the Flate Rate shipping module.  I did a search and anywhere I found something that said Flate Rate I made a copy and called it Flate Rate2.  So a technical victory, but not exactly what I wanted.  If I’m not mistaken, my module lives in constant fear of the next upgrade.  Waiting for the time when he will be wiped out by some “official” Flate Rate2 module.

My next goal is to move my Flate Rate2 module to the safety of the local area where he can frolic and play free from the worry of an impending upgrade.  Keep your fingers crossed that I can get it show in the front end after the move.

MunchyMonster

 
Magento Community Magento Community
Magento Community
Magento Community
 
MunchyMonster
Member
 
Avatar
Total Posts:  71
Joined:  2008-02-05
New Hampshire, USA
 

Thanks to TweakMag’s Autralian Post shipping Module I have finally made a first cut at a working module that seems to do what I want.  I’ve got to clean up the code, but I’ll be revising the Shipping Module tutorial in the wiki as as soon as I figure out all the steps, and get half a chance to write them all down.  I want to see how much of the stuff I really need and how much is just there for the sake of “If aint broke, don’t fix it”.  All in all this is good news.  I’ll post back as soon as I get my notes together and get the wiki updated.

MunchyMonster

 
Magento Community Magento Community
Magento Community
Magento Community
 
evL
Jr. Member
 
Total Posts:  29
Joined:  2008-04-23
 

Can you explain in short words the steps you took to make it appear on the frontend ?!

I took all the shipping methods included with Mage, duplicated it in the local folder but still, it doesn’t show in the frontend ... I believe I am missing something in my config.xml ....

 
Magento Community Magento Community
Magento Community
Magento Community
 
MunchyMonster
Member
 
Avatar
Total Posts:  71
Joined:  2008-02-05
New Hampshire, USA
 

I’m going to post a change to the wiki as soon as I get time, but I want to make sure that I have the minimal amount of stuff that needs to be included and then follow my own directions to make another module to make sure I can make it work.  But…

If you need to get something working quickly and can’t wait for me to confirm that what I did is working, I started with TweakMag’s Shipping Module in the Magento Connect area.  Installation was straightforward and once I had it in my directory structure a quick search on the word tweakmag let me find all the files he had touched to get his stuff working.  Once I knew all the files he touched I just duplicated the changes and added my own business logic.  Start there.

I should have my tutorial posted in the next few days.

MunchyMonster

 
Magento Community Magento Community
Magento Community
Magento Community
 
MunchyMonster
Member
 
Avatar
Total Posts:  71
Joined:  2008-02-05
New Hampshire, USA
 

Here’s my first cut.  I’m not posting this to the wiki yet because I’m not sure how this differs from what the wiki article says to do.  Also before anyone starts thinking that I figured this out all by myself I want to make sure TweakMag gets some credit.  I dissected his Australian Post module to figure out how to make things work for my code.  My Shipping Module is a simple module that allows the user to select our delivery service if the recipient is local to our production facility.  I have defined 3 “tiers” of delivery service allowing us to provide differing prices as our prospective delivery customer is farther and farther away.  But now to the meat:

To define a custom shipping module you will need to create 4 files.  Start with our sample Local Delivery module and go from there.  I might warn you that captilization seems to be important.  Be careful to name things consistently.  As Magento seems to use the names to infer directory structure (this is a total guess based on observation, not testing).

The first file you need should be created in app/etc/modules for this example call the file Momsmunchies_Shipping.xml.  Paste this into the file:

<?xml version="1.0"?>
<!--
/**
 * Magento Momsmunchies Shipping
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @category   Momsmunchies
 * @package    Momsmunchies_Shipping
 * @copyright  Copyright (c) 2008 Momsmunchies (http://www.momsmunchies.com)
 * @author       Michael Caron (mcaron@adelphia.net)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
-->
<
config>
    <
modules>
        <
Momsmunchies_Shipping>
            <
active>true</active>
            <
codePool>community</codePool>
        </
Momsmunchies_Shipping>
    </
modules>
</
config>
That tells magento where to find our module and that it should be activated for use in the admin panel (If anyone catches me in an untruth PLEASE rat me out).

<Continued in the next post>

 
Magento Community Magento Community
Magento Community
Magento Community
 
MunchyMonster
Member
 
Avatar
Total Posts:  71
Joined:  2008-02-05
New Hampshire, USA
 

The second file needs to be created in app/code/community/Momsmunchies/Shipping/etc for this example call the file config.xml (please take note of the case I believe it is important for both the file and directory structure).  Put this information in it:

<?xml version="1.0"?>
<!--
/**
 * Magento Momsmunchies Shipping Module
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @category   Momsmunchies
 * @package    Momsmunchies_Shipping
 * @copyright  Copyright (c) 2008 Mom's Munchies (http://www.Momsmunchies.com)
 * @author       Michael Caron (mcaron@adelphia.net)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
-->
<
config>
    <
modules>
        <
Momsmunchies_Shipping>
            <
version>0.1.0</version>
            <
depends>
                <
Mage_Shipping />
            </
depends>
        </
Momsmunchies_Shipping>
    </
modules>
    <global>
        <
models>
            <
mmshipping>
                <class>
Momsmunchies_Shipping</class>
            </
mmshipping>
        </
models>
        <
resources>
            <
mmshipping_setup>
                <
setup>
                    <
module>Momsmunchies_Shipping</module>
                </
setup>
                <
connection>
                    <use>
directory_setup</use>
                </
connection>
            </
mmshipping_setup>
            <
mmshipping_read>
                <
connection>
                    <use>
local_read</use>
                </
connection>
            </
mmshipping_read>
        </
resources>
        <
sales>
            <
shipping>
                <
carriers>
                    <
localdelivery>
                        <class>
Momsmunchies_Shipping_Model_Carrier_Localdelivery</class>
                    </
localdelivery>
                </
carriers>
            </
shipping>
        </
sales>
    </global>

    <default>
        <
carriers>
            <
localdelivery>
                <
active>0</active>
                <
model>momsmunchies_shipping_model_carrier_localdelivery</model>
                <
name>Local Delivery (Momsmunchies)</name>
                <
title>Local Delivery</title>
                <
handling_fee>0</handling_fee>
                <
specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping methodplease contact us.</specificerrmsg>
            </
localdelivery>
        </
carriers>
    </default>
</
config>
This file tells Magento about your module and allows you to set some default values for the data items.

<Continued Next Post>

 
Magento Community Magento Community
Magento Community
Magento Community
 
MunchyMonster
Member
 
Avatar
Total Posts:  71
Joined:  2008-02-05
New Hampshire, USA
 

The third file needs to be created in app/code/community/Momsmunchies/Shipping/etc for this example call the file system.xml (please take note of the case again I believe it is important for both the file and directory structure).  Put this information in it:

<?xml version="1.0"?>
<!--
/**
 * Magento Momsmunchies Shipping Module
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @category   Momsmunchies
 * @package    Momsmunchies_Shipping
 * @copyright  Copyright (c) 2008 Momsmunchies (http://www.Momsmunchies.com)
 * @author       Michael Caron (mcaron@adelphia.net)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
-->
<
config>
    <
sections>
        <
carriers>
            <
groups>
                <
localdelivery translate="label" module="shipping">
                    <
label>Local Delivery (Powered by Momsmunchies)</label>
                    <
frontend_type>text</frontend_type>
                    <
sort_order>1</sort_order>
                    <
show_in_default>1</show_in_default>
                    <
show_in_website>1</show_in_website>
                    <
show_in_store>1</show_in_store>
                    <
fields>
                        <
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>1</show_in_store>
                        </
active>
                        <
handling_fee translate="label">
                            <
label>Handling Fee</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>7</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
handling_fee>
                        <
tier1zips translate="label">
                            <
label>Tier 1 Zip Codes</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>20</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
tier1zips>
                        <
tier1rate translate="label">
                            <
label>Tier 1 Delivery Charge</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>21</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
tier1rate>
                        <
tier2zips translate="label">
                            <
label>Tier 2 Zip Codes</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>22</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
tier2zips>
                        <
tier2rate translate="label">
                            <
label>Tier 2 Delivery Charge</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>23</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
tier2rate>
                        <
tier3zips translate="label">
                            <
label>Tier 3 Zip Codes</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>24</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
tier3zips>
                        <
tier3rate translate="label">
                            <
label>Tier 3 Delivery Charge</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>25</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
tier3rate>
                        <
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>1</show_in_store>
                        </
sort_order>
<Continued>

 
Magento Community Magento Community
Magento Community
Magento Community
 
MunchyMonster
Member
 
Avatar
Total Posts:  71
Joined:  2008-02-05
New Hampshire, USA
 

<Continued>

<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>
                        <
showmethod translate="label">
                            <
label>Show method if not applicable</label>
                            <
frontend_type>select</frontend_type>
                            <
sort_order>92</sort_order>
                            <
source_model>adminhtml/system_config_source_yesno</source_model>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
showmethod>
                        <
specificerrmsg translate="label">
                            <
label>Displayed Error Message</label>
                            <
frontend_type>textarea</frontend_type>
                            <
sort_order>93</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
specificerrmsg>
                    </
fields>
                </
localdelivery>
            </
groups>
        </
carriers>
    </
sections>
</
config>
This file tells Magento how to layout the configuration page in the admin panel.

The fourth and final file is where all the magic happens.  This is where your module does whatever it is you module is supposed to do.  It needs to be created in app/code/community/Momsmunchies/Shipping/Model/Carrier and should be called Localdelivery.php (this might be total voodoo here, but please take note of the case AGAIN.  I believe it is important for both the file and directory structure).  I wrote this code to do a simple check against a list of comma separated Zip Code in one of three tiers and then apply the correct delivery rate based on the tier the zip code match was found in.  This code will be cleaned up to match the country and state as well, but for now it serves as a good demonstration of how to add some simple custom code.  Take this code and paste it into the file we just created:

<?php
/**
 * Magento MomsMunchies Shipping Module
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @category   MomsMunchies
 * @package    MomsMunchies_Shipping
 * @subpackage Local Delivery
 * @copyright  Copyright (c) 2008 MomsMunchies (http://www.MomsMunchies.com)
 * @author       Michael Caron (mcaron@adelphia.net)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */



class MomsMunchies_Shipping_Model_Carrier_Localdelivery
    
extends Mage_Shipping_Model_Carrier_Abstract
    
implements Mage_Shipping_Model_Carrier_Interface


    
protected $_code 'localdelivery';

    
/**
     * Collects the shipping rates for local delivery from our setting in the admin.
     *
     * @param Mage_Shipping_Model_Rate_Request $request
     * @return Mage_Shipping_Model_Rate_Result
     */
    
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    
{
        
// Check if this method is active
        
if (!$this->getConfigFlag('active'))
        
{
            
return false;