Magento - Create a minimum shipping charge
We use USPS API for international shipping. The API returns a shipping cost and we add % Handling charge. We want to set a minimum charge, e.g., i开发者_如何学Gof shipping + handling is less than $5 we want to set the shipping price to $5. Would this require writing a full shipping module or just adapt the USPS module?
You can accomplish this by overriding just a portion of the USPS module. The method that applies handling is in Mage_Shipping_Model_Carrier_Abstract
:
public function getFinalPriceWithHandlingFee($cost)
To override this method for US, create a new model override on Mage_Usa_Model_Shipping_Carrier_Usps
(see elsewhere for how to set up this override):
class Namespace_Module_Model_Shipping_Carrier_Usps extends Mage_Usa_Model_Shipping_Carrier_Usps {
function getFinalPriceWithHandlingFee($cost) {
$parentValue = parent::getFinalPriceWithHandlingFee($cost);
return max($parentValue,5);
}
}
This will implement a "floor" for shipping prices. Keep in mind that this may in some cases lead to results that users notice as being odd. For contrived example:
- First Class - $5.00
- Media Mail - $5.00
- Priority Mail - $5.33
Keep it aboveboard and let them know that you're doing this.
Hope that helps!
Thanks, Joe
精彩评论