本文整理汇总了PHP中Mage_Sales_Model_Quote_Address::getBaseDiscountAmount方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Address::getBaseDiscountAmount方法的具体用法?PHP Mage_Sales_Model_Quote_Address::getBaseDiscountAmount怎么用?PHP Mage_Sales_Model_Quote_Address::getBaseDiscountAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Address
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Address::getBaseDiscountAmount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例5: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$session = Mage::getSingleton('admin/session');
$store_id = Mage::app()->getStore()->getId();
if (Mage::helper('affiliate/data')->getEnabledStore($store_id)) {
$quote = $address->getQuote();
$items = $address->getAllVisibleItems();
//$items = $address->getAllNonNominalItems();
if (!count($items)) {
return $this;
}
// xu ly code
// zend_debug::dump($items);die();
$discountAmount = 0;
$referral_code = Mage::helper('affiliate')->getReferralCodeByCheckout();
$customer_id = (int) Mage::getSingleton("customer/session")->getCustomer()->getId();
$program_priority = Mage::helper('affiliate/data')->getAffiliatePositionStore($store_id);
$position_discount = Mage::helper('affiliate/data')->getAffiliateDiscountStore($store_id);
$programs = array();
$programs = $this->getAllProgram();
if (!Mage::app()->isSingleStoreMode()) {
$programs = $this->getProgramByStoreView($programs);
}
$programs = $this->getProgramByEnable($programs);
$_programs = $this->getProgramByTime($programs);
foreach ($items as $item) {
$product_id = $item->getProductId();
$qty = $item->getQty();
//$price = $item->getPrice();
//$item->setBaseDiscountAmount($item->getBaseDiscountAmount() - $item->getAffiliateDiscount());
if ($position_discount == 1) {
$price = $item->getBasePrice();
} else {
$price = $item->getBasePrice() - $item->getBaseDiscountAmount() / $qty;
}
//$price = $item->getPrice();
$programs = $this->processRule($item, $_programs);
//var_dump($programs);exit;
// neu mang program > 0
$programs = $this->getProgramByCustomer($programs, $referral_code);
//var_dump($programs);exit;
if (sizeof($programs) >= 2) {
$array_customer_inviteds = array_splice($programs, sizeof($programs) - 1, 1);
foreach ($array_customer_inviteds as $array_customer_invited) {
$customer_invited = $array_customer_invited;
break;
}
// lay program theo 3 tieu chi
if ($program_priority == 1) {
$program_id = $this->getProgramByCommission($programs, $qty, $price, $customer_invited);
} else {
if ($program_priority == 2) {
$program_id = $this->getProgramByDiscount($programs, $qty, $price, $customer_invited);
} else {
if ($program_priority == 3) {
$program_id = $this->getProgramByPosition($programs);
}
}
}
$discount = $this->getDiscountByProgram($program_id, $qty, $price, $customer_invited);
} else {
$discount = 0;
}
$discount = round($discount, 2);
$discountAmount = $discountAmount + $discount;
$item->setDiscountAmount($item->getDiscountAmount() + Mage::helper('core')->currency($discount, false, false));
$item->setBaseDiscountAmount($item->getBaseDiscountAmount() + $discount);
$item->setMwAffiliateDiscount($discount);
// tim ra mang chuong trinh cho moi san pham $programs
// kiem tra xem san pham do dung chuong trinh khuyen mai nao
//var_dump($program_id);die();
}
//$discountAmount = 100;
//phan xu ly cuoi cung
$discountAmount_show = Mage::helper('core')->currency($discountAmount, false, false);
//$address->setDiscountAmount($address->getDiscountAmount() - $discountAmount_show);// gia de hien thi
$address->setBaseDiscountAmount($address->getBaseDiscountAmount() - $discountAmount);
// gia de tinh toan
$address->setAffiliateDiscount($discountAmount_show);
// gia de hien thi
$address->setBaseAffiliateDiscount($discountAmount);
$address->setGrandTotal($address->getGrandTotal() - $address->getAffiliateDiscount());
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $address->getBaseAffiliateDiscount());
return $this;
}
}
示例6: createTaxRequestFromQuoteAddress
protected function createTaxRequestFromQuoteAddress(Mage_Sales_Model_Quote_Address $address)
{
$quote = $address->getQuote();
$store = $quote->getStore();
$hideDiscountAmount = Mage::getStoreConfigFlag(Mage_Tax_Model_Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT, $store);
$timestamp = $quote->getCreatedAt() ? Varien_Date::toTimestamp($quote->getCreatedAt()) : now();
$date = new Zend_Date($timestamp);
$request = array('Client' => 'Aoe_AvaTax', 'CompanyCode' => $this->limit($this->getHelper()->getConfig('company_code', $store), 25), 'DocType' => 'SalesOrder', 'Commit' => false, 'DetailLevel' => 'Tax', 'DocDate' => $date->toString('yyyy-MM-dd'), 'CustomerCode' => $this->getHelper()->getCustomerDocCode($quote->getCustomer()) ?: $this->getHelper()->getQuoteDocCode($quote), 'CurrencyCode' => $this->limit($quote->getBaseCurrencyCode(), 3), 'Discount' => $hideDiscountAmount ? 0.0 : $store->roundPrice($address->getBaseDiscountAmount()), 'Addresses' => array(), 'Lines' => array());
if ($quote->getCustomerTaxvat()) {
$request['BusinessIdentificationNo'] = $this->limit($quote->getCustomerTaxvat(), 25);
}
$request['Addresses'][] = $this->getOriginAddress('ORIGIN', $store);
$request['Addresses'][] = $this->getAddress('DESTINATION', $address);
$itemPriceIncludesTax = Mage::getStoreConfigFlag(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $store);
foreach ($this->getHelper()->getActionableQuoteAddressItems($address) as $k => $item) {
/** @var Mage_Sales_Model_Quote_Item|Mage_Sales_Model_Quote_Address_Item $item */
$request['Lines'][] = array("LineNo" => $this->limit($k, 50), "ItemCode" => $this->limit($item->getSku(), 50), "Qty" => round(floatval($item->getQty()), 4), "Amount" => $store->roundPrice($item->getBaseRowTotal()) - $store->roundPrice($item->getBaseDiscountAmount()), "OriginCode" => "ORIGIN", "DestinationCode" => "DESTINATION", "Description" => $this->limit($item->getName(), 255), "TaxCode" => $this->limit($this->getHelper()->getProductTaxCode($item->getProduct()), 25), "Discounted" => $item->getBaseDiscountAmount() > 0.0, "TaxIncluded" => $itemPriceIncludesTax, "Ref1" => $this->limit($this->getHelper()->getQuoteItemRef1($item, $store), 250), "Ref2" => $this->limit($this->getHelper()->getQuoteItemRef2($item, $store), 250));
}
$shippingPriceIncludesTax = Mage::getStoreConfigFlag(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_INCLUDES_TAX, $store);
$request['Lines'][] = array("LineNo" => "SHIPPING", "ItemCode" => "SHIPPING", "Qty" => "1", "Amount" => $store->roundPrice($address->getBaseShippingAmount()) - $store->roundPrice($address->getBaseShippingDiscountAmount()), "OriginCode" => "ORIGIN", "DestinationCode" => "DESTINATION", "Description" => $this->limit("Shipping: " . $address->getShippingMethod(), 255), "TaxCode" => $this->limit($this->getHelper()->getShippingTaxCode($store), 25), "Discounted" => $address->getBaseShippingDiscountAmount() > 0.0, "TaxIncluded" => $shippingPriceIncludesTax, "Ref1" => $this->limit($address->getShippingMethod(), 250));
// TODO: Handle giftwrapping
return $request;
}