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 2 of 3
Flat Rate Shipping per item as override
 
ModifyMage
Sr. Member
 
Avatar
Total Posts:  84
Joined:  2008-10-15
 
Atjuh - 01 February 2010 10:00 AM

@ Spheric :

Thanks allot it is just what i needed plain and simple but Perfect for the job !!!!!

Thanks again!

Regards,

Aaron

Your very welcome. I’m glad people are still finding this useful.

I look at the code now and realize I would overload the core a little differently if I wrote this today, since I have a somewhat better handle on how that all works now. But, so far it still functions perfectly in my stores, so I’m not ready to rewrite it just yet.

grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
The Conqueror
Jr. Member
 
Total Posts:  3
Joined:  2009-08-31
 
Spheric - 01 February 2010 12:07 PM

Atjuh - 01 February 2010 10:00 AM
@ Spheric :

Thanks allot it is just what i needed plain and simple but Perfect for the job !!!!!

Thanks again!

Regards,

Aaron

Your very welcome. I’m glad people are still finding this useful.

I look at the code now and realize I would overload the core a little differently if I wrote this today, since I have a somewhat better handle on how that all works now. But, so far it still functions perfectly in my stores, so I’m not ready to rewrite it just yet.

grin

Just added this and it works great on 1.4.0.1

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
ModifyMage
Sr. Member
 
Avatar
Total Posts:  84
Joined:  2008-10-15
 
The Conqueror - 05 May 2010 02:36 AM

Spheric - 01 February 2010 12:07 PM
Atjuh - 01 February 2010 10:00 AM
@ Spheric :

Thanks allot it is just what i needed plain and simple but Perfect for the job !!!!!

Thanks again!

Regards,

Aaron

Your very welcome. I’m glad people are still finding this useful.

I look at the code now and realize I would overload the core a little differently if I wrote this today, since I have a somewhat better handle on how that all works now. But, so far it still functions perfectly in my stores, so I’m not ready to rewrite it just yet.

:-)

Just added this and it works great on 1.4.0.1

Thanks!

Thank you. That’s good to know.

 
Magento Community Magento Community
Magento Community
Magento Community
 
helefa
Jr. Member
 
Total Posts:  9
Joined:  2008-10-28
 

Just another thank you to @ Spheric - the code worked like a charm. And the detailed instructions were very helpful. Thanks so much!

 
Magento Community Magento Community
Magento Community
Magento Community
 
gistano
Jr. Member
 
Total Posts:  3
Joined:  2010-07-25
 

perfect! perfect! perfect!.......All thanks to spheric, don’t know what i would have done without u!

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

We just released an extension to specify a flat rate for each product (or use a default if none specified).  We found that we were migrating a lot of customers from existing carts that had it set up this way.

The next version will allow for it to default to calculated rates as well as the default flat rate (free upgrades of course).  Looks like we’ll have that completed in about a week or so.

Here’s the link: http://store.redstage.com/flat-rate-shipping-per-product.html

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

By popular demand, we’ve also released a pro version that allows you to set up multiple service levels, international shipping, and multiple calculation methods (sum of values, highest value, lowest value).  Check that one out here: http://store.redstage.com/flat-rate-shipping-per-product-pro.html.

 
Magento Community Magento Community
Magento Community
Magento Community
 
augustroad
Jr. Member
 
Total Posts:  17
Joined:  2008-10-21
 

Hi all,

Quick question on this - I’m working to implement Spheric’s code, but I can’t find a sub-folder under “app -->code” called “local” in the newest version of Magento. Am I missing something, or should I add Spheric’s new folders in some other place? Any help on this would be extremely appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
 
miyacrys
Jr. Member
 
Total Posts:  11
Joined:  2009-07-20
 

Thanks for this tutorial, I have followed the steps but I am getting this error when adding a product to the shopping cart:

Fatal error: Call to a member function setStore() on a non-object in /home/content/95/7979695/html/app/code/core/Mage/Shipping/Model/Shipping.php on line 193

I’m on version 1.5

Any help is appreciated.

Thanks!

----
I must just be sleepy or my cache just caught up cause all the sudden it started working. So I can vouch for this solution working in 1.5!

Now my boss won’t kill me. Yay! smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
jeitnier
Jr. Member
 
Total Posts:  5
Joined:  2011-11-19
 

