I had a similar problem and I found a solution inspired by the Abdul comment
The Problem: Multistore website with multiple shipping method: flatrate, matrixrate. In some store the free shipping rule should be applied only to matrixrate and not flatrate, in some others should be applied to flatrate.
The Solution: Use the rule like explaned here with whatever condition but the shipping method one. Then create a module that extend the Flatrate model (or the one witch shouldn't be affected by the rule) for prevent to apply the shipping rule according to a configuration specific for website.
Adding the configuration file (system.xml
):
<?xml version="1.0"?>
<config>
<sections>
<carriers>
<groups>
<flatrate>
<fields>
<ignore_freeshipping translate="label">
<label>Ignore Free Shipping Promotions</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>100</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</ignore_freeshipping>
</fields>
</flatrate>
</groups>
</carriers>
</sections>
</config>
The Flatrate model rewrite:
<?php
class Ac_Freeshipping_Model_Carrier_Flatrate extends Mage_Shipping_Model_Carrier_Flatrate
{
/**
* rewrite original method, with condition to freeshipping
*
* @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->getProduct()->isVirtual() || $item->getParentItem()) {
continue;
}
if ($item->getHasChildren() && $item->isShipSeparately()) {
foreach ($item->getChildren() as $child) {
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
$freeBoxes += $item->getQty() * $child->getQty();
}
}
////////////HERE I CHECK IF THE CONFIGURATION IS SET FOR SKIP FREE SHIPPING RULES
} elseif ($item->getFreeShipping() && !Mage::helper('ac_freeshipping')->flatrateIgnoreFreeShipping()) {
$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 = ($request->getPackageQty() * $this->getConfigData('price')) - ($this->getFreeBoxes() * $this->getConfigData('price'));
} 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'));
////////////HERE I CHECK IF THE CONFIGURATION IS SET FOR SKIP FREE SHIPPING RULES
if (($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) && !Mage::helper('ac_freeshipping')->flatrateIgnoreFreeShipping()) {
$shippingPrice = '0.00';
}
$method->setPrice($shippingPrice);
$method->setCost($shippingPrice);
$result->append($method);
}
return $result;
}
}
The complete module is here: https://github.com/andreacanton/magento-freeshipping-rule