コード例 #1
0
ファイル: Interest.php プロジェクト: rorteg/rafaelmage
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     if ($address->getQuote()->isVirtual()) {
         if ($address->getData('address_type') == 'shipping') {
             return $this;
         }
     } else {
         if ($address->getData('address_type') == 'billing') {
             return $this;
         }
     }
     $this->_setAddress($address);
     parent::collect($address);
     $quote = $address->getQuote();
     $amount = $quote->getMundipaggInterest();
     if ($amount > 0) {
         $this->_setBaseAmount(0.0);
         $this->_setAmount(0.0);
         $quote->getPayment()->setPaymentInterest($amount);
         $address->setMundipaggInterest($amount);
         $this->_setBaseAmount($amount);
         $this->_setAmount($amount);
     } else {
         $this->_setBaseAmount(0.0);
         $this->_setAmount(0.0);
         $quote->getPayment()->setPaymentInterest(0.0);
         $address->setMundipaggInterest(0.0);
     }
     return $this;
 }
コード例 #2
0
 /**
  * Set correct values on subscription address based on given subscription and order address
  *
  * @param Adyen_Subscription_Model_Subscription $subscription
  * @param Mage_Sales_Model_Order_Address|Mage_Sales_Model_Quote_Address $address
  * @return $this
  */
 public function initAddress(Adyen_Subscription_Model_Subscription $subscription, $address)
 {
     $this->setSubscriptionId($subscription->getId());
     // Reset (possible) original values
     $this->setOrderAddressId(null)->setCustomerAddressId(null)->setQuoteAddressId(null);
     if ($address->getAddressType() == Mage_Sales_Model_Order_Address::TYPE_BILLING) {
         $this->setType(self::ADDRESS_TYPE_BILLING);
     } else {
         $this->setType(self::ADDRESS_TYPE_SHIPPING);
     }
     // Note: Only use customer address if 'save_in_address_book' or 'same_as_billing'
     // is also checked at the address, because it's not enough to rely solely on the
     // customer address ID, because an address can be changed when creating an order
     // in the backend, but this ID still remains when a quote is converted to an order
     if ($address->getCustomerAddressId() && $address->getData('save_in_address_book')) {
         // Create customer address
         $this->setSource(self::ADDRESS_SOURCE_CUSTOMER)->setCustomerAddressId($address->getCustomerAddressId());
     } elseif ($address instanceof Mage_Sales_Model_Quote_Address) {
         // Create quote address
         $this->setSource(self::ADDRESS_SOURCE_QUOTE)->setQuoteAddressId($address->getId());
     } else {
         // Create order address
         $this->setSource(self::ADDRESS_SOURCE_ORDER)->setOrderAddressId($address->getId());
     }
     return $this;
 }
コード例 #3
0
ファイル: Points.php プロジェクト: HPTTeam/hackathon
 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;
 }
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     if ($address->getData('address_type') == 'billing') {
         return $this;
     }
     $amount = (double) $address->getStoreCreditDiscount();
     if ($amount > 0) {
         $address->addTotal(array('code' => $this->getCode(), 'title' => 'Store Credit Discount (' . $amount . ' credit used)', 'value' => '-' . $amount));
     }
     return $address;
 }
コード例 #5
0
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     if ($address->getData('address_type') == 'billing') {
         return $this;
     }
     $discount = $address->getGiftcardDiscount();
     $gcCode = Mage::getSingleton('core/session')->getGiftcardCode();
     if ($discount > 0) {
         $address->addTotal(array('code' => $this->getCode(), 'title' => Mage::helper('sales')->__('Gift Card (' . $gcCode . ')'), 'value' => -$discount));
     }
 }
