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 3
Disable other shipping methods when free shipping is available
 
PitchOu
Member
 
Total Posts:  39
Joined:  2008-02-04
Villeneuve d'Ascq, France
 

Hi all !

All is in the title ... if free shipping is available for an order (price > min price configured) it’s strange to propose other shipping methods.

So how would it be possible to show only free shipping option ?

Thanks !

 
Magento Community Magento Community
Magento Community
Magento Community
 
radders
Sr. Member
 
Total Posts:  162
Joined:  2008-03-23
 

Maybe this will be possible once they implement the shopping cart rules correctly.

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

Hi there - I have done this with my tweakmag_shipping extension (available on connect). What it allows you to do is set a minimum and maximum order value for the shipping method to be active. This way you can chain as many shipping methods together as you like. For example:

1 Australia Post - min. 0 max 299.99
2. Free Shipping - min 300

So you can see that free shipping becomes available and Australia Post no longer shows, I will be adding more methods shortly.
Cheers
Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
PitchOu
Member
 
Total Posts:  39
Joined:  2008-02-04
Villeneuve d'Ascq, France
 

Finally I managed to do this changing app/design/frontend/default/default/template/checkout/cart/shipping.phtml around line 52 :

<dl class="shipment-methods">
<?php $freeOnly = False; ?>
<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
<?php if ( $code == "freeshipping") {$freeOnly = True;}?>
<?php endforeach; ?>

<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
<?php if (( $freeOnly == False) || ( ( $freeOnly == True ) && ( $code == "freeshipping" ) )): ?>
<dt><?php echo $this->getCarrierName($code) ?></dt>
<dd>
<ul>
<?php foreach ($_rates as $_rate): ?>
<li class="<?php if ($_rate->getErrorMessage()) echo 'error-msg';?>">
<?php if ($_rate->getErrorMessage()): ?>
<?php echo $_rate->getErrorMessage() ?>
<?php else: ?>
<input name="estimate_method" type="radio" value="<?php echo $this->htmlEscape($_rate->getCode()) ?>” id="s_method_<?php echo $_rate->getCode() ?>"<?php if( ($_rate->getCode()===$this->getAddressShippingMethod() || ($code == "freeshipping") )) echo ' checked="checked"' ?>/>
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodDescription() ?> - <strong><?php echo $_rate->getPrice() ?></strong></label>
<?php endif ?>
</li>
<?php endforeach; ?>
</ul>
</dd>
<?php endif; ?>
<?php endforeach; ?>
</dl>

/app/design/frontend/default/default/template/checkout/onepage/shipping_method/available.phtml must be changed the same way.

Bye

 
Magento Community Magento Community
Magento Community
Magento Community
 
JoeNmass
Member
 
Avatar
Total Posts:  50
Joined:  2008-03-07
 

Thanks PitchOu

Just what I was looking for. Works great.

************UPDATE*********************
When I did a complete test I got an error message

See next thread

********************************************

 
Magento Community Magento Community
Magento Community
Magento Community
 
JoeNmass
Member
 
Avatar
Total Posts:  50
Joined:  2008-03-07
 

Looks like it’s not perfect after all. When I tried with a product to get the free shipping I get an error message saying that there is no shipping method for it.

Has anyone else get this message?

Image Attachments
error_shipping.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
PitchOu
Member
 
Total Posts:  39
Joined:  2008-02-04
Villeneuve d'Ascq, France
 

Hi JoeNmass, I’ve just got your PM.
Seems that your shipping country is not enabled for free shipping. Could you check in admin (admin/system_config/edit/section/carriers), in the free shipping tab ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
JoeNmass
Member
 
Avatar
Total Posts:  50
Joined:  2008-03-07
 

I do have the shipping country enabled but I am still getting that notice.
Could I be overloooking something else?

 
Magento Community Magento Community
Magento Community
Magento Community
 
mathilda
Jr. Member
 
Total Posts:  15
Joined:  2008-04-04
Frankfurt / Main
 

I´m also very interested in a solution here. I also get a (slightly different) error message. I copied Pitchous code in the according part of both files, available.phtml and shipping.phtml (in my new theme folder, but according to the original folder structure). Was that right ? Maybe some adjustments would have been necessary for available.phtml?

Shipping country is enabled.

Does anyone have come any further with this problem?

 
Magento Community Magento Community
Magento Community
Magento Community
 
medlington
Sr. Member
 
Total Posts:  143
Joined:  2008-04-30
 

