本文整理汇总了PHP中Mage_Sales_Model_Quote_Address::getDiscountAmount方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Address::getDiscountAmount方法的具体用法?PHP Mage_Sales_Model_Quote_Address::getDiscountAmount怎么用?PHP Mage_Sales_Model_Quote_Address::getDiscountAmount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Address
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Address::getDiscountAmount方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addressToOrder
/**
* Convert quote address model to order
*
* @param Mage_Sales_Model_Quote $quote
* @return Mage_Sales_Model_Order
*/
public function addressToOrder(Mage_Sales_Model_Quote_Address $address, $order = null)
{
if (!$order instanceof Mage_Sales_Model_Order) {
$order = $this->toOrder($address->getQuote());
}
$order->setWeight($address->getWeight())->setShippingMethod($address->getShippingMethod())->setShippingDescription($address->getShippingDescription())->setShippingRate($address->getShippingRate())->setSubtotal($address->getSubtotal())->setTaxAmount($address->getTaxAmount())->setDiscountAmount($address->getDiscountAmount())->setShippingAmount($address->getShippingAmount())->setGiftcertAmount($address->getGiftcertAmount())->setCustbalanceAmount($address->getCustbalanceAmount())->setGrandTotal($address->getGrandTotal())->setBaseSubtotal($address->getBaseSubtotal())->setBaseTaxAmount($address->getBaseTaxAmount())->setBaseDiscountAmount($address->getBaseDiscountAmount())->setBaseShippingAmount($address->getBaseShippingAmount())->setBaseGiftcertAmount($address->getBaseGiftcertAmount())->setBaseCustbalanceAmount($address->getBaseCustbalanceAmount())->setBaseGrandTotal($address->getBaseGrandTotal());
Mage::dispatchEvent('sales_convert_quote_address_to_order', array('address' => $address, 'order' => $order));
return $order;
}
示例2: fetch
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
$amount = $address->getDiscountAmount();
if ($amount != 0) {
$title = Mage::helper('sales')->__('Discount');
if ($code = $address->getQuote()->getCouponCode()) {
$title = Mage::helper('sales')->__('Discount (%s)', $code);
}
$address->addTotal(array('code' => $this->getCode(), 'title' => $title, 'value' => -$amount));
}
return $this;
}
示例3: fetchTotals
public function fetchTotals(Mage_Sales_Model_Quote_Address $address)
{
$amount = $address->getDiscountAmount();
if ($amount != 0) {
$title = AO::helper('sales')->__('Discount');
if ($address->getQuote()->getCouponCode()) {
$title .= ' (' . $address->getQuote()->getCouponCode() . ')';
}
$address->addTotal(array('code' => 'discount', 'title' => $title, 'value' => -$amount));
}
return $this;
}
示例4: fetchTotals
/**
* Fetch discount
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_Sales_Model_Resource_Quote_Address_Attribute_Frontend_Discount
*/
public function fetchTotals(Mage_Sales_Model_Quote_Address $address)
{
$amount = $address->getDiscountAmount();
if ($amount != 0) {
$title = Mage::helper('Mage_Sales_Helper_Data')->__('Discount');
if ($address->getQuote()->getCouponCode()) {
$title .= sprintf(' (%s)', $address->getQuote()->getCouponCode());
}
$address->addTotal(array('code' => 'discount', 'title' => $title, 'value' => -$amount));
}
return $this;
}
示例5: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$store = $address->getQuote()->getStore();
$session = Mage::getSingleton('checkout/session');
$discount = $session->getData('webpos_admin_discount');
if (!$discount) {
return $this;
}
$items = $address->getAllItems();
if (!count($items)) {
return $this;
}
$session->setData('webpos_admin_discount', $discount);
$address->setWebposDiscountAmount($discount);
$address->setData('webpos_discount_amount', $discount);
/* Daniel - tax for discount */
$afterDiscount = Mage::getStoreConfig('tax/calculation/apply_after_discount');
if ($afterDiscount) {
$country = Mage::getModel('checkout/session')->getQuote()->getShippingAddress()->getCountry();
$oldTax = $address->getTaxAmount();
$oldBaseTax = $address->getBaseTaxAmount();
if ($country) {
$rateTax = Mage::getModel('tax/calculation_rate')->getCollection()->addFieldToFilter('tax_country_id', $country)->setOrder('rate', 'DESC')->getFirstItem();
$address->setTaxAmount(($address->getBaseSubtotal() - $discount + $address->getShippingAmount() + $address->getDiscountAmount()) * $rateTax->getRate() / 100)->setBaseTaxAmount(($address->getBaseSubtotal() - $discount + $address->getShippingAmount() + $address->getDiscountAmount()) * $rateTax->getRate() / 100);
$taxCalculationModel = Mage::getSingleton('tax/calculation');
$request = Mage::getSingleton('tax/calculation')->getRateRequest($address, $address->getQuote()->getBillingAddress(), $address->getQuote()->getCustomerTaxClassId(), $store);
$rate = Mage::getSingleton('tax/calculation')->getRate($request);
$this->_saveAppliedTaxes($address, $taxCalculationModel->getAppliedRates($request), $address->getTaxAmount(), $address->getBaseTaxAmount(), $rate);
}
$address->setGrandTotal($address->getGrandTotal() - $address->getWebposDiscountAmount());
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $address->getWebposDiscountAmount());
} else {
$address->setGrandTotal($address->getGrandTotal() - $address->getWebposDiscountAmount());
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $address->getWebposDiscountAmount());
}
/* end */
return $this;
}
示例6: fetch
/**
* Add discount/surcharge total information to address
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_SalesRule_Model_Quote_Discount
*/
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
$amount = $address->getDiscountAmount();
$part = Mage::helper('aitloyalty/discount')->getTitlePart($amount);
if ($amount != 0) {
$description = $address->getDiscountDescription();
if ($description) {
$title = Mage::helper('sales')->__($part . ' (%s)', $description);
} else {
$title = Mage::helper('sales')->__($part);
}
$address->addTotal(array('code' => $this->getCode(), 'title' => $title, 'value' => $amount, 'full_info' => $address->getFullDescr()));
}
return $this;
}
示例7: fetch
/**
* Add discount total information to address
* Added 'off first payment only' message for discount
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_SalesRule_Model_Quote_Discount
*/
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
$add_message = Mage::helper('pixopc')->getDiscountDetails();
$amount = $address->getDiscountAmount();
if ($amount != 0) {
$description = $address->getDiscountDescription();
if (strlen($description)) {
$title = Mage::helper('sales')->__('Coupon: %s', $description);
} else {
$title = Mage::helper('sales')->__('Coupon');
}
$address->addTotal(array('code' => $this->getCode(), 'title' => $title, 'value' => Mage::helper('checkout')->formatPrice($amount) . $add_message));
}
return $this;
}
示例8: fetch
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
$amount = $address->getDiscountAmount();
if ($amount != 0) {
if ($amount > 0) {
$title = Mage::helper('sales')->__('Discount');
} else {
$title = Mage::helper('sales')->__('Surcharge');
}
if ($code = $address->getCouponCode()) {
if ($amount > 0) {
$title = Mage::helper('sales')->__('Discount (%s)', $code);
} else {
$title = Mage::helper('sales')->__('Surcharge (%s)', $code);
}
}
$address->addTotal(array('code' => $this->getCode(), 'title' => $title, 'value' => -$amount, 'full_info' => $address->getFullDescr()));
}
return $this;
}
示例9: fetch
/**
* Add discount total information to address
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_SalesRule_Model_Quote_Discount
*/
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
$amount = $address->getDiscountAmount();
if ($amount != 0) {
$description = $address->getDiscountDescription();
if (strlen($description)) {
$title = Mage::helper('sales')->__('Discount (%s)', $description);
} else {
$title = Mage::helper('sales')->__('Discount');
}
$address->addTotal(array('code' => $this->getCode(), 'title' => $title, 'value' => $amount));
}
return $this;
}
示例10: calculateCartTotal
/**
* Calculate cart total net
*
* @param Mage_Sales_Model_Quote_Address $address
* @return int
*/
private function calculateCartTotal($address)
{
if ($address->getTaxAmount() > 0) {
$value = $address->getGrandTotal() - $address->getTaxAmount();
return $this->currencyToSmallerUnit($value);
} else {
$discount = $address->getDiscountAmount() < 0 ? -$address->getDiscountAmount() : $address->getDiscountAmount();
$value = $address->getSubtotal() + $address->getShippingAmount() + $this->getQuote()->getBillpayChargedFeeNet() - $discount;
// TODO: for rate payment add fee tax amount
return $this->currencyToSmallerUnit($value);
}
}