コード例 #6
0
ファイル: Point.php プロジェクト: AmineCherrai/rostanvo
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $quote = $address->getQuote();
     $session = Mage::getSingleton('checkout/session');
     $customer = Mage::getSingleton('customer/session')->getCustomer();
     $params = Mage::app()->getRequest()->getParam('payment');
     if ($params['use_point'] != null || $params['point_amount'] != null) {
         $session->setData('use_point', $params['use_point'])->setData('point_amount', $params['point_amount']);
     }
     if ($session->getData('use_point') && $address->getBaseGrandTotal() && $customer->getId()) {
         $pointAmount = $session->getData('point_amount');
         $rate = Mage::getModel('customerreward/rate')->getPointToMoneyRate($customer->getWebsiteId(), $customer->getGroupId());
         $moneyBase = $pointAmount * $rate;
         $currentMoney = Mage::app()->getStore()->convertPrice($moneyBase);
         $baseSubtotalWithDiscount = $address->getData('base_subtotal') + $address->getData('base_discount_amount');
         $subtotalWithDiscount = $address->getData('subtotal') + $address->getData('discount_amount');
         if ($moneyBase < $baseSubtotalWithDiscount) {
             $address->setBaseGrandTotal($address->getBaseGrandTotal() - $moneyBase);
             $address->setGrandTotal($address->getGrandTotal() - $currentMoney);
             $address->setMoneyBase($moneyBase);
             $address->setCurrentMoney($currentMoney);
             $quote->setMoneyBase($moneyBase);
             $quote->setCurrentMoney($currentMoney);
         } else {
             $pointUsed = ceil($baseSubtotalWithDiscount / $rate);
             $moneyBaseUsed = $pointUsed * $rate;
             $currentMoneyUsed = Mage::app()->getStore()->convertPrice($moneyBaseUsed);
             $session->setData('point_amount', $pointUsed);
             $address->setBaseGrandTotal($address->getBaseGrandTotal() - $baseSubtotalWithDiscount);
             $address->setGrandTotal($address->getGrandTotal() - $subtotalWithDiscount);
             $address->setMoneyBase($moneyBaseUsed);
             $address->setCurrentMoney($currentMoneyUsed);
             $quote->setMoneyBase($moneyBaseUsed);
             $quote->setCurrentMoney($currentMoneyUsed);
         }
     }
     return $this;
 }
コード例 #7
0
ファイル: Onestep.php プロジェクト: jpedro21/comerciodoboi
 /**
  * Validate customer data and set some its data for further usage in quote
  * Will return either true or array with error messages
  *
  * @param Mage_Sales_Model_Quote_Address $address
  * @return true|array
  */
 protected function _processValidateCustomer(Mage_Sales_Model_Quote_Address $address)
 {
     // set customer date of birth for further usage
     $dob = '';
     if ($address->getDob()) {
         $dob = Mage::app()->getLocale()->date($address->getDob(), null, null, false)->toString('yyyy-MM-dd');
         $this->getQuote()->setCustomerDob($dob);
     }
     // set customer tax/vat number for further usage
     if ($address->getTaxvat()) {
         $this->getQuote()->setCustomerTaxvat($address->getTaxvat());
     }
     /* ADD RG E TIPO  */
     if ($address->getTipo()) {
         $this->getQuote()->setCustomerTipo($address->getTipo());
     }
     if ($address->getRg()) {
         $this->getQuote()->setCustomerRg($address->getRg());
     }
     /* ADD RG E TIPO  */
     // set customer gender for further usage
     if ($address->getGender()) {
         $this->getQuote()->setCustomerGender($address->getGender());
     }
     // invoke customer model, if it is registering
     if (self::METHOD_REGISTER == $this->getQuote()->getCheckoutMethod()) {
         // set customer password hash for further usage
         $customer = Mage::getModel('customer/customer');
         $this->getQuote()->setPasswordHash($customer->encryptPassword($address->getCustomerPassword()));
         // validate customer
         foreach (array('firstname' => 'firstname', 'lastname' => 'lastname', 'email' => 'email', 'password' => 'customer_password', 'confirmation' => 'confirm_password', 'taxvat' => 'taxvat', 'gender' => 'gender', 'rg' => 'rg', 'tipo' => 'tipo') as $key => $dataKey) {
             $customer->setData($key, $address->getData($dataKey));
         }
         if ($dob) {
             $customer->setDob($dob);
         }
         $validationResult = $customer->validate();
         if (true !== $validationResult && is_array($validationResult)) {
             return array('error' => -1, 'message' => implode(', ', $validationResult));
         }
     } elseif (self::METHOD_GUEST == $this->getQuote()->getCheckoutMethod()) {
         $email = $address->getData('email');
         if (!Zend_Validate::is($email, 'EmailAddress')) {
             return array('error' => -1, 'message' => $this->_helper->__('Invalid email address "%s"', $email));
         }
     }
     return true;
 }
