Prashant Parekh
Prashant Parekh

Reputation: 428

One page checkout process show two shipping method in magento 1.7.0.1

I have enbaled two shipping method. 1. tablerate 2. free shipping

I need show only single shipping method and also enable two shipping method. I have customize code in app\code\core\Mage\Checkout\Block\Onepage\Shipping\Method\Available.php

if (!empty($groups)) {
            $ratesFilter = new Varien_Filter_Object_Grid();
            $ratesFilter->addFilter(Mage::app()->getStore()->getPriceFilter(), 'price');

            $custom = array();
            $k=0;
            foreach ($groups as $code => $groupItems) {
                $custom['shippingmethod'][$k] = $code;
                $k++;
            }

            $check = array('tablerate','freeshipping');

            if(in_array($check,$custom)){

                foreach ($groups as $code => $groupItems) {
                    if($code == 'tablerate')
                        $groups[$code] = $ratesFilter->filter($groupItems);
                }
            } else {
                foreach ($groups as $code => $groupItems) {
                    $groups[$code] = $ratesFilter->filter($groupItems);
                }
            }
        }

But its not give me price for shipping method. Is there any other solution for this?

Upvotes: 3

Views: 1698

Answers (1)

Péter Gulyás
Péter Gulyás

Reputation: 1111

You can customize this feature in the frontend templates. You will have to change app/design/frontend/_your_package_/_your_theme_/template/checkout/onepage/shipping_method/available.phtml

I guess you want to show only the free shipping if available. When freeshipping is not availabe, it should not be shown anyway.

Original code:

<dl class="sp-methods">
<?php $shippingCodePrice = array(); ?>

New code:

<dl class="sp-methods">
<?php
    $showFreeShipping = false;
    $_shippingRateGroupsReduced = array();
    foreach ($_shippingRateGroups as $code => $_rates) {
        if(strstr($code, 'freeshipping')) {
            $showFreeShipping = true;
            $_shippingRateGroupsReduced[$code] = $_shippingRateGroups[$code];
        }
    }

    if($showFreeShipping) {
        $_shippingRateGroups = $_shippingRateGroupsReduced;
    }

?>
<?php $shippingCodePrice = array(); ?>

Upvotes: 5

Related Questions