Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

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
Member
 
Total Posts:  32
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;
        
}
        
        
//The the destination Zip Code
        
$toZipCode $request->getDestPostcode();
        
//Retrieve each of the valid strings of zip codes
        
$validZipString1 $this->getConfigData('tier1zips');
        
$validZipString2 $this->getConfigData('tier2zips');
        
$validZipString3 $this->getConfigData('tier3zips');
        
//Turn them into arrays
        
$validZips1 explode(","$validZipString1);
        
$validZips2 explode(","$validZipString2);
        
$validZips3 explode(","$validZipString3);
        
        
//Set up our found flags to see if we have a match
        
$foundValid1 false;
        
$foundValid2 false;
        
$foundValid3 false;
<Continued>
 
Magento Community Magento Community
Magento Community
Magento Community
 
MunchyMonster
Member
 
Avatar
Total Posts:  71
Joined:  2008-02-05
New Hampshire, USA
 

<continued>

//Search tier 1 for a match
        foreach ($validZips1 as $validZip1)
        
{
            
if($validZip1 == $toZipCode)
            
{
                $foundValid1 
true;
                break;
            
}
        }
        
if(!$foundValid1)
        
{
        
//if it wasn't in tier 1 search tier 2
            
foreach ($validZips2 as $validZip2)
            
{
                
if($validZip2 == $toZipCode)
                
{
                    $foundValid2 
true;
                    break;
                
}
            }
            
if(!$foundValid2)
            
{
            
//if it wasn't in tier 2 search tier 3
                
foreach ($validZips3 as $validZip3)
                
{
                    
if($validZip3 == $toZipCode)
                    
{
                        $foundValid3 
true;
                        break;
                    
}
                }
                
if(!$foundValid3)
                
{
                
//if it wasn't in tier 3 then we can't provide Local Delivery
                    
return false;
                
}
                
else
                
{
                
//Found it so charge tier 3 delivery rate
                    
$shippingPrice $this->getConfigData('tier3rate');
                
}
            }
            
else
            
{
            
//Found it so charge tier 2 delivery rate
                
$shippingPrice $this->getConfigData('tier2rate');
            
}
        }
        
else
        
{
        
//Found it so charge tier 1 delivery rate
             
$shippingPrice $this->getConfigData('tier1rate');
        
}
        
        
//if we get to here we should have a valid $shippingPrice
        
$result Mage::getModel('shipping/rate_result');
        
$method Mage::getModel('shipping/rate_result_method');

        
//add the handling fee if needed
        
$shippingPrice += $this->getConfigData('handling_fee');

        
$method->setCarrier('localdelivery');
        
$method->setCarrierTitle($this->getConfigData('title'));

        
$shipping_method "Delivery Fee(" $toZipCode ")";
        
        
$method->setMethod($shipping_method);
        
$method->setMethodTitle("$shipping_method");

        
$method->setPrice($shippingPrice);
        
$method->setCost($shippingPrice);
        
$result->append($method);

        return 
$result;
    
}

    
/**
     * Get allowed shipping methods
     *
     * @return array
     */
    
public function getAllowedMethods()
    
{
    
//we only have one method so just return the name from the admin panel
        
return array('localdelivery' => $this->getConfigData('name'));
    
}

}
Obviously if you were writing your own code you would simply go in and replace all the references to Momsmunchies with <YOUR COMPANY NAME> and all the references to Localdelivery with <YOUR SHIPPING METHOD>.  After you get this working in the backend/admin and the store/frontend, I’d suggest doing just that to make sure you can find all the files and directories that need to be renamed as well as all the places within the files.  When in doubt sprinkle print statements everywhere so you can follow the progress of the code.  It isn’t pretty, but it can be informative.

Some of you may have noticed the http://www.MomsMunchies.com in the code.  This is our current store front.  It is NOT a Magento site.  I am doing all of my Magento development separate from our current production site and have a few custom modules to write and need “Bundles” from the Magento team before I can even think about deploying Magento for production use.

Hopefully this helps someone.  If anyone can figure out the differences between this and the Wiki Tutorial, please post them here or make the changes to the wiki itself.  I’ll using these instruction in the next few days to see if I can duplicate this accomplishment from scratch.  Wish me luck.

-MunchyMonster

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tweakmag
Guru
 
Avatar
Total Posts:  307
Joined:  2007-08-31
London, UK
 

Glad my code assisted you smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
redpen
Sr. Member
 
Total Posts:  254
Joined:  2008-01-23
 

Thanks for documenting this.  I’ve been through your example, but can’t get it to appear on the frontend at all.  I followed your instructions to the letter, and have refreshed the cache.

All I want is to duplicate the Flat Rate modules a few times, that’s all I need… :/

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagNewby
Jr. Member
 