コード例 #8
0
ファイル: Discount.php プロジェクト: aoepeople/aoe_salesrule
 protected function resetAddress(Mage_Sales_Model_Quote_Address $address)
 {
     $address->setDiscountAmount(0.0);
     $address->setBaseDiscountAmount(0.0);
     $address->setSubtotalWithDiscount($address->getSubtotal());
     $address->setBaseSubtotalWithDiscount($address->getBaseSubtotal());
     $address->setDiscountDescription('');
     $address->setDiscountDescriptionArray([]);
     if (!$address->getData('__applied_rules_reset__')) {
         $address->setAppliedRuleIds('');
         $address->setData('__applied_rules_reset__', true);
     }
     $address->setShippingDiscountAmount(0);
     $address->setBaseShippingDiscountAmount(0);
     $address->setFreeShipping(false);
 }
コード例 #9
0
ファイル: Interest.php プロジェクト: AZPay/Magento-Azpay
 /**
  * Used each time when collectTotals is invoked
  *
  * @param Mage_Sales_Model_Quote_Address $address
  * @return Your_Module_Model_Total_Custom
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     if ($address->getData('address_type') == 'billing') {
         return $this;
     }
     $this->_setAddress($address);
     if ($ammount = $address->getQuote()->getInterest()) {
         $this->_setBaseAmount($ammount);
         $this->_setAmount($address->getQuote()->getStore()->convertPrice($ammount, false));
         $address->setInterest($ammount);
     } else {
         $this->_setBaseAmount(0.0);
         $this->_setAmount(0.0);
     }
     return $this;
 }
コード例 #10
0
ファイル: Discount.php プロジェクト: protechhelp/gamamba
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     $quote = $address->getQuote();
     if (!Mage::getStoreConfig('tax/calculation/apply_after_discount', $quote->getStoreId())) {
         return $this;
     }
     if (!$quote->isVirtual() && $address->getData('address_type') == 'billing') {
         return $this;
     }
     $session = Mage::getSingleton('checkout/session');
     $customer_credit_discount = $address->getCustomercreditDiscount();
     if ($session->getBaseCustomerCreditAmount()) {
         $customer_credit_discount = $session->getBaseCustomerCreditAmount();
     }
     //  zend_debug::Dump($session->getBaseCustomerCreditAmount());die();
     if (!$session->getHasCustomerCreditItem()) {
         if ($customer_credit_discount > 0) {
             $address->addTotal(array('code' => $this->getCode(), 'title' => Mage::helper('customercredit')->__('Customer Credit'), 'value' => -$customer_credit_discount));
         }
     }
     return $this;
 }
コード例 #11
0
ファイル: Quote.php プロジェクト: axovel/easycarcare
 /**
  * Enter description here...
  *
  * @param Mage_Sales_Model_Quote_Address $address
  * @return Mage_Sales_Model_Quote
  */
 public function setShippingAddress(Mage_Sales_Model_Quote_Address $address)
 {
     if ($this->getIsMultiShipping()) {
         $this->addAddress($address->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_SHIPPING));
     } else {
         $old = $this->getShippingAddress();
         if (!empty($old)) {
             $old->addData($address->getData());
         } else {
             $this->addAddress($address->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_SHIPPING));
         }
     }
     return $this;
 }
コード例 #12
0
 protected function _processValidateCustomer(Mage_Sales_Model_Quote_Address $address)
 {
     if ($address->getTaxvat()) {
         $this->getQuote()->setCustomerTaxvat($address->getTaxvat());
     }
     if ($this->getQuote()->getCheckoutMethod() == self::REGISTER) {
         $customer = Mage::getModel('customer/customer');
         $this->getQuote()->setPasswordHash($customer->encryptPassword($address->getCustomerPassword()));
         $cust_data = array('email' => 'email', 'password' => 'customer_password', 'confirmation' => 'confirm_password', 'firstname' => 'firstname', 'lastname' => 'lastname', 'taxvat' => 'taxvat');
         foreach ($cust_data as $key => $value) {
             $customer->setData($key, $address->getData($value));
         }
         $val_result = $customer->validate();
         if ($val_result !== true && is_array($val_result)) {
             return array('message' => implode(', ', $val_result), 'error' => -1);
         }
     } elseif ($this->getQuote()->getCheckoutMethod() == self::GUEST) {
         $email = $address->getData('email');
         if (!Zend_Validate::is($email, 'EmailAddress')) {
             return array('message' => $this->_help_obj->__('Invalid email address "%s"', $email), 'error' => -1);
         }
     }
     return true;
 }
