magento 中的运费
Shipping charges in magento
运费:
(美国/加拿大境内):
我们对 1 件产品收取 5.95 美元,每增加一件产品收取 1.00 美元
(海外)
我们对 1 件产品收取 12.95 美元,每增加一件产品收取 2.00 美元
如何在 magento 中实现每个附加产品的价格?
请找到 app/code/Local/MY/Shipping/Model/Carrier/MyFlatrate.php
您可以在那里添加 collectRates 方法。
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) {
// Write your logic here
}
}
$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);
$shippingPrice = $this->get_pro_ship();
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'));
if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
$shippingPrice = '0.00';
}
$method->setPrice($shippingPrice);
$method->setCost($shippingPrice);
$result->append($method);
}
$request->getAllItems() 包含 cart/quote 中的所有产品。
运费:
(美国/加拿大境内): 我们对 1 件产品收取 5.95 美元,每增加一件产品收取 1.00 美元
(海外) 我们对 1 件产品收取 12.95 美元,每增加一件产品收取 2.00 美元
如何在 magento 中实现每个附加产品的价格?
请找到 app/code/Local/MY/Shipping/Model/Carrier/MyFlatrate.php 您可以在那里添加 collectRates 方法。
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) {
// Write your logic here
}
}
$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);
$shippingPrice = $this->get_pro_ship();
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'));
if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
$shippingPrice = '0.00';
}
$method->setPrice($shippingPrice);
$method->setCost($shippingPrice);
$result->append($method);
}
$request->getAllItems() 包含 cart/quote 中的所有产品。