0

I'm just wondering if it's possible to allow a customer to select a shipping method on the cart/basket page without entering country or postcode? I have added an image of a mockup to show what it is I'm looking to do. If anyone knows a tutorial or extension that would do this that would be great.

enter image description here

2

If you don't ship to different countries, or if you don't use the matrixrate extension, you can edit the estimate tax & shipping box to get this effect.

I've used this tutorial as a base:

http://www.arscommunity.com/wiki/magento/default-address-for-shipping-estimation

copy /app/code/core/Mage/Checkout/Model/Session.php 

to

/app/code/local/Mage/Checkout/Model/Session.php

and before:

$this->_quote = $quote;

add this

$sha = $quote->getShippingAddress();
if (!$sha->getCountry()) {
$country = Mage::getStoreConfig('shipping/origin/country_id');
$state = Mage::getStoreConfig('shipping/origin/region_id');
$postcode = Mage::getStoreConfig('shipping/origin/postcode');
$quote->getShippingAddress()
->setCountryId($country)
->setRegionId($state)
->setPostcode($postcode)
->setCollectShippingRates(true);
$this->resetCheckout();
$quote->save();
}

then copy

/app/design/frontend/base/default/checkout/cart/shipping.phtml

to

/app/design/frontend/default/YOURTEMPLATE/checkout/cart/shipping.phtml

and change it, I've changed it to:

  <div class="shipping">
<h2><?php echo $this->__('Estimate Shipping and Tax') ?></h2>
<div class="shipping-form">



    <?php if (($_shippingRateGroups = $this->getEstimateRates())): ?>
    <form id="co-shipping-method-form" action="<?php echo $this->getUrl('checkout/cart/estimateUpdatePost') ?>">
        <dl class="sp-methods">
            <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
                <dt><?php echo $this->escapeHtml($this->getCarrierName($code)) ?></dt>
                <dd>
                    <ul>
                    <?php foreach ($_rates as $_rate): ?>
                        <li<?php if ($_rate->getErrorMessage()) echo ' class="error-msg"';?>>
                           <?php if ($_rate->getErrorMessage()): ?>
                                <?php echo $this->escapeHtml($_rate->getErrorMessage()) ?>
                           <?php else: ?>
                                <input name="estimate_method" type="radio" value="<?php echo $this->escapeHtml($_rate->getCode()) ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio" />
                                <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $this->escapeHtml($_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 endforeach; ?>
                    </ul>
                </dd>
            <?php endforeach; ?>
        </dl>
        <div class="buttons-set">
            <button type="submit" title="<?php echo $this->__('Update Total') ?>" class="button" name="do" value="<?php echo $this->__('Update Total') ?>"><span><span><?php echo $this->__('Update Total') ?></span></span></button>
        </div>
    </form>
    <?php endif; ?>

</div>

  • No, this hasn't worked for me. My shipping methods are not visible. – Duggy G Nov 4 '14 at 9:36
  • I've edited the two files, it should work now. I've added a reset in Session.php and removed the form fields in shipping.phtml I took the information from this link: magentocommerce.com/boards/v/viewthread/194314/#t245813 – The Tankgirl Nov 4 '14 at 10:17
  • Brilliant, I have this working. Thankyou for your help. – Duggy G Nov 6 '14 at 23:43
  • hi the above URL is not working (magentocommerce.com/boards/v/viewthread/194314/#t245813) I need to set select Shipping method option in cart page. Please help – Jenith Samuel Oct 3 '17 at 10:42
  • I tried the above code its not working.please help – Jenith Samuel Oct 3 '17 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.