예제 #1
1
 private function initializeQuoteItems()
 {
     foreach ($this->proxyOrder->getItems() as $item) {
         $this->clearQuoteItemsCache();
         /** @var $quoteItemBuilder Ess_M2ePro_Model_Magento_Quote_Item */
         $quoteItemBuilder = Mage::getModel('M2ePro/Magento_Quote_Item');
         $quoteItemBuilder->init($this->quote, $item);
         $product = $quoteItemBuilder->getProduct();
         $request = $quoteItemBuilder->getRequest();
         // ----------------------------
         $productOriginalPrice = (double) $product->getPrice();
         $price = $item->getBasePrice();
         $product->setPrice($price);
         $product->setSpecialPrice($price);
         // ----------------------------
         // see Mage_Sales_Model_Observer::substractQtyFromQuotes
         $this->quote->setItemsCount($this->quote->getItemsCount() + 1);
         $this->quote->setItemsQty((double) $this->quote->getItemsQty() + $request->getQty());
         $result = $this->quote->addProduct($product, $request);
         if (is_string($result)) {
             throw new Exception($result);
         }
         $quoteItem = $this->quote->getItemByProduct($product);
         if ($quoteItem !== false) {
             $weight = $product->getTypeInstance()->getWeight();
             if ($product->isConfigurable()) {
                 // hack: for child product weight was not load
                 $simpleProductId = $product->getCustomOption('simple_product')->getProductId();
                 $weight = Mage::getResourceModel('catalog/product')->getAttributeRawValue($simpleProductId, 'weight', 0);
             }
             $quoteItem->setStoreId($this->quote->getStoreId());
             $quoteItem->setOriginalCustomPrice($item->getPrice());
             $quoteItem->setOriginalPrice($productOriginalPrice);
             $quoteItem->setBaseOriginalPrice($productOriginalPrice);
             $quoteItem->setWeight($weight);
             $quoteItem->setNoDiscount(1);
             $giftMessageId = $quoteItemBuilder->getGiftMessageId();
             if (!empty($giftMessageId)) {
                 $quoteItem->setGiftMessageId($giftMessageId);
             }
             $quoteItem->setAdditionalData($quoteItemBuilder->getAdditionalData($quoteItem));
         }
     }
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 private function getAssociatedGroupedProduct()
 {
     $associatedProducts = $this->proxyItem->getAssociatedProducts();
     $associatedProductId = reset($associatedProducts);
     $product = Mage::getModel('catalog/product')->setStoreId($this->quote->getStoreId())->load($associatedProductId);
     return $product->getId() ? $product : null;
 }
예제 #4
0
 /**
  * Convert the resource model collection to an array
  *
  * @param Mage_Sales_Model_Quote $quote
  *
  * @return array
  */
 public function prepareCollection(Mage_Sales_Model_Quote $quote)
 {
     // Store current state
     $actionType = $this->getActionType();
     $operation = $this->getOperation();
     // Change state
     $this->setActionType(self::ACTION_TYPE_COLLECTION);
     $this->setOperation(self::OPERATION_RETRIEVE);
     $data = [];
     // Get store
     $store = $quote->getStoreId();
     // Get filter
     $filter = $this->getFilter();
     // Prepare methods
     foreach (Mage::helper('payment')->getStoreMethods($store, $quote) as $method) {
         /** @var $method Mage_Payment_Model_Method_Abstract */
         if ($this->_canUseMethod($method, $quote) && $method->isApplicableToQuote($quote, Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL)) {
             $method->setInfoInstance($quote->getPayment());
             $data[] = $this->prepareMethod($method, $filter);
         }
     }
     // Restore old state
     $this->setActionType($actionType);
     $this->setOperation($operation);
     // Return prepared outbound data
     return $data;
 }
예제 #5
0
 /**
  * Validates alias for in quote provided addresses
  * @param Mage_Sales_Model_Quote $quote
  * @param Varien_Object $payment
  * @throws Mage_Core_Exception
  */
 protected function validateAlias($quote, $payment)
 {
     $alias = $payment->getAdditionalInformation('alias');
     if (0 < strlen(trim($alias)) && is_numeric($payment->getAdditionalInformation('cvc')) && false === Mage::helper('ops/alias')->isAliasValidForAddresses($quote->getCustomerId(), $alias, $quote->getBillingAddress(), $quote->getShippingAddress(), $quote->getStoreId())) {
         $this->getOnepage()->getCheckout()->setGotoSection('payment');
         Mage::throwException($this->getHelper()->__('Invalid payment information provided!'));
     }
 }
예제 #6
0
 /**
  * Checkout with PayPal image URL getter
  * @return string
  */
 public function getCheckoutShortcutImageUrl()
 {
     $localUrl = $this->getHelperConfig()->getConfigGeneral($this->_quote->getStoreId())->getPaymentPaypalExpressCheckout()->getPaypalExpressCheckoutImage();
     if ($localUrl) {
         return Mage::getBaseUrl('media') . 'payone' . DS . $localUrl;
     }
     return sprintf('https://www.paypal.com/%s/i/btn/btn_xpressCheckout.gif', $this->_getSupportedLocaleCode(Mage::app()->getLocale()->getLocaleCode()));
 }
예제 #7
0
 /**
  * returns the quote currency
  *
  * @param $quote
  *
  * @return string - the quotes currency
  */
 public function getQuoteCurrency(Mage_Sales_Model_Quote $quote)
 {
     if ($quote->hasForcedCurrency()) {
         return $quote->getForcedCurrency()->getCode();
     } else {
         return Mage::app()->getStore($quote->getStoreId())->getBaseCurrencyCode();
     }
 }
예제 #8
0
 /**
  * @api
  *
  * To be used in Form_Block, which has to display all wallet types
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return Payone_Core_Model_Config_Payment_Method_Interface
  */
 public function getAllConfigsByQuote(Mage_Sales_Model_Quote $quote)
 {
     if (empty($this->matchingConfigs)) {
         $configStore = $this->getConfigStore($quote->getStoreId());
         $this->matchingConfigs = $configStore->getPayment()->getMethodsForQuote($this->methodType, $quote);
     }
     return $this->matchingConfigs;
 }
예제 #9
0
 /**
  * extraxcts the according Barclaycard owner* parameter
  *
  * @param Mage_Sales_Model_Quote               $quote
  * @param Mage_Customer_Model_Address_Abstract $billingAddress
  *
  * @return array
  */
 public function getOwnerParams(Mage_Sales_Model_Quote $quote, Mage_Customer_Model_Address_Abstract $billingAddress)
 {
     $ownerParams = array();
     if ($this->getConfig()->canSubmitExtraParameter($quote->getStoreId())) {
         $ownerParams = array('OWNERADDRESS' => str_replace("\n", ' ', $billingAddress->getStreet(1)), 'OWNERTOWN' => $billingAddress->getCity(), 'OWNERZIP' => $billingAddress->getPostcode(), 'OWNERTELNO' => $billingAddress->getTelephone(), 'OWNERCTY' => $billingAddress->getCountry(), 'ECOM_BILLTO_POSTAL_POSTALCODE' => $billingAddress->getPostcode());
     }
     return $ownerParams;
 }
예제 #10
0
 /**
  * @param Mage_Sales_Model_Quote|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     $isAvailable = parent::isAvailable();
     $disableZeroTotal = Mage::getStoreConfig('payment/adyen_hpp/disable_zero_total', $quote->getStoreId());
     if (!is_null($quote) && $quote->getGrandTotal() <= 0 && $disableZeroTotal) {
         return false;
     }
     return $isAvailable;
 }
예제 #11
0
 /**
  * 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;
 }
예제 #12
0
 /**
  * Convert quote model to order model
  *
  * @param   Mage_Sales_Model_Quote $quote
  * @return  Mage_Sales_Model_Order
  */
 public function toOrder(Mage_Sales_Model_Quote $quote, $order = null)
 {
     if (!$order instanceof Mage_Sales_Model_Order) {
         $order = Mage::getModel('sales/order');
     }
     /* @var $order Mage_Sales_Model_Order */
     $order->setStoreId($quote->getStoreId())->setQuoteId($quote->getId())->setRemoteIp($quote->getRemoteIp())->setCustomerId($quote->getCustomerId())->setCustomerEmail($quote->getCustomerEmail())->setCustomerFirstname($quote->getCustomerFirstname())->setCustomerLastname($quote->getCustomerLastname())->setCustomerGroupId($quote->getCustomerGroupId())->setCustomerTaxClassId($quote->getCustomerTaxClassId())->setCustomerNote($quote->getCustomerNote())->setCustomerNoteNotify($quote->getCustomerNoteNotify())->setCustomerIsGuest($quote->getCustomerIsGuest())->setBaseCurrencyCode($quote->getBaseCurrencyCode())->setStoreCurrencyCode($quote->getStoreCurrencyCode())->setOrderCurrencyCode($quote->getQuoteCurrencyCode())->setStoreToBaseRate($quote->getStoreToBaseRate())->setStoreToOrderRate($quote->getStoreToQuoteRate())->setCouponCode($quote->getCouponCode())->setGiftcertCode($quote->getGiftcertCode())->setIsVirtual($quote->getIsVirtual())->setIsMultiPayment($quote->getIsMultiPayment())->setAppliedRuleIds($quote->getAppliedRuleIds());
     Mage::dispatchEvent('sales_convert_quote_to_order', array('order' => $order, 'quote' => $quote));
     return $order;
 }
예제 #13
0
 /**
  * Convert quote model to order model
  *
  * @param   Mage_Sales_Model_Quote $quote
  * @return  Mage_Sales_Model_Order
  */
 public function toOrder(Mage_Sales_Model_Quote $quote, $order = null)
 {
     if (!$order instanceof Mage_Sales_Model_Order) {
         $order = Mage::getModel('sales/order');
     }
     /* @var $order Mage_Sales_Model_Order */
     $order->setIncrementId($quote->getReservedOrderId())->setStoreId($quote->getStoreId())->setQuoteId($quote->getId())->setCustomer($quote->getCustomer());
     Mage::helper('core')->copyFieldset('sales_convert_quote', 'to_order', $quote, $order);
     Mage::dispatchEvent('sales_convert_quote_to_order', array('order' => $order, 'quote' => $quote));
     return $order;
 }
예제 #14
0
파일: Mep.php 프로젝트: cewolf2002/magento
 /**
  * Check whether payment method can be used
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     $storeId = false;
     $model = Mage::registry('current_app');
     if ($model instanceof Mage_XmlConnect_Model_Application) {
         $storeId = $model->getStoreId();
     }
     if (!$storeId) {
         $storeId = $quote ? $quote->getStoreId() : Mage::app()->getStore()->getId();
     }
     return (bool) Mage::getModel('paypal/config')->setStoreId($storeId)->isMethodAvailable(Mage_Paypal_Model_Config::METHOD_WPP_EXPRESS);
 }
예제 #15
0
 /**
  * Convert quote model to order model
  *
  * @param   Mage_Sales_Model_Quote $quote
  * @return  Mage_Sales_Model_Order
  */
 public function toOrder(Mage_Sales_Model_Quote $quote, $order = null)
 {
     if (!$order instanceof Mage_Sales_Model_Order) {
         $order = Mage::getModel('sales/order');
     }
     /* @var $order Mage_Sales_Model_Order */
     $order->setIncrementId($quote->getReservedOrderId())->setStoreId($quote->getStoreId())->setQuoteId($quote->getId());
     Mage::helper('core')->copyFieldset('sales_convert_quote', 'to_order', $quote, $order);
     if (!$quote->getCustomerId()) {
         $order->setCustomerId(null);
     }
     //
     //            ->setRemoteIp($quote->getRemoteIp())
     //
     //            /**
     //             * Customer data
     //             */
     //            ->setCustomerId($quote->getCustomerId())
     //            ->setCustomerEmail($quote->getCustomerEmail())
     //            ->setCustomerPrefix($quote->getCustomerPrefix())
     //            ->setCustomerFirstname($quote->getCustomerFirstname())
     //            ->setCustomerMiddlename($quote->getCustomerMiddlename())
     //            ->setCustomerLastname($quote->getCustomerLastname())
     //            ->setCustomerSuffix($quote->getCustomerSuffix())
     //            ->setCustomerGroupId($quote->getCustomerGroupId())
     //            ->setCustomerTaxClassId($quote->getCustomerTaxClassId())
     //            ->setCustomerNote($quote->getCustomerNote())
     //            ->setCustomerNoteNotify($quote->getCustomerNoteNotify())
     //            ->setCustomerIsGuest($quote->getCustomerIsGuest())
     //            ->setCustomerDob($quote->getCustomerDob())
     //
     //            /**
     //             * Currency data
     //             */
     //            ->setBaseCurrencyCode($quote->getBaseCurrencyCode())
     //            ->setStoreCurrencyCode($quote->getStoreCurrencyCode())
     //            ->setOrderCurrencyCode($quote->getQuoteCurrencyCode())
     //            ->setStoreToBaseRate($quote->getStoreToBaseRate())
     //            ->setStoreToOrderRate($quote->getStoreToQuoteRate())
     //
     //            /**
     //             * Another data
     //             */
     //            ->setCouponCode($quote->getCouponCode())
     //            ->setGiftcertCode($quote->getGiftcertCode())
     //            ->setIsVirtual($quote->getIsVirtual())
     //            ->setIsMultiPayment($quote->getIsMultiPayment())
     //            ->setAppliedRuleIds($quote->getAppliedRuleIds());
     Mage::dispatchEvent('sales_convert_quote_to_order', array('order' => $order, 'quote' => $quote));
     return $order;
 }
예제 #16
0
 public function isGuestCheckoutAllowed(Mage_Sales_Model_Quote $quote, $store = null)
 {
     if ($store === null) {
         $store = $quote->getStoreId();
     }
     $guestCheckout = Mage::getStoreConfig('onepagecheckout/general/guest_checkout', $store);
     if ($guestCheckout == true) {
         $result = new Varien_Object();
         $result->setIsAllowed($guestCheckout);
         Mage::dispatchEvent('checkout_allow_guest', array('quote' => $quote, 'store' => $store, 'result' => $result));
         $guestCheckout = $result->getIsAllowed();
     }
     return $guestCheckout;
 }
예제 #17
0
 /**
  * Check whether payment method can be used
  *
  * TODO: payment method instance is not supposed to know about quote
  *
  * @param Mage_Sales_Model_Quote|null $quote
  *
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     $checkResult = new StdClass();
     $isActive = (bool) (int) $this->getConfigData('active', $quote ? $quote->getStoreId() : null);
     $shippingMethodRaw = $quote->getShippingAddress()->getShippingMethod();
     $product = $this->_getHelper()->getDPDServiceCode($shippingMethodRaw);
     if (!$isActive || !$quote || !$this->_getHelper()->isShippingMethodDpd($shippingMethodRaw) || !in_array($product, explode(',', $this->getConfigData('specificproducto', $quote->getStoreId()))) || is_null($this->getSurchage())) {
         $isActive = false;
     }
     $checkResult->isAvailable = $isActive;
     $checkResult->isDeniedInConfig = !$isActive;
     // for future use in observers
     Mage::dispatchEvent('payment_method_is_active', array('result' => $checkResult, 'method_instance' => $this, 'quote' => $quote));
     // disable method if it cannot implement recurring profiles management and there are recurring items in quote
     if ($checkResult->isAvailable) {
         $implementsRecurring = $this->canManageRecurringProfiles();
         // the $quote->hasRecurringItems() causes big performance impact, thus it has to be called last
         if ($quote && !$implementsRecurring && $quote->hasRecurringItems()) {
             $checkResult->isAvailable = false;
         }
     }
     return $checkResult->isAvailable;
 }
예제 #18
0
 /**
  * Restore
  *
  * @param $quote  Mage_Sales_Model_Quote
  * @param $status string
  * @return bool
  */
 public function restoreCart(Mage_Sales_Model_Quote $quote, $status)
 {
     $storeId = $quote->getStoreId();
     $gatewayMethod = $quote->getPayment()->getMethod();
     $needRestore = false;
     $statuses = array('canceled', 'expired', 'declined', 'void');
     if (Mage::getStoreConfig('payment/msp/keep_cart', $storeId) || Mage::getStoreConfig('msp/settings/keep_cart', $storeId) || $gatewayMethod == 'msp_payafter') {
         $needRestore = true;
     }
     if ($needRestore && in_array($status, $statuses)) {
         $quote->setIsActive(true)->setReservedOrderId(null)->save();
         return true;
     }
     return false;
 }
 /**
  * Add custom methods
  *
  * @param Mage_Sales_Model_Quote $quote
  */
 public function addCustomMethods(Mage_Sales_Model_Quote $quote)
 {
     /** @var MatheusGontijo_EasyShippingRules_Model_Custommethod $methods */
     //var_dump($quote);
     $storeId = $quote->getStoreId();
     $methods = Mage::getModel('easyshippingrules/custommethod')->getCollection()->prepareAvailableMethods($storeId);
     $address = $quote->getShippingAddress();
     if (!$this->_isDefaultRuleValid($address)) {
         return;
     }
     foreach ($methods as $method) {
         foreach ($method->getRules() as $rule) {
             if ($rule->validate($address)) {
                 $this->_rates[] = $this->createRate($method, $rule);
             }
         }
     }
 }
예제 #20
0
 /**
  * Get customer balance model using sales entity
  *
  * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $salesEntity
  *
  * @return Enterprise_CustomerBalance_Model_Balance|bool
  */
 public function getCustomerBalanceModelFromSalesEntity($salesEntity)
 {
     if ($salesEntity instanceof Mage_Sales_Model_Order) {
         $customerId = $salesEntity->getCustomerId();
         $quote = $salesEntity->getQuote();
     } elseif ($salesEntity instanceof Mage_Sales_Model_Quote) {
         $customerId = $salesEntity->getCustomer()->getId();
         $quote = $salesEntity;
     } else {
         return false;
     }
     if (!$customerId) {
         return false;
     }
     $customerBalanceModel = Mage::getModel('enterprise_customerbalance/balance')->setCustomerId($customerId)->setWebsiteId(Mage::app()->getStore($salesEntity->getStoreId())->getWebsiteId())->loadByCustomer();
     if ($quote->getBaseCustomerBalanceVirtualAmount() > 0) {
         $customerBalanceModel->setAmount($customerBalanceModel->getAmount() + $quote->getBaseCustomerBalanceVirtualAmount());
     }
     return $customerBalanceModel;
 }
 /**
  * @api
  *
  * To be used in Form_Block, which has to display all types
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return Payone_Core_Model_Config_Payment_Method_Interface
  */
 public function getAllConfigsByQuote(Mage_Sales_Model_Quote $quote)
 {
     if (empty($this->matchingConfigs)) {
         $configStore = $this->getConfigStore($quote->getStoreId());
         $this->matchingConfigs = $configStore->getPayment()->getMethodsForQuote($this->methodType, $quote);
     }
     if (!$this->isAllowedBillSafe($quote)) {
         // Special handling for BillSAFE, virtual quotes are not allowed
         foreach ($this->matchingConfigs as $configKey => $config) {
             /** @var $config Payone_Core_Model_Config_Payment_Method_Interface */
             $types = $config->getTypes();
             foreach ($types as $key => $type) {
                 // Remove BSV
                 if ($type === Payone_Api_Enum_FinancingType::BSV) {
                     unset($types[$key]);
                 }
             }
             if (count($types) === 0) {
                 unset($this->matchingConfigs[$configKey]);
             }
         }
     }
     return $this->matchingConfigs;
 }
예제 #22
0
파일: Cc.php 프로젝트: AleksNesh/pandora
 /**
  * Check whether there are CC types set in configuration
  *
  * @param Mage_Sales_Model_Quote|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     return $this->getConfigData('cctypes', $quote ? $quote->getStoreId() : null) && parent::isAvailable($quote);
 }
예제 #23
0
 /**
  * Retrieve store Id (From Quote)
  *
  * @return int
  */
 public function getStoreId()
 {
     return (int) $this->_quote->getStoreId();
 }
예제 #24
0
 /**
  * Get Tax Class for Shipping option
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return mixed
  */
 protected function _getTaxClassForShipping($quote)
 {
     return Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS, $quote->getStoreId());
 }
