Is it possible to set a flat rate shipping method with two different prices for two different customer groups?
Googled around, but couldn't find one, and why isn't this as easy as one would imagine it be to setup?
You can create this option by copy Flatrate file core/Mage/Shipping/Model/Carrier/Flatrate.php
in local code pool local/Mage/Shipping/Model/Carrier/Flatrate.php
.
you need to modify code in collectRates
function.
$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;
}
Replace the above code using the below code:
if(!Mage::getSingleton('customer/session')->isLoggedIn()){
//not logged in
$flatRatePrice = $this->getConfigData('price');
}else{
// logged in
$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
$group = Mage::getSingleton('customer/group')->load($groupId)->getData('customer_group_code');
$group = strtolower($group);
switch ($group) {
case 'general': //Set price for different customer group
$flatRatePrice = 10;
break;
case 'retailer':
$flatRatePrice = 20;
break;
case 'wholesale':
$flatRatePrice = 30;
break;
default:
$flatRatePrice = $this->getConfigData('price');
}
}
$result = Mage::getModel('shipping/rate_result');
if ($this->getConfigData('type') == 'O') { // per order
$shippingPrice = $flatRatePrice;
} elseif ($this->getConfigData('type') == 'I') { // per item
$shippingPrice = ($request->getPackageQty() * $flatRatePrice) - ($this->getFreeBoxes() * $flatRatePrice);
} else {
$shippingPrice = false;
}