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 2 of 2
Making new module from magento ? 
 
pengo
Jr. Member
 
Total Posts:  4
Joined:  2008-05-29
 

my system.xml file has 6 fields for the differents methods and prices they call name1, name2, name3, price1, price2, price3.

<name1 translate="label">
                            <
label>Metodo 1</label>
                            <
frontend_type>text</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>
                        </
name1>
                        <
price1 translate="label">
                            <
label>Precio 1</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>4</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
price1>
                        
                        <
name2 translate="label">
                            <
label>Metodo 2</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>5</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
name2>
                        <
price2 translate="label">
                            <
label>Precio 2</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>6</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
price2>
                        
                        <
name3 translate="label">
                            <
label>Metodo 3</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>
                        </
name3>
                        <
price3 translate="label">
                            <
label>Precio 3</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>8</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
price3>

Do you know what problem could be?

PD: sorry for my english.

 
Magento Community Magento Community
Magento Community
Magento Community
 
alkarim
Guru
 
Total Posts:  368
Joined:  2008-04-10
 

hi @pengo,
there need different name of $method to make different shipping rate,

$price[0] 10;
$price[1] 20;
$price[2] 30;
for(
$i 1$i <= 3$i++)
        
{
            $shippingPrice 
$this->getConfigData('price'.$i);
            
            if(
$shippingPrice)
            
{                
                $method[$i] 
Mage::getModel('shipping/rate_result_method');
                
$method[$i]->setCarrier('flatrate2');
                
$method[$i]->setCarrierTitle($this->getConfigData('title'));
                
$method[$i]->setMethod('flatrate2');
                
$method[$i]->setMethodTitle($this->getConfigData('name'.$i));
                
$method[$i]->setPrice($price[$i]);
                
$method[$i]->setCost($shippingPrice);
                
                
$result->append($method[$i]);
            
}
        }
 
Magento Community Magento Community
Magento Community
Magento Community
 
pengo
Jr. Member
 
Total Posts:  4
Joined:  2008-05-29
 

Hi again @alkarim and thanks for your reply,

I tryed your code, but it doesn’t worked, it had the same problem than my code.

I have modified tweakmag’s shipping module code, it’s very similar, has AIR and SEA shipping rates, but they take this rates from a http-request, and I’m taking the values from my xml config file, the same problem happends when I try to set the values in the carrier model file (.php).

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
pengo
Jr. Member
 
Total Posts:  4
Joined:  2008-05-29
 

it’s me again, I found my mistake, te problem was the setMethod parameter, I always give the same parameter for all methods, so the module always take the same rate.

I change this line

$method->setMethod('modoenvio');

to this

$method->setMethod($this->getConfigData('name'.$i));

and it’s works perfectly.

Thanks for your help!

 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

@ pengo:  I did what you did but mine does not show up as an option on the frontend, only the backend ... can you help?  This is what I have:

app/code/core/Mage/Shipping/etc/config.xml

<carriers>
            <
flatrate>
                <
active>1</active>
                <
sallowspecific>0</sallowspecific>
                <
model>shipping/carrier_flatrate</model>
                <
name>Fixed</name>
                <
price>5.00</price>
                <
title>Flat Rate</title>
                <
type>I</type>
                <
specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping methodplease contact us.</specificerrmsg>
                <
handling_type>F</handling_type>
            </
flatrate>
        <
Flatrate2>
                <
active>1</active>
                <
sallowspecific>0</sallowspecific>
                <
model>shipping/carrier_flatrate2</model>
                <
name>Fixed</name>
                <
price>5.00</price>
                <
title>Flat Rate 2</title>
                <
type>I</type>
                <
specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping methodplease contact us.</specificerrmsg>
                <
handling_type>F</handling_type>
        </
Flatrate2>

            <
freeshipping>
                <
active>0</active>
                <
sallowspecific>0</sallowspecific>
                <
cutoff_cost>50</cutoff_cost>
                <
model>shipping/carrier_freeshipping</model>
                <
name>Free</name>
                <
title>Free Shipping</title>
                <
specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping methodplease contact us.</specificerrmsg>
            </
freeshipping>
 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

app/code/core/Mage/Shipping/etc/system.xml

<groups>
                <
flatrate2 translate="label">
                    <
label>Pickup at Event</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>
                    <
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>
                       <
name1 translate="label">
                            <
label>Event 1</label>
                            <
frontend_type>text</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>
                        </
name1>
                        <
price1 translate="label">
                            <
label>Price 1</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>4</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
price1>
                        
                        <
name2 translate="label">
                            <
label>Event 2</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>5</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
name2>
                        <
price2 translate="label">
                            <
label>Price 2</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>6</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
price2>
                        
                        <
name3 translate="label">
                            <
label>Event 3</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>
                        </
name3>
                        <
price3 translate="label">
                            <
label>Price 3</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>8</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
                        </
price3
                        <
handling_type translate="label">
                            <
label>Calculate Handling Fee</label>
                            <
frontend_type>select</frontend_type>
                            <
source_model>shipping/source_handlingType</source_model>
                            <
sort_order>9</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>0</show_in_store>
                        </
handling_type>
                        <
handling_fee translate="label">
                            <
label>Handling Fee</label>
                            <
frontend_type>text</frontend_type>
                            <
sort_order>10</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>
 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

Actually ... disregard my last two posts.  I figured out the reason it wasn’t working was because I was using 0.00 for the price.  How do I modify it so the price can be 0.00?  I have it at 0.00 in another shipping module, but the coding is different.

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