2015-01-29 4 views
0

Мне нужно, чтобы получить тип скидки, применяемый в корзине.Magento - Получите скидку в корзине

я могу получить сумму скидки, как так:

$cart = Mage::getModel('checkout/cart')->getQuote(); 
$totals = $cart->getTotals(); 
$discount = $totals["discount"]->getValue(); 

Как я могу проверить, какой тип скидки это - является ли это процент или фиксированную сумму от?

ответ

0

Посмотрите на applied_rule_ids в sales_flat_quote и sales_flat_quote_item

Вы могли бы попробовать что-то вроде

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

См Magento - get price rules from order

Смежные вопросы