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.
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.
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.
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.
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.
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!
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!
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.
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.
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!!
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.
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;