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

Choose shipping method on any page
 
GoMediaLtd
Sr. Member
 
Avatar
Total Posts:  84
Joined:  2009-11-12
Wakefield, United Kingdom
 

I am trying to create a dropdown menu of available shipping methods to be selected by the customer on any page of my Magento store (it is situated at the top of the page in a ‘floating’ bar).

I also display the order total in this bar, when I select a different shipping method the order total doesn’t update unless I am on the cart page.

Does anyone have any ideas why? Is there something on the cart page that I need to include on every page?

My current code is as follows:

Mage::app("default"); 
Mage::getSingleton("core/session", array("name" => "frontend")); 

    
$cartHelper Mage::helper('checkout/cart');
    
$quote Mage::getSingleton('checkout/cart')->getQuote();
    if(
$cartHelper->getItemsCount()<1){
        
echo '<select name="delivery" style="font-size:9px; width:100%;">
         <option selected="selected" style="padding:3px;">'
."Please add at-least 1 product to see shipping methods".'</option></select>';
        return;
    
}
    $shippingAddress 
$quote->getShippingAddress();
    
$groups $shippingAddress->getGroupedAllShippingRates();
    
    if(!
$groups{
        $shippingCountry 
"GB";
        
$shippingRegionID "20";
        
$shippingRegion "";
        
$postcode "";
        
$shippingAddress->setCountryId($shippingCountry)
            ->
setCity("")
            ->
setPostcode($postcode)
            ->
setRegionId($shippingRegionID)
            ->
setRegion($shippingRegion)
            ->
setCollectShippingRates(true);
        
        
//echo $quote->getCode();
            
        
$code "matrixrate_matrixrate";
        
$shippingAddress->setShippingMethod($code)/*->collectTotals()*/->save();
        
$groups getGroupedAllShippingRates();
    
}

    
echo '<form id="co-shipping-method-form" action="<MY_URL>/index.php/checkout/cart/estimateUpdatePost/">'$countShip 1;
        foreach (
$groups as $code => $_rates):
        
            echo 
"<select name=\"estimate_method\" onchange=\"this.form.submit()\" style=\"font-size:9pxwidth:100%;\">";
            echo 
"<option style=\"padding:3px;\">"."Please Select"."</option>";
            
            foreach (
$_rates as $_rate):
                
                
$selected = ($_rate->getCode() == $quote->getShippingAddress()->getShippingMethod())?"selected":"";
                
                
$text $_rate->getMethodTitle()."&nbsp;";
                if(
$_rate->getPrice() != ""):

                    
$_incl number_format(Mage::helper('tax')->getShippingPrice($_rate->getPrice(), true), 2"."",");
                    
$text .= "£".$_incl;
                    
                endif;
            
                echo 
"<option value=\"".$_rate->getCode()."\" ".$selected." style=\"padding:3px;\" >".$text."</opton>";
                
            endforeach;
            
            echo 
"</select>";    
        endforeach;
         
    echo 
'</form>';
 
Magento Community Magento Community
Magento Community
Magento Community
 
GoMediaLtd
Sr. Member
 
Avatar
Total Posts:  84
Joined:  2009-11-12
Wakefield, United Kingdom
 

Bump for a fix smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
GoMediaLtd
Sr. Member
 
Avatar
Total Posts:  84
Joined:  2009-11-12
Wakefield, United Kingdom
 

Anybody? Really need a fix for this :(

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