本文整理汇总了PHP中Mage_Sales_Model_Quote_Address::setGrandTotal方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Address::setGrandTotal方法的具体用法?PHP Mage_Sales_Model_Quote_Address::setGrandTotal怎么用?PHP Mage_Sales_Model_Quote_Address::setGrandTotal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Address
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Address::setGrandTotal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
/**
* Collect giftcertificate totals for specified address
*
* @param Mage_Sales_Model_Quote_Address $address
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$this->_collectQuoteGiftCards($address->getQuote());
$baseAmountLeft = $address->getQuote()->getBaseGiftCardsAmount() - $address->getQuote()->getBaseGiftCardsAmountUsed();
$amountLeft = $address->getQuote()->getGiftCardsAmount() - $address->getQuote()->getGiftCardsAmountUsed();
$baseTotalUsed = $totalUsed = $baseUsed = $used = $skipped = $baseSaved = $saved = 0;
if ($baseAmountLeft >= $address->getBaseGrandTotal()) {
$baseUsed = $address->getBaseGrandTotal();
$used = $address->getGrandTotal();
$address->setBaseGrandTotal(0);
$address->setGrandTotal(0);
} else {
$baseUsed = $baseAmountLeft;
$used = $amountLeft;
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $baseAmountLeft);
$address->setGrandTotal($address->getGrandTotal() - $amountLeft);
}
$addressCards = array();
$usedAddressCards = array();
if ($baseUsed) {
$quoteCards = $this->_sortGiftCards(Mage::helper('enterprise_giftcardaccount')->getCards($address->getQuote()));
foreach ($quoteCards as $quoteCard) {
$card = $quoteCard;
if ($quoteCard['ba'] + $skipped <= $address->getQuote()->getBaseGiftCardsAmountUsed()) {
$baseThisCardUsedAmount = $thisCardUsedAmount = 0;
} elseif ($quoteCard['ba'] + $baseSaved > $baseUsed) {
$baseThisCardUsedAmount = min($quoteCard['ba'], $baseUsed - $baseSaved);
$thisCardUsedAmount = min($quoteCard['a'], $used - $saved);
$baseSaved += $baseThisCardUsedAmount;
$saved += $thisCardUsedAmount;
} elseif ($quoteCard['ba'] + $skipped + $baseSaved > $address->getQuote()->getBaseGiftCardsAmountUsed()) {
$baseThisCardUsedAmount = min($quoteCard['ba'], $baseUsed);
$thisCardUsedAmount = min($quoteCard['a'], $used);
$baseSaved += $baseThisCardUsedAmount;
$saved += $thisCardUsedAmount;
} else {
$baseThisCardUsedAmount = $thisCardUsedAmount = 0;
}
// avoid possible errors in future comparisons
$card['ba'] = round($baseThisCardUsedAmount, 4);
$card['a'] = round($thisCardUsedAmount, 4);
$addressCards[] = $card;
if ($baseThisCardUsedAmount) {
$usedAddressCards[] = $card;
}
$skipped += $quoteCard['ba'];
}
}
Mage::helper('enterprise_giftcardaccount')->setCards($address, $usedAddressCards);
$address->setUsedGiftCards($address->getGiftCards());
Mage::helper('enterprise_giftcardaccount')->setCards($address, $addressCards);
$baseTotalUsed = $address->getQuote()->getBaseGiftCardsAmountUsed() + $baseUsed;
$totalUsed = $address->getQuote()->getGiftCardsAmountUsed() + $used;
$address->getQuote()->setBaseGiftCardsAmountUsed($baseTotalUsed);
$address->getQuote()->setGiftCardsAmountUsed($totalUsed);
$address->setBaseGiftCardsAmount($baseUsed);
$address->setGiftCardsAmount($used);
return $this;
}
示例2: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$quote = $address->getQuote();
$session = Mage::getSingleton('checkout/session');
if (is_null($session->getQuoteId())) {
$session = Mage::getSingleton('adminhtml/session_quote');
}
$isCustomerLoggedIn = (bool) $quote->getCustomer()->getId();
if ($session->getData('use_points') && $address->getBaseGrandTotal() && $isCustomerLoggedIn) {
$customer = Mage::getModel('customer/customer')->load($quote->getCustomer()->getId());
$pointsAmountUsed = abs($session->getData('points_amount'));
$pointsAmountAllowed = Mage::getModel('points/summary')->loadByCustomer($customer)->getPoints();
$storeId = $session->getQuote()->getStoreId();
$website = Mage::app()->getWebsite(Mage::app()->getStore($storeId)->getWebsiteId());
$baseSubtotalWithDiscount = $address->getData('base_subtotal') + $address->getData('base_discount_amount');
$subtotalWithDiscount = $address->getData('subtotal') + $address->getData('discount_amount');
$pointsSpendingCalculation = Mage::helper('points/config')->getPointsSpendingCalculation();
if ($pointsSpendingCalculation !== AW_Points_Helper_Config::BEFORE_TAX) {
$baseSubtotalWithDiscount += $address->getData('base_tax_amount');
$subtotalWithDiscount += $address->getData('tax_amount');
}
$limitedPoints = Mage::helper('points')->getLimitedPoints($baseSubtotalWithDiscount, $customer, $storeId);
$pointsAmountUsed = min($pointsAmountUsed, $pointsAmountAllowed, $limitedPoints);
$session->setData('points_amount', $pointsAmountUsed);
$rate = Mage::getModel('points/rate')->setCurrentCustomer($customer)->setCurrentWebsite($website)->loadByDirection(AW_Points_Model_Rate::POINTS_TO_CURRENCY);
if (!$rate->getId()) {
return $this;
}
$moneyBaseCurrencyForPoints = $rate->exchange($pointsAmountUsed);
$moneyCurrentCurrencyForPoints = Mage::app()->getStore()->convertPrice($moneyBaseCurrencyForPoints);
/**
* If points amount is more then needed to pay for subtotal with discount for order,
* we need to set new points amount
*/
if ($moneyBaseCurrencyForPoints > $baseSubtotalWithDiscount) {
$neededAmount = ceil($baseSubtotalWithDiscount * $rate->getPoints() / $rate->getMoney());
$neededAmountBaseCurrency = $rate->exchange($neededAmount);
$neededAmountCurrentCurrency = Mage::app()->getStore()->convertPrice($neededAmountBaseCurrency);
$session->setData('points_amount', $neededAmount);
$address->setGrandTotal($address->getData('grand_total') - $subtotalWithDiscount);
$address->setBaseGrandTotal($address->getData('base_grand_total') - $baseSubtotalWithDiscount);
$address->setMoneyForPoints($neededAmountCurrentCurrency);
$address->setBaseMoneyForPoints($neededAmountBaseCurrency);
$quote->setMoneyForPoints($neededAmountCurrentCurrency);
$quote->setBaseMoneyForPoints($neededAmountBaseCurrency);
} else {
$address->setGrandTotal($address->getGrandTotal() - $moneyCurrentCurrencyForPoints);
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $moneyBaseCurrencyForPoints);
$address->setMoneyForPoints($moneyCurrentCurrencyForPoints);
$address->setBaseMoneyForPoints($moneyBaseCurrencyForPoints);
$quote->setMoneyForPoints($moneyCurrentCurrencyForPoints);
$quote->setBaseMoneyForPoints($moneyBaseCurrencyForPoints);
}
}
return $this;
}
示例3: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
if ($address->getData('address_type') == 'billing') {
return $this;
}
// Fetch if "Store Credit" was applied by checking if "store_credit" session is not empty.
$raw = (double) $this->_getSession()->getData('store_credit');
if (!$raw) {
return $this;
}
/* START: Perform a re-check / validation in the credit's session.
* This will ensure that session has
* */
if (($customer_id = $this->_getSession()->getId()) > 0) {
list($read, $write) = $this->_getResource();
$sql = "SELECT credit_remaining FROM storecredit WHERE customer_id='" . $customer_id . "'";
$credit_remaining = (double) $read->fetchOne($sql);
if ($credit_remaining >= $raw) {
/* $credit_remaining must be always greater or equal than $raw (credit to use). */
} else {
return $this;
}
}
/* END: Perform a re-check / validation in the credit's session. */
$discount = (double) Mage::app()->getStore()->convertPrice($raw);
$address->setStoreCreditDiscount($discount);
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $raw);
$address->setGrandTotal($address->getGrandTotal() - $discount);
return $this;
}
示例4: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
if (!$this->_getConfigHelper()->getGeneralConfig('enable', $address->getQuote()->getStoreId())) {
return $this;
}
$customer = $address->getQuote()->getCustomer();
$baseGrandTotal = $address->getBaseGrandTotal();
if (!$customer || !$customer->getId() || $baseGrandTotal <= 0) {
return $this;
}
$baseDiscount = 0;
$luckyCodes = Mage::getModel('luckydraw/code')->getFailedCodes($customer->getId());
$useCodes = array();
foreach ($luckyCodes as $code) {
$codeDiscount = $code->getData('credit_rate');
$useCodes[] = $code->getId();
if ($baseGrandTotal - $codeDiscount <= 0) {
$baseGrandTotal = 0;
$baseDiscount = $address->getBaseGrandTotal();
break;
}
$baseGrandTotal -= $codeDiscount;
$baseDiscount += $codeDiscount;
}
if ($baseDiscount) {
Mage::getSingleton('core/session')->setUseLuckydrawCodes($useCodes);
$discount = Mage::app()->getStore()->convertPrice($baseDiscount);
$address->setBaseLuckydrawDiscount(-$baseDiscount);
$address->setLuckydrawDiscount(-$discount);
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $baseDiscount);
$address->setGrandTotal($address->getGrandTotal() - $discount);
}
return $this;
}
示例5: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$address->setPaymentCharge(0);
$address->setBasePaymentCharge(0);
$items = $address->getAllItems();
if (!count($items)) {
return $this;
}
$paymentMethod = $address->getQuote()->getPayment()->getMethod();
if (Mage::getStoreConfig('tax/calculation/price_includes_tax') != 1) {
$tax = $address->getTaxAmount();
}
if ($paymentMethod) {
$amount1 = Mage::helper('paymentcharge')->getPaymentCharge($paymentMethod, $address->getQuote());
$amount = Mage::helper('directory')->currencyConvert($amount1, Mage::app()->getWebsite()->getConfig('currency/options/default'), Mage::app()->getStore()->getCurrentCurrencyCode());
// if(Mage::getStoreConfig('payment/paypal_payment_solutions/charge_type')!="percentage"){
$address->setPaymentCharge($amount);
$address->setBasePaymentCharge($amount1);
/* } else {
$address->setPaymentCharge($amount);
$subTotal = $address->getBaseSubtotal();
$amount12 = ($subTotal+ $tax) * floatval(Mage::getStoreConfig('payment/paypal_payment_solutions/charge_value')) / 100;
$address->setBasePaymentCharge($amount12);
}*/
}
$address->setGrandTotal($address->getGrandTotal() + $tax + $address->getPaymentCharge());
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBasePaymentCharge());
return $this;
}
示例6: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$_helper = Mage::helper('webpos');
$active = $_helper->enableGiftWrap();
if (!$active) {
return;
}
$session = Mage::getSingleton('checkout/session');
$giftwrap = $session->getData('webpos_giftwrap');
if (!$giftwrap) {
return $this;
}
$items = $address->getAllItems();
if (!count($items)) {
return $this;
}
$giftwrapType = $_helper->getGiftwrapType();
$giftwrapAmount = $_helper->getGiftwrapAmount();
$wrapTotal = 0;
if ($giftwrapType == 1) {
foreach ($items as $item) {
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
continue;
}
$wrapTotal += $giftwrapAmount * $item->getQty();
}
} else {
$wrapTotal = $giftwrapAmount;
}
$session->setData('webpos_giftwrap_amount', $wrapTotal);
$address->setWebposGiftwrapAmount($wrapTotal);
$address->setGrandTotal($address->getGrandTotal() + $address->getWebposGiftwrapAmount());
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getWebposGiftwrapAmount());
return $this;
}
示例7: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$active = Mage::helper('giftwrap')->enableGiftwrap();
if (!$active) {
return;
}
if (Mage::app()->getStore()->isAdmin()) {
return $this;
}
$items = $address->getAllItems();
if (!count($items)) {
return $this;
}
$address_id = $address->getId();
/*
* update of version 0.2.2
*/
$giftwrapAmount = Mage::helper('giftwrap')->giftwrapAmount(null, $address_id);
$address->setGiftwrapAmount($giftwrapAmount);
$address->setBaseGiftwrapAmount(0);
//var_dump($address->getData());die();
// if($giftwrapAmount>0){
// $taxAmount = 10;
// $address->setTaxAmount($address->getTaxAmount() + $taxAmount);
// $address->setBaseTaxAmount($address->getBaseTaxAmount() + $taxAmount);
// }
Mage::getModel('core/session')->setData('giftwrap_amount', $giftwrapAmount);
$address->setGrandTotal($address->getGrandTotal() + $address->getGiftwrapAmount());
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getGiftwrapAmount());
//var_dump($address->getData());die();
return $this;
}
示例8: collect
/**
* Collect grand total address amount
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_Sales_Model_Quote_Address_Total_Grand
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
/** @var $helper Openstream_RappenRounding_Helper_Data */
$helper = Mage::helper('rappenrounding');
$grandTotal = $address->getGrandTotal();
$baseGrandTotal = $address->getBaseGrandTotal();
$totals = array_sum($address->getAllTotalAmounts());
$baseTotals = array_sum($address->getAllBaseTotalAmounts());
if ($helper->getScope() == 'totals' || $helper->getScope() == 'all') {
$address->setGrandTotal($helper->_roundBase5($grandTotal + $totals));
$address->setBaseGrandTotal($helper->_roundBase5($baseGrandTotal + $baseTotals));
} else {
$address->setGrandTotal($grandTotal + $totals);
$address->setBaseGrandTotal($baseGrandTotal + $baseTotals);
}
return $this;
}
示例9: collect
/**
* Collect reward totals
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Enterprise_Reward_Model_Total_Quote_Reward
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
/* @var $quote Mage_Sales_Model_Quote */
$quote = $address->getQuote();
if (!Mage::helper('enterprise_reward')->isEnabledOnFront($quote->getStore()->getWebsiteId())) {
return $this;
}
if (!$quote->getRewardPointsTotalReseted() && $address->getBaseGrandTotal() > 0) {
$quote->setRewardPointsBalance(0)->setRewardCurrencyAmount(0)->setBaseRewardCurrencyAmount(0);
$address->setRewardPointsBalance(0)->setRewardCurrencyAmount(0)->setBaseRewardCurrencyAmount(0);
$quote->setRewardPointsTotalReseted(true);
}
if ($address->getBaseGrandTotal() >= 0 && $quote->getCustomer()->getId() && $quote->getUseRewardPoints()) {
/* @var $reward Enterprise_Reward_Model_Reward */
$reward = $quote->getRewardInstance();
if (!$reward || !$reward->getId()) {
$reward = Mage::getModel('enterprise_reward/reward')->setCustomer($quote->getCustomer())->setCustomerId($quote->getCustomer()->getId())->setWebsiteId($quote->getStore()->getWebsiteId())->loadByCustomer();
}
$pointsLeft = $reward->getPointsBalance() - $quote->getRewardPointsBalance();
$rewardCurrencyAmountLeft = $quote->getStore()->convertPrice($reward->getCurrencyAmount()) - $quote->getRewardCurrencyAmount();
$baseRewardCurrencyAmountLeft = $reward->getCurrencyAmount() - $quote->getBaseRewardCurrencyAmount();
if ($baseRewardCurrencyAmountLeft >= $address->getBaseGrandTotal()) {
$pointsBalanceUsed = $reward->getPointsEquivalent($address->getBaseGrandTotal());
$pointsCurrencyAmountUsed = $address->getGrandTotal();
$basePointsCurrencyAmountUsed = $address->getBaseGrandTotal();
$address->setGrandTotal(0);
$address->setBaseGrandTotal(0);
} else {
$pointsBalanceUsed = $reward->getPointsEquivalent($baseRewardCurrencyAmountLeft);
if ($pointsBalanceUsed > $pointsLeft) {
$pointsBalanceUsed = $pointsLeft;
}
$pointsCurrencyAmountUsed = $rewardCurrencyAmountLeft;
$basePointsCurrencyAmountUsed = $baseRewardCurrencyAmountLeft;
$address->setGrandTotal($address->getGrandTotal() - $pointsCurrencyAmountUsed);
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $basePointsCurrencyAmountUsed);
}
$quote->setRewardPointsBalance($quote->getRewardPointsBalance() + $pointsBalanceUsed);
$quote->setRewardCurrencyAmount($quote->getRewardCurrencyAmount() + $pointsCurrencyAmountUsed);
$quote->setBaseRewardCurrencyAmount($quote->getBaseRewardCurrencyAmount() + $basePointsCurrencyAmountUsed);
$address->setRewardPointsBalance($pointsBalanceUsed);
$address->setRewardCurrencyAmount($pointsCurrencyAmountUsed);
$address->setBaseRewardCurrencyAmount($basePointsCurrencyAmountUsed);
}
return $this;
}
示例10: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$address->setCustbalanceAmount(0);
$address->setBaseCustbalanceAmount(0);
$address->setGrandTotal($address->getGrandTotal() - $address->getCustbalanceAmount());
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $address->getBaseCustbalanceAmount());
return $this;
}
示例11: setSubscriptionFee
protected function setSubscriptionFee(Mage_Sales_Model_Quote_Address $address)
{
$fee = "0.01";
$currentAmount = $address->getSubscriptionFeeAmount();
$balance = $fee - $currentAmount;
$address->setSubscriptionFeeAmount($address->getQuote()->getStore()->convertPrice($balance));
$address->setBaseSubscriptionFeeAmount($balance);
$address->setGrandTotal($address->getGrandTotal() + $address->getSubscriptionFeeAmount());
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseSubscriptionFeeAmount());
}
示例12: collect
/**
* Collect grand total address amount
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_Sales_Model_Quote_Address_Total_Grand
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$grandTotal = $address->getGrandTotal();
$baseGrandTotal = $address->getBaseGrandTotal();
$totals = array_sum($address->getAllTotalAmounts());
$baseTotals = array_sum($address->getAllBaseTotalAmounts());
$address->setGrandTotal($grandTotal + $totals);
$address->setBaseGrandTotal($baseGrandTotal + $baseTotals);
return $this;
}
示例13: collectTotals
public function collectTotals(Mage_Sales_Model_Quote_Address $address)
{
$gift = Mage::getResourceModel('sales/giftcert')->getGiftcertByCode($address->getGiftcertCode());
if ($gift) {
$address->setGiftcertAmount(min($address->getGrandTotal(), $gift['balance_amount']));
} else {
$address->setGiftcertAmount(0);
}
$address->setGrandTotal($address->getGrandTotal() - $address->getGiftcertAmount());
return $this;
}
示例14: collect
/**
* Collect customer balance totals for specified address
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Enterprise_CustomerBalance_Model_Total_Quote_Customerbalance
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
if (!Mage::helper('enterprise_customerbalance')->isEnabled()) {
return $this;
}
$quote = $address->getQuote();
if (!$quote->getCustomerBalanceCollected()) {
$quote->setBaseCustomerBalAmountUsed(0);
$quote->setCustomerBalanceAmountUsed(0);
$quote->setCustomerBalanceCollected(true);
}
$baseTotalUsed = $totalUsed = $baseUsed = $used = 0;
$baseBalance = $balance = 0;
if ($quote->getCustomer()->getId()) {
if ($quote->getUseCustomerBalance()) {
$store = Mage::app()->getStore($quote->getStoreId());
$baseBalance = Mage::getModel('enterprise_customerbalance/balance')->setCustomer($quote->getCustomer())->setCustomerId($quote->getCustomer()->getId())->setWebsiteId($store->getWebsiteId())->loadByCustomer()->getAmount();
$balance = $quote->getStore()->convertPrice($baseBalance);
}
}
$baseAmountLeft = $baseBalance - $quote->getBaseCustomerBalAmountUsed();
$amountLeft = $balance - $quote->getCustomerBalanceAmountUsed();
if ($baseAmountLeft >= $address->getBaseGrandTotal()) {
$baseUsed = $address->getBaseGrandTotal();
$used = $address->getGrandTotal();
$address->setBaseGrandTotal(0);
$address->setGrandTotal(0);
} else {
$baseUsed = $baseAmountLeft;
$used = $amountLeft;
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $baseAmountLeft);
$address->setGrandTotal($address->getGrandTotal() - $amountLeft);
}
$baseTotalUsed = $quote->getBaseCustomerBalAmountUsed() + $baseUsed;
$totalUsed = $quote->getCustomerBalanceAmountUsed() + $used;
$quote->setBaseCustomerBalAmountUsed($baseTotalUsed);
$quote->setCustomerBalanceAmountUsed($totalUsed);
$address->setBaseCustomerBalanceAmount($baseUsed);
$address->setCustomerBalanceAmount($used);
return $this;
}
示例15: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
if ($address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_BILLING) {
return;
}
$quote = $address->getQuote();
$amount = $this->_giftWrapAmount();
$address->setAmount($amount);
$address->setGrandTotal($address->getGrandTotal() + $amount);
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $amount);
return $this;
}