【发布时间】:2015-09-14 08:17:15
【问题描述】:
我按照here 的建议扩展了 Magento 1.9 的统一运费运营商模型,因为我想为单个产品设置运费。
当我在购物车中添加可配置产品时,运费是双倍的。 Magento 在购物车中考虑了可配置的产品和简单的产品变体。 因此,当我添加可配置产品时,Magento 将可配置产品和单个产品的运费相加。
我添加了一个排除可配置产品的条件。可以吗?有没有办法只从购物车中提取单个产品?
谢谢。
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('checkout/session');
$cart_items = $session->getQuote()->getAllItems();
$_helper = Mage::helper('catalog/output');
$custom_ship = 0;
foreach( $cart_items as $items ){
// items are configurable and single products
$cur_fproduct = Mage::getModel('catalog/product')->load($items->getProduct_id());
if($cur_fproduct->getTypeId()=='simple') {
$custom_ship +=($items->getQty())*($_helper->productAttribute($cur_fproduct, $cur_fproduct->getShippingWorld(), 'shipping_world'));
}
}
return $custom_ship ;
【问题讨论】:
标签: php magento magento-1.9