Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento-在购物车中获取折扣类型_Magento_Cart_Discount - Fatal编程技术网

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>";
 }