本文整理汇总了PHP中Mage_Sales_Model_Quote_Address::setRewardpointsBaseDiscount方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Address::setRewardpointsBaseDiscount方法的具体用法?PHP Mage_Sales_Model_Quote_Address::setRewardpointsBaseDiscount怎么用?PHP Mage_Sales_Model_Quote_Address::setRewardpointsBaseDiscount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Address
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Address::setRewardpointsBaseDiscount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
/**
* collect reward point label
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Magestore_RewardPoints_Model_Total_Quote_Label
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$address->setRewardpointsSpent(0);
$address->setRewardpointsBaseDiscount(0);
$address->setRewardpointsDiscount(0);
$address->setRewardpointsEarn(0);
$address->setMagestoreBaseDiscount(0);
return $this;
}
示例2: collect
/**
* collect reward point label
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Magestore_RewardPoints_Model_Total_Quote_Label
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$address->setRewardpointsSpent(0);
$address->setRewardpointsBaseDiscount(0);
$address->setRewardpointsDiscount(0);
$address->setRewardpointsEarn(0);
$address->setMagestoreBaseDiscount(0);
foreach ($address->getAllItems() as $item) {
if ($item->getParentItemId()) {
continue;
}
if ($item->getHasChildren() && $item->isChildrenCalculated()) {
foreach ($item->getChildren() as $child) {
$child->setRewardpointsBaseDiscount(0)->setRewardpointsDiscount(0)->setMagestoreBaseDiscount(0)->setRewardpointsSpent(0);
}
} elseif ($item->getProduct()) {
$item->setRewardpointsBaseDiscount(0)->setRewardpointsDiscount(0)->setMagestoreBaseDiscount(0)->setRewardpointsSpent(0);
}
}
return $this;
}
示例3: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$quote = $address->getQuote();
if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
return $this;
}
$session = Mage::getSingleton('checkout/session');
$catalogRules = $session->getCatalogRules();
if (!is_array($catalogRules)) {
$catalogRules = array();
}
$newCatalogRules = array();
$customerPoints = Mage::helper('rewardpoints/customer')->getAccountByCustomerId($session->getData('webpos_customerid'))->getPointBalance();
/* Hai.Tran 23.10.2013 */
if ($customerPoints < (int) Mage::getStoreConfig(Magestore_RewardPoints_Helper_Customer::XML_PATH_REDEEMABLE_POINTS, $quote->getStoreId())) {
$session->setCatalogRules($newCatalogRules);
return $this;
}
$helper = Mage::helper('rewardpointsrule/calculation_spending');
/* @var $helper Magestore_RewardPointsRule_Helper_Calculation_Spending */
$usePoint = 0;
$baseDiscount = 0;
$maxPointPerOrder = $helper->getMaxPointsPerOrder($quote->getStoreId());
foreach ($quote->getAllItems() as $item) {
if ($item->getParentItemId()) {
continue;
}
if (!isset($catalogRules[$item->getId()])) {
continue;
}
$rulePoints = $catalogRules[$item->getId()];
if ($customerPoints < $usePoint + $item->getQty() * $rulePoints['point_used']) {
$session->addError($helper->__('Not enough points to use the full catalog rule.'));
break;
}
if ($maxPointPerOrder && $maxPointPerOrder < $usePoint + $item->getQty() * $rulePoints['point_used']) {
$session->addError($helper->__('Maximum points allowed to spend for an order is %s', $maxPointPerOrder));
break;
}
$product = $item->getProduct();
if (!$product) {
$product = Mage::getModel('catalog/product')->load($item->getProductId());
}
$rule = $helper->getCatalogRule($rulePoints['rule_id']);
if (!$rule->getId() || !$rule->validate($product)) {
continue;
}
$points = $rulePoints['point_used'];
$baseRuleDiscount = $helper->getCatalogDiscount($rule, $product, $points);
$itemBaseDiscount = $item->getQty() * $baseRuleDiscount;
$itemDiscount = Mage::app()->getStore()->convertPrice($itemBaseDiscount);
$item->setRewardpointsBaseDiscount($itemBaseDiscount)->setRewardpointsDiscount($itemDiscount)->setRewardpointsSpent($item->getQty() * $points);
$baseDiscount += $itemBaseDiscount;
$usePoint += $item->getQty() * $points;
$newCatalogRules[$item->getId()] = array('item_id' => $item->getId(), 'item_qty' => $item->getQty(), 'rule_id' => $rule->getId(), 'point_used' => $points, 'base_point_discount' => $baseRuleDiscount, 'point_discount' => Mage::app()->getStore()->convertPrice($baseRuleDiscount), 'type' => 'catalog_spend');
}
$session->setCatalogRules($newCatalogRules);
if ($baseDiscount) {
$discount = Mage::app()->getStore()->convertPrice($baseDiscount);
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $baseDiscount);
$address->setGrandTotal($address->getGrandTotal() - $discount);
$address->setRewardpointsSpent($usePoint);
$address->setRewardpointsBaseDiscount($baseDiscount);
$address->setRewardpointsDiscount($discount);
}
return $this;
}