예제 #25
0
 public function setAliasToActiveAfterUserRegisters(Mage_Sales_Model_Order $order, Mage_Sales_Model_Quote $quote)
 {
     if (true === $quote->getPayment()->getAdditionalInformation('userIsRegistering')) {
         $customerId = $order->getCustomerId();
         $billingAddressHash = $this->generateAddressHash($quote->getBillingAddress());
         $shippingAddressHash = $this->generateAddressHash($quote->getShippingAddress());
         $aliasId = $quote->getPayment()->getAdditionalInformation('opsAliasId');
         if (is_numeric($aliasId) && 0 < $aliasId) {
             $alias = Mage::getModel('ops/alias')->getCollection()->addFieldToFilter('alias', $quote->getPayment()->getAdditionalInformation('alias'))->addFieldToFilter('billing_address_hash', $billingAddressHash)->addFieldToFilter('shipping_address_hash', $shippingAddressHash)->addFieldToFilter('store_id', array('eq' => $quote->getStoreId()))->getFirstItem();
             if ($alias->getState() === Netresearch_OPS_Model_Alias_State::PENDING) {
                 $alias->setState(Netresearch_OPS_Model_Alias_State::ACTIVE);
                 $alias->setCustomerId($customerId);
                 $alias->save();
             }
         }
     }
 }
