Magento-在购物车中获取折扣类型
我需要能够在购物车中应用折扣类型 我可以这样获得折扣金额:Magento-在购物车中获取折扣类型,magento,cart,discount,Magento,Cart,Discount,我需要能够在购物车中应用折扣类型 我可以这样获得折扣金额: $cart = Mage::getModel('checkout/cart')->getQuote(); $totals = $cart->getTotals(); $discount = $totals["discount"]->getValue(); 如何检查折扣的类型?是百分比折扣还是固定折扣?查看sales\u flat\u quote和sales\u flat\u quote\u item中应用的\u
$cart = Mage::getModel('checkout/cart')->getQuote();
$totals = $cart->getTotals();
$discount = $totals["discount"]->getValue();
如何检查折扣的类型?是百分比折扣还是固定折扣?查看sales\u flat\u quote和sales\u flat\u quote\u item中应用的\u rule\u ID
你可以试试类似的东西
//if the item has not had a rule applied to it skip it
if($item->getAppliedRuleIds() == '')continue;
/*
* I cant remember in the database they might be comma separated or space if multiple rules were applied
* the getAppliedRuleIds() function is the one you want
*/
foreach(explode(",",$item->getAppliedRuleIds()) as $ruleID){
//Load the rule object
$rule = Mage::getModel('catalogrule/rule')->load($ruleID);
// Throw out some information like the rule name what product it was applied to
echo "<p>".$item->getSku()." had rule ".$rule->getName()."(".$item->getAppliedRuleIds().") applied </p>";
}
看