不同客户群的统一运费?
Flat Rate shipping for different customer groups?
是否可以为两个不同的客户群设置两种不同价格的统一运费方式?
用 Google 搜索了一圈,但没找到,为什么这不像人们想象的那么容易设置?
您可以通过在本地代码池 local/Mage/Shipping/Model/Carrier/Flatrate.php
中复制 Flatrate 文件 core/Mage/Shipping/Model/Carrier/Flatrate.php
来创建此选项。
您需要修改collectRates
函数中的代码。
$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;
}
使用以下代码替换上面的代码:
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;
}
是否可以为两个不同的客户群设置两种不同价格的统一运费方式?
用 Google 搜索了一圈,但没找到,为什么这不像人们想象的那么容易设置?
您可以通过在本地代码池 local/Mage/Shipping/Model/Carrier/Flatrate.php
中复制 Flatrate 文件 core/Mage/Shipping/Model/Carrier/Flatrate.php
来创建此选项。
您需要修改collectRates
函数中的代码。
$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;
}
使用以下代码替换上面的代码:
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;
}