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

Help with shipp module
 
licentia
Sr. Member
 
Avatar
Total Posts:  78
Joined:  2007-08-31
Portugal
 

Hi,

I’m trying to develop a shipping module, I’ve successfully configured the admin section, and there everything works fine.

But on checkout process the carrier don’t get listed.

As far I can tell, my carrier it’s even called (added a die on the construct but the script don’t stop)

I’m following the Magento existing modules to create my own.

Any help will be appreciated.

my config.xml

<config>
    <
modules
        <
Mage_Ctt>
            <
version>0.1.0</version>
            <
depends>
                <
Mage_Sales />
                <
Mage_Shipping />
            </
depends>
        </
Mage_Ctt>
    </
modules>
    <global>
        <
resources>
            <
ctt_setup>
                <
setup>
                    <
module>Mage_Ctt</module>
                </
setup>
                <
connection>
                    <use>
directory_setup</use>
                </
connection>
            </
ctt_setup>
            <
ctt_read>
                <
connection>
                    <use>
core_read</use>
                </
connection>
            </
ctt_read>
        </
resources>
        <
models>
            <
ctt>
                <class>
Mage_Ctt_Model</class>
            </
ctt>
        </
models>
        <
sales>
            <
shipping>
                <
carriers>
                    <
ctt>
                        <class>
Mage_Ctt_Model_Shipping_Carrier_Ctt</class>
                    </
ctt>
                </
carriers>
            </
shipping>
            <
tax>
                <
methods>
                    <
ctt>
                        <class>
Mage_Ctt_Model_Tax_Ctt</class>
                    </
ctt>
                </
methods>
            </
tax>
        </
sales>
    </global></
config>

Mage/Ctt/Model/Shipping/Carrier/Ctt.php

class Mage_Ctt_Model_Shipping_Carrier_Ctt
    
extends Mage_Shipping_Model_Carrier_Abstract
    
implements Mage_Shipping_Model_Carrier_Interface
{
 
 
    
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    
{
        $result 
Mage::getModel('shipping/rate_result');
 
        foreach(
$this->getAllowedMethods() as $shipping_method)
        
{
            $shippingPrice 
23;
            
$method Mage::getModel('shipping/rate_result_method');
            
$method->setCarrier('ctt');
            
$method->setCarrierTitle($this->getConfigData('title'));
            
$method->setMethod($shipping_method);
            
$method->setMethodTitle($this->getConfigData('name') . $shipping_method );
            
$method->setPrice($shippingPrice);
            
$method->setCost($shippingPrice);

            
$result->append($method);
        
}
        
        
return $result;
    
}

   
public function getAllowedMethods()
    
{
        $allowed 
explode(','$this->getConfigData('allowed_methods'));
        
$arr = array();
        foreach (
$allowed as $k{
            $arr[$k] 
$this->getCode($k);
        
}
        
return $arr;
    
}

    
    
public function getCode($code=7)
    
{
        $codes 
= array(
            
1'Nac. - Correio Verde',
            
2'Nac. - Prioritario (Azul)',
            
3'Nac. - Correio Registado Simples',
            
4'Nac. - Correio Registado Em M&atilde;o',
            
5'Nac. - Correio Registado Pessoal',
            
6'Nac. - N&atilde;o Priorit&aacute;rio',
            
7'Nac. - Encomenda Nac.',
            
8'Inter. - Correio Verde',
            
9'Inter. - Correio Azul Priorit&aacute;rio',
            
10'Inter. - Correio Azul Prime',
            
11'Inter. - Correio N&atilde;o Priorit&aacute;rio (Avi&atilde;o)',
            
12'Inter. - Correio N&atilde;o Priorit&aacute;rio (Econ&oacute;mico)',
            
13'Inter. - Encomenda Inter.',
            
14'Inter. - Correio Registado Em M&atilde;o',
            
15'Inter. - Correio Registado Pessoal',
            
16'Nac. Urg. - Cont. - Dia Seguinte - EMS 9',
            
17'Nac. Urg. - Cont. - Dia Seguinte - EMS 12',
            
18'Nac. Urg. - Cont. - Dia Seguinte - EMS 18',
            
19'Nac. Urg. - Cont. - 3 Dias &Uacute;teis - Quick Nac.',
            
20'Nac. Urg. - Cont. - ILHAS - EMS Ilhas',
            
21'Nac. Urg. - Cont. - ILHAS - Quick Nac.',
            
22'Inter. Urg. - Europa',
            
23'Inter. Urg. - Resto do Mundo'

        
);

        return 
$codes[$code];
    
}
}

Mage/Ctt/Helper/Data.php and Mage/Ctt/Model/Tax/Ctt.php will only extend the abstract class

Check the next post for the system.xml

 
Magento Community Magento Community
Magento Community
Magento Community
 
licentia
Sr. Member
 
Avatar
Total Posts:  78
Joined:  2007-08-31
Portugal
 

system.xml

<config>
    <
sections>
        <
carriers>
            <
groups>
                <
ctt translate="label" module="ctt">
                    <
label>Envio Ctt</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>
                        <
name translate="label">
                            <
label>Method name prefix</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>
                        </
name>
                        <
allowed_methods translate="label">
                            <
label>Allowed methods</label>
                            <
source_model>Mage_Ctt_Model_Source_Type</source_model>
                            <
frontend_type>multiselect</frontend_type>
                            <
sort_order>3</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
allowed_methods>
                        <
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>
                        <
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>
                        <
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>
                        <
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>1</show_in_store>
                        </
sallowspecific>
                        <
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>1</show_in_store>
                        </
specificcountry>
                        <
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>
                </
ctt>
            </
groups>
        </
carriers>
    </
sections>
</
config>

The module is active.

Best Regards,

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

I’m working on this problem over in this thread (http://www.magentocommerce.com/boards/viewthread/7247/).  Unfortunately I don’t have any responses yet.  I’ve been listing what I’ve done as I try different things hoping to save someone the trouble later on.  If I find an answer I will post it on my thread and drop a pointer to it over here.

MunchyMonster

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top