I have a problem for which I cannot find a solution. I have a shopping cart rule to give a free shipping for order subtotal > $75. However if a discount code is used this rule is applied again despite the fact that the total amount of the order is less than $75. No taxes and other fees are in place. I want to give a free shipping only if they spend > $75. Any ideas how can I solve this? Thanks in advance
You are right, the shopping cart rule only works with the cart subtotal, as does the freeshipping carrier model. Using a small rewrite it is possible to change the behavior of the freeshipping model.
First, deactivate your shopping cart rule that grants free shipping. Then go to System > Configuration > Shipping Methods
and activate the free shipping carrier, giving it a "Minimum Order Amount" of 75$.
Next, we need to add the rewrite so the freeshipping model uses the discounted value instead of the subtotal.
Add a module My_Shipping, with the appropriate module registration file. Since you are asking on stackoverflow, I'll assume you are familiar with creating Magento modules. Then add the My/Shipping/etc/config.xml
file with the following rewrite declaration:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<global>
<models>
<shipping>
<rewrite>
<carrier_freeshipping>My_Shipping_Model_Freeshipping</carrier_freeshipping>
</rewrite>
</shipping>
</models>
</global>
</config>
The only thing missing now is the rewritten carrier model. The following code implements the change you require:
class My_Shipping_Model_Freeshipping extends Mage_Shipping_Model_Carrier_Freeshipping
{
/**
* Force the original free shipping class to use the discounted package value.
*
* The package_value_with_discount value already is in the base currency
* even if there is no "base" in the property name, no need to convert it.
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Shipping_Model_Rate_Result
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
$origBaseSubtotal = $request->getBaseSubtotalInclTax();
$request->setBaseSubtotalInclTax($request->getPackageValueWithDiscount());
$result = parent::collectRates($request);
$request->setBaseSubtotalInclTax($origBaseSubtotal);
return $result;
}
}
Thats it. Now, if the subtotal including discount is above 75$, the free shipping method is available. Otherwise the customer won't see it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With