本文整理汇总了PHP中Mage_SalesRule_Model_Rule::getDiscountQty方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_SalesRule_Model_Rule::getDiscountQty方法的具体用法?PHP Mage_SalesRule_Model_Rule::getDiscountQty怎么用?PHP Mage_SalesRule_Model_Rule::getDiscountQty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_SalesRule_Model_Rule
的用法示例。
在下文中一共展示了Mage_SalesRule_Model_Rule::getDiscountQty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getItemQty
/**
* Return discount item qty
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @param Mage_SalesRule_Model_Rule $rule
* @return int
*/
protected function _getItemQty($item, $rule)
{
//@nelkaake: Magento 1.3 and lower doesnt have the item->getTotalQty attribute.
if (Mage::helper('rewards/version')->isBaseMageVersionAtLeast('1.4')) {
$qty = $item->getTotalQty();
} else {
$qty = $item->getQty();
if ($item->getParentItem()) {
$qty *= $item->getParentItem()->getQty();
}
}
return $rule->getDiscountQty() ? min($qty, $rule->getDiscountQty()) : $qty;
}
示例2: _getItemQty
/**
* Return discount item qty
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @param Mage_SalesRule_Model_Rule $rule
* @return int
*/
protected function _getItemQty($item, $rule)
{
$qty = $item->getTotalQty();
return $rule->getDiscountQty() ? min($qty, $rule->getDiscountQty()) : $qty;
}
示例3: getItemRuleQty
public function getItemRuleQty(Mage_Sales_Model_Quote_Item_Abstract $item, Mage_SalesRule_Model_Rule $rule)
{
return $rule->getDiscountQty() ? min($item->getTotalQty(), $rule->getDiscountQty()) : $item->getTotalQty();
}
示例4: fireLegacyEvent
/**
* Fire a legacy event to process this rule for this item
*
* @param Mage_SalesRule_Model_Rule $rule
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @param Mage_Sales_Model_Quote_Address $address
*
* @return bool
*/
protected function fireLegacyEvent(Mage_SalesRule_Model_Rule $rule, Mage_Sales_Model_Quote_Item_Abstract $item, Mage_Sales_Model_Quote_Address $address)
{
// Prepare values for the event
$quote = $address->getQuote();
$qty = $rule->getDiscountQty() ? min($item->getTotalQty(), $rule->getDiscountQty()) : $item->getTotalQty();
// Prepare result object
$result = new Varien_Object(['discount_amount' => 0.0, 'base_discount_amount' => 0.0, 'applied' => false]);
// Fire legacy event
Mage::dispatchEvent('salesrule_validator_process', ['quote' => $quote, 'address' => $address, 'rule' => $rule, 'item' => $item, 'qty' => $qty, 'result' => $result]);
// Save discount amounts
$item->setDiscountAmount($item->getDiscountAmount() + $result->getData('discount_amount'));
$item->setBaseDiscountAmount($item->getBaseDiscountAmount() + $result->getData('base_discount_amount'));
// brain-dead check to see if a rule was applied
return $result->getData('applied') || $result->getData('discount_amount') != 0.0;
}