本文整理汇总了PHP中Mage_Sales_Model_Quote::getBaseGrandTotal方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote::getBaseGrandTotal方法的具体用法?PHP Mage_Sales_Model_Quote::getBaseGrandTotal怎么用?PHP Mage_Sales_Model_Quote::getBaseGrandTotal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote::getBaseGrandTotal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
/**
* collect reward points that customer earned (per each item and address) total
*
* @param Mage_Sales_Model_Quote_Address $address
* @param Mage_Sales_Model_Quote $quote
* @return Magestore_RewardPoints_Model_Total_Quote_Point
*/
public function collect($address, $quote)
{
if (!Mage::helper('rewardpoints')->isEnable($quote->getStoreId())) {
return $this;
}
// get points that customer can earned by Rates
if ($quote->isVirtual()) {
$address = $quote->getBillingAddress();
} else {
$address = $quote->getShippingAddress();
}
$baseGrandTotal = $quote->getBaseGrandTotal();
if (!Mage::getStoreConfigFlag(Magestore_RewardPoints_Helper_Calculation_Earning::XML_PATH_EARNING_BY_SHIPPING, $quote->getStoreId())) {
$baseGrandTotal -= $address->getBaseShippingAmount();
}
if (!Mage::getStoreConfigFlag(Magestore_RewardPoints_Helper_Calculation_Earning::XML_PATH_EARNING_BY_TAX, $quote->getStoreId())) {
$baseGrandTotal -= $address->getBaseTaxAmount();
}
$baseGrandTotal = max(0, $baseGrandTotal);
$earningPoints = Mage::helper('rewardpoints/calculation_earning')->getRateEarningPoints($baseGrandTotal, $quote->getStoreId());
if ($earningPoints > 0) {
$address->setRewardpointsEarn($earningPoints);
}
Mage::dispatchEvent('rewardpoints_collect_earning_total_points_before', array('address' => $address));
// Update earning point for each items
$this->_updateEarningPoints($address);
Mage::dispatchEvent('rewardpoints_collect_earning_total_points_after', array('address' => $address));
return $this;
}
示例2: start
/**
* Reserve order ID for specified quote and start checkout on PayPal
* @return string
*/
public function start($returnUrl, $cancelUrl)
{
$this->_quote->reserveOrderId()->save();
// prepare API
$this->_getApi();
$this->_api->setAmount($this->_quote->getBaseGrandTotal())->setCurrencyCode($this->_quote->getBaseCurrencyCode())->setInvNum($this->_quote->getReservedOrderId())->setReturnUrl($returnUrl)->setCancelUrl($cancelUrl)->setSolutionType($this->_config->solutionType)->setPaymentAction($this->_config->paymentAction);
// supress or export shipping address
if ($this->_quote->getIsVirtual()) {
$this->_api->setSuppressShipping(true);
} else {
$address = $this->_quote->getShippingAddress();
$isOverriden = 0;
if (true === $address->validate()) {
$isOverriden = 1;
$this->_api->setAddress($address);
}
$this->_quote->getPayment()->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN, $isOverriden);
$this->_quote->getPayment()->save();
}
// add line items
if ($this->_config->lineItemsEnabled) {
list($items, $totals) = Mage::helper('paypal')->prepareLineItems($this->_quote);
$this->_api->setLineItems($items)->setLineItemTotals($totals);
}
$this->_config->exportExpressCheckoutStyleSettings($this->_api);
// call API and redirect with token
$this->_api->callSetExpressCheckout();
$token = $this->_api->getToken();
$this->_redirectUrl = $this->_config->getExpressCheckoutStartUrl($token);
return $token;
}
示例3: doTransaction
/**
* Call Transaction API (Authorized & Capture at the same time)
*
* @param Eway_Rapid31_Model_Response $response
* @return Eway_Rapid31_Model_Response
*/
public function doTransaction(Eway_Rapid31_Model_Response $response)
{
$this->unsetData();
$this->_buildRequest();
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
$items = $this->_quote->getAllVisibleItems();
$lineItems = array();
foreach ($items as $item) {
/* @var Mage_Sales_Model_Order_Item $item */
$lineItem = Mage::getModel('ewayrapid/field_lineItem');
$lineItem->setSKU($item->getSku());
$lineItem->setDescription(substr($item->getName(), 0, 26));
$lineItem->setQuantity($item->getQty());
$lineItem->setUnitCost(round($item->getBasePrice() * 100));
$lineItem->setTax(round($item->getBaseTaxAmount() * 100));
$lineItem->setTotal(round($item->getBaseRowTotalInclTax() * 100));
$lineItems[] = $lineItem;
}
$this->setItems($lineItems);
$this->setItems(false);
// add Payment
$amount = round($this->_quote->getBaseGrandTotal() * 100);
$paymentParam = Mage::getModel('ewayrapid/field_payment');
$paymentParam->setTotalAmount($amount);
$paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
$this->setPayment($paymentParam);
$customerParam = $this->getCustomer();
$customerParam->setTokenCustomerID($response->getTokenCustomerID());
$this->setCustomer($customerParam);
$response = $this->_doRapidAPI('Transaction');
return $response;
}
示例4: isCCAndZeroAmountAuthAllowed
/**
* check if payment method is cc and zero amount authorization is enabled
*
* @param Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod
*
* @return bool
*/
public function isCCAndZeroAmountAuthAllowed(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod, Mage_Sales_Model_Quote $quote)
{
$result = false;
$storeId = $quote->getStoreId();
if ($quote->getBaseGrandTotal() < 0.01 && $opsPaymentMethod instanceof Netresearch_OPS_Model_Payment_Cc && $opsPaymentMethod->isZeroAmountAuthorizationAllowed($storeId) && 0 < $quote->getItemsCount()) {
$result = true;
}
return $result;
}
示例5: testCollectTotalsWithVirtual
/**
* @magentoDataFixture Mage/Catalog/_files/product_virtual.php
* @magentoDataFixture Mage/Sales/_files/quote.php
*/
public function testCollectTotalsWithVirtual()
{
$quote = new Mage_Sales_Model_Quote();
$quote->load('test01', 'reserved_order_id');
$product = new Mage_Catalog_Model_Product();
$product->load(21);
$quote->addProduct($product);
$quote->collectTotals();
$this->assertEquals(2, $quote->getItemsQty());
$this->assertEquals(1, $quote->getVirtualItemsQty());
$this->assertEquals(20, $quote->getGrandTotal());
$this->assertEquals(20, $quote->getBaseGrandTotal());
}
示例6: start
/**
* Reserve order ID for specified quote and start checkout on PayPal
* @return string
*/
public function start($returnUrl, $cancelUrl)
{
$this->_quote->reserveOrderId()->save();
// prepare API
$this->_getApi();
$this->_api->setAmount($this->_quote->getBaseGrandTotal())->setCurrencyCode($this->_quote->getBaseCurrencyCode())->setInvNum($this->_quote->getReservedOrderId())->setReturnUrl($returnUrl)->setCancelUrl($cancelUrl)->setSolutionType($this->_config->solutionType)->setPaymentAction($this->_config->paymentAction);
if ($this->_giropayUrls) {
list($successUrl, $cancelUrl, $pendingUrl) = $this->_giropayUrls;
$this->_api->addData(array('giropay_cancel_url' => $cancelUrl, 'giropay_success_url' => $successUrl, 'giropay_bank_txn_pending_url' => $pendingUrl));
}
// supress or export shipping address
if ($this->_quote->getIsVirtual()) {
$this->_api->setSuppressShipping(true);
} else {
$address = $this->_quote->getShippingAddress();
$isOverriden = 0;
if (true === $address->validate()) {
$isOverriden = 1;
$this->_api->setAddress($address);
}
$this->_quote->getPayment()->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN, $isOverriden);
$this->_quote->getPayment()->save();
}
// add line items
if ($this->_config->lineItemsEnabled && Mage::helper('paypal')->doLineItemsMatchAmount($this->_quote, $this->_quote->getBaseGrandTotal())) {
//For transfering line items order amount must be equal to cart total amount
list($items, $totals) = Mage::helper('paypal')->prepareLineItems($this->_quote);
$this->_api->setLineItems($items)->setLineItemTotals($totals);
}
$this->_config->exportExpressCheckoutStyleSettings($this->_api);
// call API and redirect with token
$this->_api->callSetExpressCheckout();
$token = $this->_api->getToken();
$this->_redirectUrl = $this->_config->getExpressCheckoutStartUrl($token);
return $token;
}
示例7: _importPaymentData
/**
* Analyze payment data for quote and set free shipping if grand total is covered by balance
*
* @param Mage_Sales_Model_Quote $quote
* @param Varien_Object|Mage_Sales_Model_Quote_Payment $payment
* @param bool $shouldUseBalance
*/
protected function _importPaymentData($quote, $payment, $shouldUseBalance)
{
$store = Mage::app()->getStore($quote->getStoreId());
if (!$quote || !$quote->getCustomerId() || $quote->getBaseGrandTotal() + $quote->getBaseCustomerBalanceAmountUsed() <= 0) {
return;
}
$quote->setUseCustomerBalance($shouldUseBalance);
if ($shouldUseBalance) {
$balance = Mage::getModel('enterprise_customerbalance/balance')->setCustomerId($quote->getCustomerId())->setWebsiteId($store->getWebsiteId())->loadByCustomer();
if ($balance) {
$quote->setCustomerBalanceInstance($balance);
if (!$payment->getMethod()) {
$payment->setMethod('free');
}
} else {
$quote->setUseCustomerBalance(false);
}
}
}
示例8: isApplicableToQuote
/**
* Check whether payment method is applicable to quote
* Purposed to allow use in controllers some logic that was implemented in blocks only before
*
* @param Mage_Sales_Model_Quote $quote
* @param int|null $checksBitMask
* @return bool
*/
public function isApplicableToQuote($quote, $checksBitMask)
{
if ($checksBitMask & self::CHECK_USE_FOR_COUNTRY) {
if (!$this->canUseForCountry($quote->getBillingAddress()->getCountry())) {
return false;
}
}
if ($checksBitMask & self::CHECK_USE_FOR_CURRENCY) {
if (!$this->canUseForCurrency($quote->getStore()->getBaseCurrencyCode())) {
return false;
}
}
if ($checksBitMask & self::CHECK_USE_CHECKOUT) {
if (!$this->canUseCheckout()) {
return false;
}
}
if ($checksBitMask & self::CHECK_USE_FOR_MULTISHIPPING) {
if (!$this->canUseForMultishipping()) {
return false;
}
}
if ($checksBitMask & self::CHECK_USE_INTERNAL) {
if (!$this->canUseInternal()) {
return false;
}
}
if ($checksBitMask & self::CHECK_ORDER_TOTAL_MIN_MAX) {
$total = $quote->getBaseGrandTotal();
$minTotal = $this->getConfigData('min_order_total');
$maxTotal = $this->getConfigData('max_order_total');
if (!empty($minTotal) && $total < $minTotal || !empty($maxTotal) && $total > $maxTotal) {
return false;
}
}
if ($checksBitMask & self::CHECK_RECURRING_PROFILES) {
if (!$this->canManageRecurringProfiles() && $quote->hasRecurringItems()) {
return false;
}
}
if ($checksBitMask & self::CHECK_ZERO_TOTAL) {
$total = $quote->getBaseSubtotal() + $quote->getShippingAddress()->getBaseShippingAmount();
if ($total < 0.0001 && $this->getCode() != 'free' && !($this->canManageRecurringProfiles() && $quote->hasRecurringItems())) {
return false;
}
}
return true;
}
示例9: _fillCartInformation
/**
* @param array $data
* @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object
*/
private function _fillCartInformation(&$data, $object)
{
$productIids = array();
$productQtys = array();
$productStyleIds = array();
/** @var Mage_Sales_Model_Quote_Item|Mage_Sales_Model_Order_Item $item */
foreach ($object->getAllVisibleItems() as $item) {
$productIids[] = $item->getProduct()->getIid();
$productQtys[] = is_null($item->getQtyOrdered()) ? (int) $item->getQty() : (int) $item->getQtyOrdered();
$productStyleIds[] = $item->getProduct()->getNumber() . '-' . $item->getProduct()->getColorCode();
}
$data['productStyleId'] = implode(',', $productStyleIds);
$data['cartProductIds'] = implode(',', $productIids);
$data['cartProductQtys'] = implode(',', $productQtys);
$data['cartTotalNetto'] = round($object->getBaseSubtotal(), 2);
$data['cartTotalBrutto'] = round($object->getBaseGrandTotal(), 2);
$data['customerId'] = (int) $object->getCustomerId();
// For zanox tracking
if (array_key_exists('zanpid', $_COOKIE) && $_COOKIE['zanpid'] != '') {
$data['zanpid'] = $_COOKIE['zanpid'];
}
}
示例10: isAvailable
/**
* @param null|Mage_Sales_Model_Quote $quote
* @return bool
*/
public function isAvailable($quote = null)
{
if ($quote && $quote->getBaseGrandTotal() < $this->_minOrderTotal) {
return false;
}
return $this->getConfigData('secretapikey', $quote ? $quote->getStoreId() : null) && parent::isAvailable($quote);
}
示例11: cartOverLimit
/**
* Checks if the user's cart is under the limit set in
* the admin config, the option isn't set or the value
* of the option is set to ' ' or '0'.
*
* @param Mage_Sales_Model_Quote $quote Shopping cart quote
*/
protected function cartOverLimit($quote)
{
$_maxAmountSet = $this->getConfigData('max_amount');
$_maxAmountValue = $this->getConfigData('max_amount_value');
// If setting disabled:
if ($_maxAmountSet == 0) {
return false;
} else {
if ($_maxAmountSet == 1 && empty($_maxAmountValue)) {
// empty() is equivalent to !isset(var) || var == false
return false;
} else {
if ($quote->getBaseGrandTotal() < $_maxAmountValue) {
return false;
}
}
}
return true;
// Option enabled and cart over limit
}
示例12: createAccessCode
/**
* Get AccessCode
*
* @param Mage_Sales_Model_Quote $quote
* @return Eway_Rapid31_Model_Response
*/
public function createAccessCode(Mage_Sales_Model_Quote $quote, $method = 'ProcessPayment', $action = 'AccessCodes')
{
// Empty Varien_Object's data
$this->unsetData();
$billingAddress = $quote->getBillingAddress();
$customerParam = Mage::getModel('ewayrapid/field_customer');
$customerParam->setTitle($billingAddress->getPrefix() ? $billingAddress->getPrefix() : 'Mr')->setFirstName($billingAddress->getFirstname())->setLastName($billingAddress->getLastname())->setCompanyName($billingAddress->getCompany())->setJobDescription($billingAddress->getJobDescription())->setStreet1($billingAddress->getStreet1())->setStreet2($billingAddress->getStreet2())->setCity($billingAddress->getCity())->setState($billingAddress->getRegion())->setPostalCode($billingAddress->getPostcode())->setCountry(strtolower($billingAddress->getCountryModel()->getIso2Code()))->setEmail($billingAddress->getEmail())->setPhone($billingAddress->getTelephone())->setMobile($billingAddress->getMobile())->setComments('')->setFax($billingAddress->getFax())->setUrl('');
if ($this->getMethod() == Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD) {
$customerTokenId = Mage::getSingleton('core/session')->getSavedToken();
if (!$customerTokenId) {
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
} elseif (is_numeric($customerTokenId)) {
$customerHelper = Mage::helper('ewayrapid/customer');
$customerTokenId = $customerHelper->getCustomerTokenId($customerTokenId);
if ($customerTokenId) {
$customerParam->setTokenCustomerID($customerTokenId);
} else {
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
}
}
}
$this->setCustomer($customerParam);
$shippingAddress = $quote->getShippingAddress();
$shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
$shippingParam->setFirstName($shippingAddress->getFirstname())->setLastName($shippingAddress->getLastname())->setStreet1($shippingAddress->getStreet1())->setStreet2($shippingAddress->getStreet2())->setCity($shippingAddress->getCity())->setState($shippingAddress->getRegion())->setPostalCode($shippingAddress->getPostcode())->setCountry(strtolower($shippingAddress->getCountryModel()->getIso2Code()))->setEmail($shippingAddress->getEmail())->setPhone($shippingAddress->getTelephone())->setFax($shippingAddress->getFax());
$this->setShippingAddress($shippingParam);
$paymentParam = Mage::getModel('ewayrapid/field_payment');
$paymentParam->setTotalAmount(round($quote->getBaseGrandTotal() * 100));
if ($method == 'CreateTokenCustomer' || $method == 'UpdateTokenCustomer') {
$paymentParam->setTotalAmount(0);
}
$paymentParam->setCurrencyCode($quote->getBaseCurrencyCode());
$this->setPayment($paymentParam);
$returnUrl = Mage::getBaseUrl() . '/ewayrapid/transparent/callBack';
$cancelUrl = Mage::getBaseUrl() . '/ewayrapid/transparent/cancel';
$this->setRedirectUrl($returnUrl);
//CheckOutUrl if using PayPal
$checkOutUrl = Mage::getBaseUrl() . '/ewayrapid/transparent/review';
if (Mage::helper('ewayrapid/data')->getTransferCartLineItems()) {
// add Shipping item and Line items
$lineItems = Mage::helper('ewayrapid')->getLineItems();
$this->setItems($lineItems);
}
/*if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
$this->setItems(false);
}*/
if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD) {
$this->setCheckoutPayment(true);
$this->setCheckoutURL($checkOutUrl);
$this->setItems(false);
}
$this->setCancelUrl($cancelUrl);
$this->setMethod($method);
$this->setShippingMethod('Other');
$this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
$this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion());
if (Mage::helper('ewayrapid')->isBackendOrder()) {
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
} else {
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
}
$this->setCustomerReadOnly(true);
$response = $this->_doRapidAPI($action);
if ($response->isSuccess()) {
return $response;
} else {
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: %s)', $response->getMessage()));
}
}
示例13: _paymentDataImport
/**
* Prepare and set to quote reward balance instance,
* set zero subtotal checkout payment if need
*
* @param Mage_Sales_Model_Quote $quote
* @param Varien_Object $payment
* @param boolean $useRewardPoints
* @return Enterprise_Reward_Model_Observer
*/
protected function _paymentDataImport($quote, $payment, $useRewardPoints)
{
if (!$quote || !$quote->getCustomerId() || $quote->getBaseGrandTotal() + $quote->getBaseRewardCurrencyAmount() <= 0) {
return $this;
}
$quote->setUseRewardPoints((bool) $useRewardPoints);
if ($quote->getUseRewardPoints()) {
/* @var $reward Enterprise_Reward_Model_Reward */
$reward = Mage::getModel('enterprise_reward/reward')->setCustomer($quote->getCustomer())->setWebsiteId($quote->getStore()->getWebsiteId())->loadByCustomer();
$minPointsBalance = (int) Mage::getStoreConfig(Enterprise_Reward_Model_Reward::XML_PATH_MIN_POINTS_BALANCE, $quote->getStoreId());
if ($reward->getId() && $reward->getPointsBalance() >= $minPointsBalance) {
$quote->setRewardInstance($reward);
if (!$payment->getMethod()) {
$payment->setMethod('free');
}
} else {
$quote->setUseRewardPoints(false);
}
}
return $this;
}
示例14: isFullAmountCovered
/**
* Check whether balance completely covers specified quote
*
* @param Mage_Sales_Model_Quote $quote
* @return bool
*/
public function isFullAmountCovered(Mage_Sales_Model_Quote $quote, $isEstimation = false)
{
if (!$isEstimation && !$quote->getUseCustomerBalance()) {
return false;
}
return $this->getAmount() >= (double) $quote->getBaseGrandTotal() + (double) $quote->getBaseCustomerBalAmountUsed();
}
示例15: buildAmount
/**
* Build Amount
*
* @param Mage_Sales_Model_Quote $quote
* @return Amount
*/
protected function buildAmount($quote)
{
$details = new Details();
$details->setShipping($quote->getShippingAddress()->getBaseShippingAmount())->setTax($quote->getBillingAddress()->getBaseTaxAmount() + $quote->getBillingAddress()->getBaseHiddenTaxAmount() + $quote->getShippingAddress()->getBaseTaxAmount() + $quote->getShippingAddress()->getBaseHiddenTaxAmount())->setSubtotal($quote->getBaseSubtotal());
$totals = $quote->getTotals();
if (isset($totals['discount']) && $totals['discount']->getValue()) {
$details->setShippingDiscount(-$totals['discount']->getValue());
}
$amount = new Amount();
$amount->setCurrency($quote->getBaseCurrencyCode())->setDetails($details)->setTotal($quote->getBaseGrandTotal());
return $amount;
}