Total Posts:  1
Joined:  2008-05-17
 

Hello

I was also trying quite a bit. Finally I got it. My shipping method is also shown in the frontend. Even the example above did not work.

Some hints for others:
- for names and folder names: if in the example is used a big letter at the start, use also one big letter. Don’t use more than one big letters.
- one possible reason can be, that there is an error in the \model\carrier\xxx.php file
- if you have long names start them differently

I don’t know, what exactly helped at the end.

 
Magento Community Magento Community
Magento Community
Magento Community
 
cooper
Sr. Member
 
Total Posts:  104
Joined:  2008-03-31
 

Hello,

I have followed these instructions to the letter but even everything seems to have worked in the admin panel, I have this error in the frontend :

getConfigFlag('active')) return false//The the destination Zip Code $toZipCode = $request->getDestPostcode(); //Retrieve each of the valid strings of zip codes $validZipString1 = $this->getConfigData('tier1zips'); $validZipString2 = $this->getConfigData('tier2zips'); $validZipString3 = $this->getConfigData('tier3zips'); //Turn them into arrays $validZips1 = explode(",", $validZipString1); $validZips2 = explode(",", $validZipString2); $validZips3 = explode(",", $validZipString3); //Set up our found flags to see if we have a match $foundValid1 = false; $foundValid2 = false; $foundValid3 = false; //Search tier 1 for a match foreach ($validZips1 as $validZip1) { if($validZip1 == $toZipCode) { $foundValid1 = true; break; } } if(!$foundValid1) { //if it wasn't in tier 1 search tier 2 foreach ($validZips2 as $validZip2) { if($validZip2 == $toZipCode) { $foundValid2 = true; break; } } if(!$foundValid2) { //if it wasn't in tier 2 search tier 3 foreach ($validZips3 as $validZip3) { if($validZip3 == $toZipCode) { $foundValid3 = true; break; } } if(!$foundValid3) { //if it wasn't in tier 3 then we can't provide Local Delivery return false; } else { //Found it so charge tier 3 delivery rate $shippingPrice = $this->getConfigData('tier3rate'); } } else { //Found it so charge tier 2 delivery rate $shippingPrice = $this->getConfigData('tier2rate'); } } else { //Found it so charge tier 1 delivery rate $shippingPrice = $this->getConfigData('tier1rate'); } //if we get to here we should have a valid $shippingPrice $result = Mage::getModel('shipping/rate_result'); $method = Mage::getModel('shipping/rate_result_method'); //add the handling fee if needed $shippingPrice += $this->getConfigData('handling_fee'); $method->setCarrier('localdelivery'); $method->setCarrierTitle($this->getConfigData('title')); $shipping_method = "Delivery Fee(" . $toZipCode . ")"; $method->setMethod($shipping_method); $method->setMethodTitle("$shipping_method"); $method->setPrice($shippingPrice); $method->setCost($shippingPrice); $result->append($method); return $result; } /** * Get allowed shipping methods * * @return array */ public function getAllowedMethods() { //we only have one method so just return the name from the admin panel return array('localdelivery' => $this->getConfigData('name')); } } æˆ¼â²ã¸¯ã°Šã¹¢æ…†æ…´â¬ç‰¥æ½²ã±²æˆ¯ã¨¾â€ æ…ƒæ±¬ç â¯â¡æ•­æ‰­ç‰¥æ˜ æ¹µç‘£æ½©â®æ•³å´æ½´æ•²â¤¨æ¼ â®â¡æ½®âµ®æ‰¯æ•ªç‘£æ¤ â®æˆ¼äŒ¾å°ºæ…¸ç­æ±°ç‘©å±¥ç‘¨æ½¤ç£æµœæ¡æ¹¥æ½´æ…œç°æœæ‘¯å±¥æ½£æ•²äµœæ¡å±¥æ¡“灩楰杮䵜摯汥卜楨灰湩⹧桰㱰戯‾湯氠湩⁥戼ㄾㄷ⼼㹢戼⁲㸯

and I have no idea why.....  confused

 
Magento Community Magento Community
Magento Community
Magento Community
 
WebShopApps
Guru
 
Avatar
Total Posts:  460
Joined:  2008-05-30
London, UK
 

Thanks all for the info here, it certainly helped me get it working.  The wiki example definitely needs updating as there is quite a bit of important information missing.

I’ve managed to sucessfully add Special Delivery for UK shipping as another version of flatrate. But what I am finding now is that the Google API section isn’t working.  I’ve fiddled with it a bit and it seems that this section relies on the carrier being in core - or am I missing something?  I copied the new shipping php file to core, and now get a blank page when I go into Google API!  I reckon I will need to add the shipping method directly under core and take the consequences of an upgrade.  Has anyone else had ths problem and got round it?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2