Try the Demo

Magento Forum

   
Page 3 of 3
Flat Rate Shipping per item as override
 
joshlipkam
Jr. Member
 
Total Posts:  5
Joined:  2012-03-21
 

David,
It works like a charm!!!!! THANK YOU THANK YOU!!

~Josh

ModifyMage - 25 June 2012 11:34 AM

Hi Josh,

I’m terribly sorry it took so long to get back to you. Here is new Flatrate.php code that should fix your problem. It’s a hack on top of the original hack that was this code, but it works in all cases as far as I can tell. This code embarrasses me now, and I don’t really have the time to make it right for the forum (we’ll do it right as an extension). It’s pretty much a matter of style, though. The code should still function properly in all cases (I hope).

Please let me know if you still have any problems.

David

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   Mage
 * @package    Mage_Shipping
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */


/**
 * Flat rate shipping model
 *
 * @category   Mage
 * @package    Mage_Shipping
 * @author      Magento Core Team <core@magentocommerce.com>
 */
class Mmsmods_ItemShipping_Model_Flatrate
    
extends Mage_Shipping_Model_Carrier_Abstract
    
implements Mage_Shipping_Model_Carrier_Interface
{

    
protected $_code 'flatrate';

    
/**
     * Enter description here...
     *
     * @param Mage_Shipping_Model_Rate_Request $data
     * @return Mage_Shipping_Model_Rate_Result
     */
    
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    
{
        
if (!$this->getConfigFlag('active')) {
            
return false;
        
}

        $freeBoxes 
0;
        if (
$request->getAllItems()) {
            
foreach ($request->getAllItems() as $item{
                
if ($item->getFreeShipping() && !$item->getProduct()->getTypeInstance()->isVirtual()) {
                    $freeBoxes
+=$item->getQty();
                
}
            }
        }
        $this
->setFreeBoxes($freeBoxes);

        
$result Mage::getModel('shipping/rate_result');
        if (
$this->getConfigData('type') == 'O'// per order
            
$shippingPrice $this->getConfigData('price');
        
elseif ($this->getConfigData('type') == 'I'// per item
            
$shippingPrice '0.00';
            
$config_qty 0;
            foreach (
$request->getAllItems() as $item{
                
if (!$item->getFreeShipping()) {
                    $productId 
$item->getProduct()->getId();
                    
$productList Mage::getModel('catalog/product')->getCollection()
                        ->
addAttributeToSelect('ship_price')
                        ->
addIdFilter($productId);
                    foreach(
$productList as $product{
                        $quantity 
$item->getQty();
                        if (
$product->getTypeId() == 'configurable'{
                            $config_qty 
$item->getQty();
                        
elseif ($quantity <= $config_qty{
                            $quantity 
$config_qty;
                            
$config_qty 0;
                        
}                        
                        
if ($product->getShipPrice()) {
                            $shippingPrice
+=$product->getShipPrice() * $quantity;
                        
else {
                            $shippingPrice
+=$this->getConfigData('price') * $quantity;

                        
}
                    }
                }

            }
        } 
else {
            $shippingPrice 
false;
        
}

        $shippingPrice 
$this->getFinalPriceWithHandlingFee($shippingPrice);

        if (
$shippingPrice !== false{
            $method 
Mage::getModel('shipping/rate_result_method');

            
$method->setCarrier('flatrate');
            
$method->setCarrierTitle($this->getConfigData('title'));

            
$method->setMethod('flatrate');
            
$method->setMethodTitle($this->getConfigData('name'));

            if (
$request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
                $shippingPrice 
'0.00';
            
}


            $method
->setPrice($shippingPrice);
            
$method->setCost($shippingPrice);

            
$result->append($method);
        
}

        
return $result;
    
}

    
public function getAllowedMethods()
    
{
        
return array('flatrate'=>$this->getConfigData('name'));
    
}

}

 Signature 

Thank You,
Josh Lipka
Digital Media Consultant
MultiTable, LLC.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dovid Yudkowitz
Jr. Member
 
Total Posts:  16
Joined:  2009-04-24
 

I bought the Red Stage mod for one of my stores and I’m very impressed with its flexibility and ease of use.

They have 2 versions:

- Pro Version

- Regular Version

 
Magento Community Magento Community
Magento Community
Magento Community
 
redstage
Sr. Member
 
Avatar
Total Posts:  168
Joined:  2009-12-04
Hoboken, NJ
 

Hi everyone!

We actually just released a new Shipping Extension that allows you to override calculated shipping rates for any product with a custom rate.  On a per product basis, you can also specifiy a rate for each service level that you have set up in your store.

You can check out the extension here:

Calculated Shipping per Product Override

 Signature 

For stable and cutting edge Magento extensions, check out the Redstage Extensions Store!

Having done work on over 200 Magento sites, Redstage is the most advanced and experienced agency in the industry.  Interested in working with us?  Check us out

 
Magento Community Magento Community
Magento Community
Magento Community
 
Amasty
Mentor
 
Avatar
Total Posts:  3001
Joined:  2009-11-10
 

Check out our shipping extensions.
Shipping Table Rates
-Unlimited shipping methods
-Specific rates for a product or a group of products
-Rates based on product type, e.g. for extra large, toxic items
-Flat and percent rates; quantity and weight-based rates, etc.
-Import and manual editing of shipping rates
-Full support of Magento discount functionality

Shipping Rules
-Modify shipping rates according to your business needs
-Shipping rules based on order and product attributes
-Modify rates both for the whole order and a single product
-Change shipping based on customer groups and store views
-Provide correct rates for LTL freights

 Signature 

55+ free & paid Magento extensions

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 3 of 3