Thanks Spheric, worked great.  Tested on 1.6.1.

 
Magento Community Magento Community
Magento Community
Magento Community
 
joshlipkam
Jr. Member
 
Total Posts:  8
Joined:  2012-03-21
 

@Modify Mage

This solution is great! However, I’m running into a snag. We use Configurable Products. For some reason, it isn’t duplicating the Flat Rate on the Simple Products that are part of the Configurable Product, but it is duplicating the Configurable Product Flat Rate.

Example: We sell Height Adjustable Desks or Tables. A consumer can configure their base color, and then select their size & color of the top. 3 different sizes of tops, each with their own Flat Rate of shipping.

Base - $49 To ship
Medium Top - $39 to ship
Total Ship for 1 Combo: $88
Add a quantity of 2 and that price goes to: $137 instead of $176 as it should.

Any suggestions?!

 
Magento Community Magento Community
Magento Community
Magento Community
 
ModifyMage
Sr. Member
 
Avatar
Total Posts:  84
Joined:  2008-10-15
 
joshlipkam - 05 June 2012 09:20 AM

@Modify Mage

This solution is great! However, I’m running into a snag. We use Configurable Products. For some reason, it isn’t duplicating the Flat Rate on the Simple Products that are part of the Configurable Product, but it is duplicating the Configurable Product Flat Rate.

Example: We sell Height Adjustable Desks or Tables. A consumer can configure their base color, and then select their size & color of the top. 3 different sizes of tops, each with their own Flat Rate of shipping.

Base - $49 To ship
Medium Top - $39 to ship
Total Ship for 1 Combo: $88
Add a quantity of 2 and that price goes to: $137 instead of $176 as it should.

Any suggestions?!

Hi Josh,

I haven’t looked at this code for quite some time now. Give me a few days to wrap my head around it again, and I’ll see if I can’t find a solution. Your timing is impeccable. We just decided on Monday to resurrect this code and use it as a starting point for an actual extension we can provide to our customers. So, I will be going over this code again anyway. But, I have a few other things on my plate as well, so it will be a few days.

David

 
Magento Community Magento Community
Magento Community
Magento Community
 
joshlipkam
Jr. Member
 
Total Posts:  8
Joined:  2012-03-21
 
ModifyMage - 06 June 2012 03:27 AM

joshlipkam - 05 June 2012 09:20 AM
@Modify Mage

This solution is great! However, I’m running into a snag. We use Configurable Products. For some reason, it isn’t duplicating the Flat Rate on the Simple Products that are part of the Configurable Product, but it is duplicating the Configurable Product Flat Rate.

Example: We sell Height Adjustable Desks or Tables. A consumer can configure their base color, and then select their size & color of the top. 3 different sizes of tops, each with their own Flat Rate of shipping.

Base - $49 To ship
Medium Top - $39 to ship
Total Ship for 1 Combo: $88
Add a quantity of 2 and that price goes to: $137 instead of $176 as it should.

Any suggestions?!

Hi Josh,

I haven’t looked at this code for quite some time now. Give me a few days to wrap my head around it again, and I’ll see if I can’t find a solution. Your timing is impeccable. We just decided on Monday to resurrect this code and use it as a starting point for an actual extension we can provide to our customers. So, I will be going over this code again anyway. But, I have a few other things on my plate as well, so it will be a few days.

David

Hey David!

I’m just doing a follow up to see if you and your team have happened to have had the time to look at this issue i was having? Hope all is well!!

~Josh

 
Magento Community Magento Community
Magento Community
Magento Community
 
ModifyMage
Sr. Member
 
Avatar
Total Posts:  84
Joined:  2008-10-15
 
joshlipkam - 13 June 2012 10:14 AM

Hey David!

I’m just doing a follow up to see if you and your team have happened to have had the time to look at this issue i was having? Hope all is well!!

~Josh

Hi Josh,

I apologize that it’s taking so long to get back to you. I honestly don’t think I’ll be able to even look into this code again until Monday. I took a quick glance at it on Tuesday, but nothing jumped out at me. I think I’ll need to dump some return values and variables to see what’s actually going on. I haven’t forgotten you, though.

David

 
Magento Community Magento Community
Magento Community
Magento Community
 
ModifyMage
Sr. Member
 
Avatar
Total Posts:  84
Joined:  2008-10-15
 

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'));
    
}

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