Php 设置产品的运输成本,修复Magento中的可配置产品
我按照建议扩展了Magento 1.9的扁平承运人模型,因为我想为单个产品设置运输成本 当我在购物车中添加可配置产品时,运输成本是原来的两倍。 MAGNTO考虑车内可配置的产品和简单的产品变型。 所以,当我添加一个可配置产品时,Magento将可配置产品和单个产品的运输成本相加 我添加了一个排除可配置产品的条件。可以吗?有没有办法只从购物车中提取单个产品 谢谢Php 设置产品的运输成本,修复Magento中的可配置产品,php,magento,magento-1.9,Php,Magento,Magento 1.9,我按照建议扩展了Magento 1.9的扁平承运人模型,因为我想为单个产品设置运输成本 当我在购物车中添加可配置产品时,运输成本是原来的两倍。 MAGNTO考虑车内可配置的产品和简单的产品变型。 所以,当我添加一个可配置产品时,Magento将可配置产品和单个产品的运输成本相加 我添加了一个排除可配置产品的条件。可以吗?有没有办法只从购物车中提取单个产品 谢谢 Mage::getSingleton('core/session', array('name'=>'frontend'));
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 ;
相反,
$cart_items = $session->getQuote()->getAllItems();
使用
或者你可以查一下
foreach( $cart_items as $items ){
// items are configurable and single products
if ($item->getParentItemId) // this is set for simple products of configurable
{
}
}
希望这有帮助 相反
$cart_items = $session->getQuote()->getAllItems();
使用
或者你可以查一下
foreach( $cart_items as $items ){
// items are configurable and single products
if ($item->getParentItemId) // this is set for simple products of configurable
{
}
}
希望这有帮助 谢谢!我还检查getAllItems()之间的差异;和getAllVisibleItems();这里:谢谢!我还检查getAllItems()之间的差异;和getAllVisibleItems();在这里: