本文整理汇总了PHP中Mage_Sales_Model_Quote_Address::setSubtotalWithDiscount方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Address::setSubtotalWithDiscount方法的具体用法?PHP Mage_Sales_Model_Quote_Address::setSubtotalWithDiscount怎么用?PHP Mage_Sales_Model_Quote_Address::setSubtotalWithDiscount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Address
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Address::setSubtotalWithDiscount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resetAddress
protected function resetAddress(Mage_Sales_Model_Quote_Address $address)
{
$address->setDiscountAmount(0.0);
$address->setBaseDiscountAmount(0.0);
$address->setSubtotalWithDiscount($address->getSubtotal());
$address->setBaseSubtotalWithDiscount($address->getBaseSubtotal());
$address->setDiscountDescription('');
$address->setDiscountDescriptionArray([]);
if (!$address->getData('__applied_rules_reset__')) {
$address->setAppliedRuleIds('');
$address->setData('__applied_rules_reset__', true);
}
$address->setShippingDiscountAmount(0);
$address->setBaseShippingDiscountAmount(0);
$address->setFreeShipping(false);
}
示例2: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$quote = $address->getQuote();
$credit = Mage::helper('credit')->exchangeCreditToMoney(Mage::getSingleton('checkout/session')->getCredit());
$subtotalWithDiscount = 0;
$items = $address->getAllItems();
if (!count($items)) {
return $this;
}
$address->setCreditDiscount($credit);
$address->setSubtotalWithDiscount($subtotalWithDiscount - $credit);
$address->setBaseCreditDiscount($credit);
$address->setBaseSubtotalWithDiscount($subtotalWithDiscount - $credit);
$address->setGrandTotal($address->getGrandTotal() - $address->getCreditDiscount());
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $address->getBaseCreditDiscount());
$address->setBaseDiscountAmount($address->getBaseDiscountAmount() - $address->getBaseCreditDiscount());
return $this;
}
示例3: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$quote = $address->getQuote();
$eventArgs = array('website_id' => Mage::app()->getStore($quote->getStoreId())->getWebsiteId(), 'customer_group_id' => $quote->getCustomerGroupId(), 'coupon_code' => $quote->getCouponCode());
$address->setFreeShipping(0);
$totalDiscountAmount = 0;
$subtotalWithDiscount = 0;
$baseTotalDiscountAmount = 0;
$baseSubtotalWithDiscount = 0;
$hasDiscount = false;
foreach ($address->getAllItems() as $item) {
if ($item->getNoDiscount()) {
$item->setDiscountAmount(0);
$item->setBaseDiscountAmount(0);
$item->setRowTotalWithDiscount($item->getRowTotal());
$item->setBaseRowTotalWithDiscount($item->getRowTotal());
$subtotalWithDiscount += $item->getRowTotal();
$baseSubtotalWithDiscount += $item->getBaseRowTotal();
} else {
$eventArgs['item'] = $item;
Mage::dispatchEvent('sales_quote_address_discount_item', $eventArgs);
if ($item->getDiscountAmount()) {
$hasDiscount = true;
}
$totalDiscountAmount += $item->getDiscountAmount();
$baseTotalDiscountAmount += $item->getBaseDiscountAmount();
$item->setRowTotalWithDiscount($item->getRowTotal() - $item->getDiscountAmount());
$item->setBaseRowTotalWithDiscount($item->getBaseRowTotal() - $item->getBaseDiscountAmount());
$subtotalWithDiscount += $item->getRowTotalWithDiscount();
$baseSubtotalWithDiscount += $item->getBaseRowTotalWithDiscount();
}
}
$address->setDiscountAmount($totalDiscountAmount);
$address->setSubtotalWithDiscount($subtotalWithDiscount);
$address->setBaseDiscountAmount($baseTotalDiscountAmount);
$address->setBaseSubtotalWithDiscount($baseSubtotalWithDiscount);
if (!$hasDiscount) {
$quote->setCouponCode(null);
}
$address->setGrandTotal($address->getGrandTotal() - $address->getDiscountAmount());
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $address->getBaseDiscountAmount());
return $this;
}
示例4: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$quote = $address->getQuote();
$eventArgs = array('website_id' => Mage::app()->getStore($quote->getStoreId())->getWebsiteId(), 'customer_group_id' => $quote->getCustomerGroupId(), 'coupon_code' => $quote->getCouponCode());
$address->setFreeShipping(0);
$totalDiscountAmount = 0;
$subtotalWithDiscount = 0;
$baseTotalDiscountAmount = 0;
$baseSubtotalWithDiscount = 0;
$items = $address->getAllItems();
if (!count($items)) {
$address->setDiscountAmount($totalDiscountAmount);
$address->setSubtotalWithDiscount($subtotalWithDiscount);
$address->setBaseDiscountAmount($baseTotalDiscountAmount);
$address->setBaseSubtotalWithDiscount($baseSubtotalWithDiscount);
return $this;
}
$hasDiscount = false;
foreach ($items as $item) {
if ($item->getNoDiscount()) {
$item->setDiscountAmount(0);
$item->setBaseDiscountAmount(0);
$item->setRowTotalWithDiscount($item->getRowTotal());
$item->setBaseRowTotalWithDiscount($item->getRowTotal());
$subtotalWithDiscount += $item->getRowTotal();
$baseSubtotalWithDiscount += $item->getBaseRowTotal();
} else {
/**
* Child item discount we calculate for parent
*/
if ($item->getParentItemId()) {
continue;
}
/**
* Composite item discount calculation
*/
if ($item->getHasChildren() && $item->isChildrenCalculated()) {
foreach ($item->getChildren() as $child) {
$eventArgs['item'] = $child;
Mage::dispatchEvent('sales_quote_address_discount_item', $eventArgs);
if ($child->getDiscountAmount() || $child->getFreeShipping()) {
$hasDiscount = true;
}
/**
* Parent free shipping we apply to all children
*/
if ($item->getFreeShipping()) {
$child->setFreeShipping($item->getFreeShipping());
}
/**
* @todo Parent discount we apply for all children without discount
*/
if (!$child->getDiscountAmount() && $item->getDiscountPercent()) {
}
$totalDiscountAmount += $child->getDiscountAmount();
//*$item->getQty();
$baseTotalDiscountAmount += $child->getBaseDiscountAmount();
//*$item->getQty();
$child->setRowTotalWithDiscount($child->getRowTotal() - $child->getDiscountAmount());
$child->setBaseRowTotalWithDiscount($child->getBaseRowTotal() - $child->getBaseDiscountAmount());
$subtotalWithDiscount += $child->getRowTotalWithDiscount();
$baseSubtotalWithDiscount += $child->getBaseRowTotalWithDiscount();
}
} else {
$eventArgs['item'] = $item;
Mage::dispatchEvent('sales_quote_address_discount_item', $eventArgs);
if ($item->getDiscountAmount() || $item->getFreeShipping()) {
$hasDiscount = true;
}
$totalDiscountAmount += $item->getDiscountAmount();
$baseTotalDiscountAmount += $item->getBaseDiscountAmount();
$item->setRowTotalWithDiscount($item->getRowTotal() - $item->getDiscountAmount());
$item->setBaseRowTotalWithDiscount($item->getBaseRowTotal() - $item->getBaseDiscountAmount());
$subtotalWithDiscount += $item->getRowTotalWithDiscount();
$baseSubtotalWithDiscount += $item->getBaseRowTotalWithDiscount();
}
}
}
$address->setDiscountAmount($totalDiscountAmount);
$address->setSubtotalWithDiscount($subtotalWithDiscount);
$address->setBaseDiscountAmount($baseTotalDiscountAmount);
$address->setBaseSubtotalWithDiscount($baseSubtotalWithDiscount);
$address->setGrandTotal($address->getGrandTotal() - $address->getDiscountAmount());
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $address->getBaseDiscountAmount());
return $this;
}