예제 #26
0
 /**
  * send tracking information for a shopping basket
  * 
  * @param Mage_Sales_Model_Quote $quote 
  */
 protected function ecommerceCartUpdate($quote)
 {
     $piwikTracker = $this->_initPiwikTracker($quote->getStoreId());
     if ($piwikTracker->getVisitorId()) {
         $piwikTracker->setIp($quote->getRemoteIp());
         $piwikTracker->setCustomVariable(1, 'U', Fooman_Jirafe_Block_Js::VISITOR_READY2BUY);
         $this->_addEcommerceItems($piwikTracker, $quote);
         $piwikTracker->doTrackEcommerceCartUpdate($quote->getBaseGrandTotal());
     }
 }
 /**
  * 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);
         }
     }
 }
예제 #28
0
 /**
  * Check whether payment method can be used
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return boolean
  */
 public function isAvailable($quote = null)
 {
     return Mage::helper('enterprise_pbridge')->isEnabled($quote ? $quote->getStoreId() : null) && Mage_Payment_Model_Method_Abstract::isAvailable($quote);
 }
예제 #29
0
 /**
  * Sets the customer info if available
  *
  * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object
  * @return $this
  */
 protected function _addCustomer($object)
 {
     $format = Mage::getStoreConfig('tax/avatax/cust_code_format', $object->getStoreId());
     $customer = Mage::getModel('customer/customer');
     if ($object->getCustomerId()) {
         $customer->load($object->getCustomerId());
         $taxClass = Mage::getModel('tax/class')->load($customer->getTaxClassId())->getOpAvataxCode();
         $this->_request->setCustomerUsageType($taxClass);
     }
     switch ($format) {
         case OnePica_AvaTax_Model_Source_Customercodeformat::LEGACY:
             if ($customer->getId()) {
                 $customerCode = $customer->getName() . ' (' . $customer->getId() . ')';
             } else {
                 $address = $object->getBillingAddress() ? $object->getBillingAddress() : $object;
                 $customerCode = $address->getFirstname() . ' ' . $address->getLastname() . ' (Guest)';
             }
             break;
         case OnePica_AvaTax_Model_Source_Customercodeformat::CUST_EMAIL:
             $customerCode = $object->getCustomerEmail() ? $object->getCustomerEmail() : $customer->getEmail();
             break;
         case OnePica_AvaTax_Model_Source_Customercodeformat::CUST_ID:
         default:
             $customerCode = $object->getCustomerId() ? $object->getCustomerId() : 'guest-' . $object->getId();
             break;
     }
     $this->_request->setCustomerCode($customerCode);
     return $this;
 }
예제 #30
0
 /**
  * Get reserved order id
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return string
  */
 public function getReservedOrderId($quote)
 {
     $storeId = (int) $quote->getStoreId();
     return Mage::getSingleton('eav/config')->getEntityType(Mage_Sales_Model_Order::ENTITY)->fetchNewIncrementId($storeId);
 }