コード例 #13
0
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     $quote = $address->getQuote();
     if (Mage::getStoreConfig('customercredit/spend/tax', $quote->getStoreId()) == 1) {
         return $this;
     }
     if (!$quote->isVirtual() && $address->getData('address_type') == 'billing') {
         return $this;
     }
     $session = Mage::getSingleton('checkout/session');
     $customer_credit_discount = $address->getCustomercreditDiscount();
     if ($session->getBaseCustomerCreditAmount()) {
         $customer_credit_discount = $session->getBaseCustomerCreditAmount();
     }
     if ($customer_credit_discount > 0) {
         $address->addTotal(array('code' => $this->getCode(), 'title' => Mage::helper('customercredit')->__('Customer Credit'), 'value' => -$customer_credit_discount));
     }
     return $this;
 }
コード例 #14
0
 /**
  * Copy real address to the quote
  *
  * @param Mage_Sales_Model_Quote $quote
  * @param Mage_Sales_Model_Quote_Address $realAddress
  * @return Mage_Sales_Model_Quote_Address
  */
 protected function _copyAddress($quote, $realAddress)
 {
     $address = Mage::getModel('sales/quote_address');
     $address->setData($realAddress->getData());
     $address->setId(null)->unsEntityId()->unsetData('cached_items_nominal')->unsetData('cached_items_nonnominal')->unsetData('cached_items_all')->setQuote($quote);
     return $address;
 }
コード例 #15
0
ファイル: Anonymizer.php プロジェクト: buro71a/Anonymizer
 /**
  * @param Mage_Sales_Model_Quote_Address $quoteAddress
  * @param array $randomData
  */
 protected function _anonymizeQuoteAddress($quoteAddress, $randomData)
 {
     foreach ($this->_getAddressMapping() as $addressKey => $randomDataKey) {
         if (!$quoteAddress->getData($addressKey)) {
             continue;
         }
         if (strlen($randomDataKey)) {
             $quoteAddress->setData($addressKey, $randomData[$randomDataKey]);
         } else {
             $quoteAddress->setData($addressKey, '');
         }
     }
     $quoteAddress->getResource()->save($quoteAddress);
     $this->_anonymizedQuoteAddressIds[] = $quoteAddress->getId();
 }
コード例 #16
0
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     $amount = $address->getData('zitec_dpd_cashondelivery_surcharge');
     if ($amount != 0 && $address->getAddressType() == 'shipping') {
         $title = Mage::getStoreConfig('payment/zitec_dpd_cashondelivery/total_title', $address->getQuote()->getStore());
         $address->addTotal(array('code' => $this->getCode(), 'title' => $title, 'value' => $amount));
     }
     return $this;
 }
コード例 #17
0
 protected function _processValidateCustomer(Mage_Sales_Model_Quote_Address $address)
 {
     $dob = '';
     if ($address->getDob()) {
         $dob = Mage::app()->getLocale()->date($address->getDob(), null, null, false)->toString('yyyy-MM-dd');
         $this->getQuote()->setCustomerDob($dob);
     }
     if ($address->getTaxvat()) {
         $this->getQuote()->setCustomerTaxvat($address->getTaxvat());
     }
     if ($address->getGender()) {
         $this->getQuote()->setCustomerGender($address->getGender());
     }
     if ($this->getQuote()->getCheckoutMethod() == 'register') {
         $customer = Mage::getModel('customer/customer');
         $this->getQuote()->setPasswordHash($customer->encryptPassword($address->getCustomerPassword()));
         foreach (array('firstname' => 'firstname', 'lastname' => 'lastname', 'email' => 'email', 'password' => 'customer_password', 'confirmation' => 'confirm_password', 'taxvat' => 'taxvat', 'gender' => 'gender') as $key => $dataKey) {
             $customer->setData($key, $address->getData($dataKey));
         }
         if ($dob) {
             $customer->setDob($dob);
         }
         $validationResult = $customer->validate();
         if (true !== $validationResult && is_array($validationResult)) {
             return array('error' => -1, 'message' => implode(', ', $validationResult));
         }
     } elseif (self::METHOD_GUEST == $this->getQuote()->getCheckoutMethod()) {
         $email = $address->getData('email');
         if (!Zend_Validate::is($email, 'EmailAddress')) {
             return array('error' => -1, 'message' => $this->_helper->__('Invalid email address "%s"', $email));
         }
     }
     return true;
 }
コード例 #18
0
 /**
  * @param Mage_Sales_Model_Quote_Address $address
  */
 protected function _country(&$address)
 {
     $_country = Mage::app()->getLocale()->getCountryTranslation($address->getData("country_id"));
     $address->setData("country", $_country);
 }