Hi,

I have tried to implement that hack but nothing happens, no errors and still have all the shipping options available with none checked.

anyone got any further with this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
portalzine
Jr. Member
 
Avatar
Total Posts:  9
Joined:  2008-05-15
Germany
 

Hi,

Just check for the free shipping carrier

in template\checkout\onepage\shipping_method\available.phtml

before:

<dt><?php echo $this->getCarrierName($code?></dt>

after:

<dt><?php $carrier =$this->getCarrierName($code) ; echo $carrier ?></dt>

Than break the loops at the right points:

before:

<?php endif ?>
                
</li>                
            
<?php endforeach; ?>
after:
<?php endif ?>
                
</li>
                
<?php if( $carrier == 'freeshipping'){break;}?>
            <?php 
endforeach; ?>

before:

</ul>
        </
dd>
    
<?php endforeach; ?>
after:
</ul>
        </
dd>
        
<?php if( $carrier == 'freeshipping'){break;}?>
    <?php 
endforeach; ?>

You will have to replace freeshipping with your carrier name smile

Alexander

 
Magento Community Magento Community
Magento Community
Magento Community
 
tradiArt
Guru
 
Avatar
Total Posts:  379
Joined:  2008-04-28
Spain
 

It’s a bit confusing to let the customer choose between free shipping and another shipping method.

portalzine thank you very much for your solution but… will be the file overwritten when an update is done?

Will be nice to have this solved in 1.1.4.  surprised

Best regards.

 
Magento Community Magento Community
Magento Community
Magento Community
 
w3lly
Jr. Member
 
Total Posts:  4
Joined:  2008-08-19
 

this works great and nice howto! must be implement into 1.1.4!

portalzine - 28 August 2008 04:21 AM

Hi,

Just check for the free shipping carrier

in template\checkout\onepage\shipping_method\available.phtml

before:

<dt><?php echo $this->getCarrierName($code?></dt>

after:
<dt><?php $carrier =$this->getCarrierName($code) ; echo $carrier ?></dt>

Than break the loops at the right points:

before:
<?php endif ?>
                
</li>                
            
<?php endforeach; ?>
after:
<?php endif ?>
                
</li>
                
<?php if( $carrier == 'freeshipping'){break;}?>
            <?php 
endforeach; ?>

before:
</ul>
        </
dd>
    
<?php endforeach; ?>
after:
</ul>
        </
dd>
        
<?php if( $carrier == 'freeshipping'){break;}?>
    <?php 
endforeach; ?>

You will have to replace freeshipping with your carrier name smile

Alexander
 
Magento Community Magento Community
Magento Community
Magento Community
 
Crazy Serb
Jr. Member
 
Total Posts:  12
Joined:  2008-07-23
 

can this be fixed in core, for the upcoming releases?

just because this fix doesn’t work for me as it is…

and having both free and paid shipping options on the cart is just dumb…

 
Magento Community Magento Community
Magento Community
Magento Community
 
Leo27
Sr. Member
 
Total Posts:  127
Joined:  2008-10-08
 

Thanks Portalzine, your adjustments worked perfectly fine!!

Thanks

L. Nunes

 
Magento Community Magento Community
Magento Community
Magento Community
 
Anjanesh
Sr. Member
 
Avatar
Total Posts:  136
Joined:  2008-03-15
Mumbai, India
 

Im trying to do a similar thing. Except - break if any of the rates is 0. But it still shows other shipping methods when Free Shipping is first.
Inserted a line at the end (commented “Inserted this Line")
template\checkout\onepage\shipping_method\available.phtml

<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
        
<dt><?php echo $this->getCarrierName($code?></dt>
        <
dd>
            <
ul>
            
<?php foreach ($_rates as $_rate): ?>
                
<li>
                   
<?php if ($_rate->getErrorMessage()): ?>
                    
<ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
                   
<?php else: ?>
                        
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> />
                        <
label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
                        <?php $_excl 
$this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
                        <?php $_incl 
$this->getShippingPrice($_rate->getPrice(), true); ?>

                        <?php 
echo $_excl?>
                        <?php 
if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
                            
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl?>)
                        
<?php endif; ?>
                        
</label>
                   
<?php endif ?>
                
</li>
                
<?php                
                
if (intval($_rate->getPrice()) == 0break; // Inserted this Line - why isnt this breaking
                
?>
            <?php 
endforeach; ?>
            
</ul>
        </
dd>
    
<?php endforeach; ?>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 3