Esempio n. 1
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $address->setBaseSubscriptionInitAmount(0);
     $address->setSubscriptionInitAmount(0);
     $this->_setAddress($address);
     $this->_setAmount(0);
     $this->_setBaseAmount(0);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     $quote = $address->getQuote();
     $baseInitAmount = $this->getInitAmount($quote);
     $initAmount = $address->getQuote()->getStore()->convertPrice($baseInitAmount, false);
     if (!Mage::registry('customweb_subscription_recurring_order') && $baseInitAmount) {
         $address->setBaseSubscriptionInitAmount($baseInitAmount);
         $address->setSubscriptionInitAmount($initAmount);
         $quote->setBaseSubscriptionInitAmount($baseInitAmount);
         $quote->setSubscriptionInitAmount($initAmount);
         $address->setGrandTotal($address->getGrandTotal() + $initAmount);
         $address->setBaseGrandTotal($address->getBaseGrandTotal() + $initAmount);
         $this->_calculateTax($address);
     }
 }
Esempio n. 2
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     // Makes sure you only use the address type shipping
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     // reset totals by default (needed for some external checkout modules)
     $address->setPaymentFeeAmount(0);
     $address->setBasePaymentFeeAmount(0);
     $adyenFeeHelper = Mage::helper('adyen_fee');
     $this->_setAmount(0);
     $this->_setBaseAmount(0);
     $quote = $address->getQuote();
     $val = $adyenFeeHelper->isPaymentFeeEnabled($quote);
     if ($address->getAllItems() && $val) {
         $basePaymentFee = $adyenFeeHelper->getPaymentFeeExclVat($address);
         if ($basePaymentFee) {
             $address->setPaymentFeeAmount($address->getQuote()->getStore()->convertPrice($basePaymentFee));
             $address->setBasePaymentFeeAmount($basePaymentFee);
             $address->setGrandTotal($address->getGrandTotal() + $address->getPaymentFeeAmount());
             $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBasePaymentFeeAmount());
         }
     }
     return $this;
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $address->setDamageWaiverAmount(0);
     $address->setBaseDamageWaiverAmount(0);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
         //this makes only address type shipping to come through
     }
     $quote = $address->getQuote();
     $quote->setDamageWaiverAmount(0);
     $depositAmt = ITwebexperts_Payperrentals_Helper_Price::getQuoteDamageWaiver($quote);
     if ($depositAmt > 0) {
         $exist_amount = $quote->getDamageWaiverAmount();
         $fee = $depositAmt;
         $balance = $fee - $exist_amount;
         $address->setDamageWaiverAmount($balance);
         $address->setBaseDamageWaiverAmount($balance);
         $quote->setDamageWaiverAmount($balance);
     } else {
         $address->setDamageWaiverAmount(0);
         $address->setBaseDamageWaiverAmount(0);
         $quote->setDamageWaiverAmount(0);
     }
     return $this;
 }
Esempio n. 5
0
 /**
  * Collect totals information about shipping
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @return  Mage_Sales_Model_Quote_Address_Total_Shipping
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $calc = $this->_calculator;
     $store = $address->getQuote()->getStore();
     $storeTaxRequest = $calc->getRateOriginRequest($store);
     $addressTaxRequest = $calc->getRateRequest($address, $address->getQuote()->getBillingAddress(), $address->getQuote()->getCustomerTaxClassId(), $store);
     $storeTaxRequest->setProductClassId($this->_config->getShippingTaxClass($store));
     $addressTaxRequest->setProductClassId($this->_config->getShippingTaxClass($store));
     $this->_areTaxRequestsSimilar = $calc->compareRequests($addressTaxRequest, $storeTaxRequest);
     $shipping = $taxShipping = $address->getShippingAmount();
     $baseShipping = $baseTaxShipping = $address->getBaseShippingAmount();
     $rate = $calc->getRate($addressTaxRequest);
     if ($this->_config->shippingPriceIncludesTax($store)) {
         if ($this->_areTaxRequestsSimilar) {
             $tax = $this->_round($calc->calcTaxAmount($shipping, $rate, true, false), $rate, true);
             $baseTax = $this->_round($calc->calcTaxAmount($baseShipping, $rate, true, false), $rate, true, 'base');
             $taxShipping = $shipping;
             $baseTaxShipping = $baseShipping;
             $shipping = $shipping - $tax;
             $baseShipping = $baseShipping - $baseTax;
             $taxable = $taxShipping;
             $baseTaxable = $baseTaxShipping;
             $isPriceInclTax = true;
         } else {
             $storeRate = $calc->getStoreRate($addressTaxRequest, $store);
             $storeTax = $calc->calcTaxAmount($shipping, $storeRate, true, false);
             $baseStoreTax = $calc->calcTaxAmount($baseShipping, $storeRate, true, false);
             $shipping = $calc->round($shipping - $storeTax);
             $baseShipping = $calc->round($baseShipping - $baseStoreTax);
             $tax = $this->_round($calc->calcTaxAmount($shipping, $rate, false, false), false, $rate);
             $baseTax = $this->_round($calc->calcTaxAmount($baseShipping, $rate, false, false), $rate, false, 'base');
             $taxShipping = $shipping + $tax;
             $baseTaxShipping = $baseShipping + $baseTax;
             $taxable = $shipping;
             $baseTaxable = $baseShipping;
             $isPriceInclTax = false;
         }
     } else {
         $tax = $this->_round($calc->calcTaxAmount($shipping, $rate, false, false), false, $rate);
         $baseTax = $this->_round($calc->calcTaxAmount($baseShipping, $rate, false, false), $rate, false, 'base');
         $taxShipping = $shipping + $tax;
         $baseTaxShipping = $baseShipping + $baseTax;
         $taxable = $shipping;
         $baseTaxable = $baseShipping;
         $isPriceInclTax = false;
     }
     $address->setTotalAmount('shipping', $shipping);
     $address->setBaseTotalAmount('shipping', $baseShipping);
     $address->setShippingInclTax($taxShipping);
     $address->setBaseShippingInclTax($baseTaxShipping);
     $address->setShippingTaxable($taxable);
     $address->setBaseShippingTaxable($baseTaxable);
     $address->setIsShippingInclTax($isPriceInclTax);
     if ($this->_config->discountTax($store)) {
         $address->setShippingAmountForDiscount($taxShipping);
         $address->setBaseShippingAmountForDiscount($baseTaxShipping);
     }
     return $this;
 }
Esempio n. 6
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $this->_setAmount(0);
     $this->_setBaseAmount(0);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
         //this makes only address type shipping to come through
     }
     $quote = $address->getQuote();
     if (Excellence_Fee_Model_Fee::canApply($address)) {
         $exist_amount = $quote->getFeeAmount();
         $fee = Excellence_Fee_Model_Fee::getFee();
         $balance = $fee - $exist_amount;
         // 			$balance = $fee;
         //$this->_setAmount($balance);
         //$this->_setBaseAmount($balance);
         $address->setFeeAmount($balance);
         $address->setBaseFeeAmount($balance);
         $quote->setFeeAmount($balance);
         $address->setGrandTotal($address->getGrandTotal() + $address->getFeeAmount());
         $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseFeeAmount());
     }
 }
Esempio n. 7
0
 /**
  * Collect address discount amount
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @return  Mage_SalesRule_Model_Quote_Discount
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $quote = $address->getQuote();
     $store = Mage::app()->getStore($quote->getStoreId());
     $this->_calculator->reset($address);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     $eventArgs = array('website_id' => $store->getWebsiteId(), 'customer_group_id' => $quote->getCustomerGroupId(), 'coupon_code' => $quote->getCouponCode());
     $this->_calculator->init($store->getWebsiteId(), $quote->getCustomerGroupId(), $quote->getCouponCode());
     $this->_calculator->initTotals($items, $address);
     $address->setDiscountDescription(array());
     $items = $this->_calculator->sortItemsByPriority($items);
     foreach ($items as $item) {
         if ($item->getNoDiscount()) {
             $item->setDiscountAmount(0);
             $item->setBaseDiscountAmount(0);
         } else {
             /**
              * Child item discount we calculate for parent
              */
             if ($item->getParentItemId()) {
                 continue;
             }
             $eventArgs['item'] = $item;
             Mage::dispatchEvent('sales_quote_address_discount_item', $eventArgs);
             if ($item->getHasChildren() && $item->isChildrenCalculated()) {
                 foreach ($item->getChildren() as $child) {
                     $this->_calculator->process($child);
                     $eventArgs['item'] = $child;
                     Mage::dispatchEvent('sales_quote_address_discount_item', $eventArgs);
                     $this->_aggregateItemDiscount($child);
                 }
             } else {
                 $this->_calculator->process($item);
                 $this->_aggregateItemDiscount($item);
             }
         }
     }
     /**
      * process weee amount
      */
     if (Mage::helper('weee')->isEnabled() && Mage::helper('weee')->isDiscounted($store)) {
         $this->_calculator->processWeeeAmount($address, $items);
     }
     /**
      * Process shipping amount discount
      */
     $address->setShippingDiscountAmount(0);
     $address->setBaseShippingDiscountAmount(0);
     if ($address->getShippingAmount()) {
         $this->_calculator->processShippingAmount($address);
         $this->_addAmount(-$address->getShippingDiscountAmount());
         $this->_addBaseAmount(-$address->getBaseShippingDiscountAmount());
     }
     $this->_calculator->prepareDescription($address);
     return $this;
 }
Esempio n. 8
0
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     $_result = parent::fetch($address);
     $giftCards = Mage::helper('aw_giftcard/totals')->getQuoteGiftCards($address->getQuote()->getId());
     $address->addTotal(array('code' => $this->getCode(), 'title' => Mage::helper('aw_giftcard')->__('Gift Cards'), 'value' => -$address->getAwGiftCardsAmount(), 'gift_cards' => $giftCards));
     return $_result;
 }
Esempio n. 9
0
 /**
  * @param Mage_Sales_Model_Quote_Address $address
  *
  * @return $this|Mage_Sales_Model_Quote_Address_Total_Abstract
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     if (Mage::helper("shopgate/config")->getIsMagentoVersionLower1410()) {
         $items = $address->getAllItems();
     } else {
         $items = $this->_getAddressItems($address);
     }
     $shopgateOrder = Mage::getSingleton("core/session")->getData("shopgate_order");
     if (!count($items) || is_null($shopgateOrder)) {
         return $this;
         //this makes only address type shipping to come through
     }
     $quote = $address->getQuote();
     $amountShopPayment = $shopgateOrder->getAmountShopPayment();
     if ($amountShopPayment >= 0) {
         return $this;
     }
     $address->setShopgatePaymentFee($amountShopPayment);
     $address->setBaseShopgatePaymentFee($amountShopPayment);
     $quote->setShopgatePaymentFee($amountShopPayment);
     $quote->setBaseShopgatePaymentFee($amountShopPayment);
     $address->setGrandTotal($address->getGrandTotal() + $address->getShopgatePaymentFee());
     $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseShopgatePaymentFee());
     return $this;
 }
Esempio n. 10
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     // Makes sure you only use the address type shipping
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     // reset totals by default (needed for onestepcheckout module)
     $address->setPaymentPercentageFee(0);
     $address->setBasePaymentPercentageFee(0);
     $quote = $address->getQuote();
     $adyenFeeHelper = Mage::helper('adyen_fee');
     $paymentMethod = $quote->getPayment()->getMethod();
     $percentageFee = $adyenFeeHelper->getHppPaymentMethodPercentageFee($paymentMethod);
     if (!$percentageFee) {
         return $this;
     }
     // minus the payment method fee inclusief tax if both are set
     $paymentMethodFee = $address->getPaymentFeeAmount();
     $paymentMethodFeeTax = $address->getPaymentFeeTax();
     $grandTotal = $address->getGrandTotal() - ($paymentMethodFee + $paymentMethodFeeTax);
     $fee = $address->getGrandTotal() / 100 * $percentageFee;
     $grandTotal = $address->getGrandTotal();
     $baseGrandTotal = $address->getBaseGrandTotal();
     $address->setPaymentPercentageFee($address->getQuote()->getStore()->convertPrice($fee));
     $address->setBasePaymentPercentageFee($fee);
     $address->setGrandTotal($grandTotal + $address->getPaymentPercentageFee());
     $address->setBaseGrandTotal($baseGrandTotal + $address->getBasePaymentPercentageFee());
     return $this;
 }
Esempio n. 11
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     if ($address->getAddressType() != "shipping") {
         return $this;
     }
     $this->address = $address;
     $this->_resetValues();
     if ($this->address->getQuote()->getId() == null) {
         return $this;
     }
     $items = $this->address->getAllItems();
     if (!count($items)) {
         return $this;
     }
     $payment = $this->address->getQuote()->getPayment();
     try {
         $this->paymentMethod = $payment->getMethodInstance();
     } catch (Mage_Core_Exception $e) {
         return $this;
     }
     if (!$this->paymentMethod instanceof Mage_Payment_Model_Method_Abstract) {
         return $this;
     }
     if ($this->paymentMethod->getCode() === 'billmateinvoice') {
         $this->_initInvoiceFee();
     }
     return $this;
 }
Esempio n. 12
0
File: Fee.php Progetto: ext/magento
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $page = $_SERVER['REQUEST_URI'];
     $onepage = "checkout/cart";
     $onepagecheck = strpos($page, $onepage);
     if ($onepagecheck !== false) {
         return $this;
     }
     $this->_setAmount(0);
     $this->_setBaseAmount(0);
     if (count($address->getAllItems()) == 0) {
         return $this;
     }
     $quote = $address->getQuote();
     $payment = $quote->getPayment();
     try {
         $method = $payment->getMethodInstance();
     } catch (Mage_Core_Exception $e) {
         return $this;
     }
     if ($method->getCode() != 'billmateinvoice') {
         return $this;
     }
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
         //this makes only address type shipping to come through
     }
     $invoiceFee = $baseInvoiceFee = Mage::helper('billmateinvoice')->replaceSeparator(Mage::getStoreConfig('payment/billmateinvoice/billmate_fee'));
     $exist_amount = $quote->getFeeAmount();
     if (Mage::getStoreConfig('payment/billmateinvoice/tax_class')) {
         $data = Mage::helper('billmateinvoice')->getInvoiceFeeArray($invoiceFee, $address, $quote->getCustomerTaxClassId());
         $invoiceFee = $data['base_incl'];
     }
     $this->_calculator = Mage::getSingleton('tax/calculation');
     $calc = $this->_calculator;
     $store = $address->getQuote()->getStore();
     $addressTaxRequest = $calc->getRateRequest($address->getQuote()->getShippingAddress(), $address->getQuote()->getBillingAddress(), $address->getQuote()->getCustomerTaxClassId(), $store);
     $paymentTaxClass = Mage::getStoreConfig('payment/billmateinvoice/tax_class');
     $addressTaxRequest->setProductClassId($paymentTaxClass);
     $rate = $calc->getRate($addressTaxRequest);
     $taxAmount = $calc->calcTaxAmount($baseInvoiceFee, $rate, false, true);
     $baseTaxAmount = $calc->calcTaxAmount($baseInvoiceFee, $rate, false, true);
     $address->setPaymentTaxAmount($taxAmount);
     $address->setBasePaymentTaxAmount($baseTaxAmount);
     //
     $address->setTaxAmount($address->getTaxAmount() + $taxAmount);
     $address->setBaseTaxAmount($address->getBaseTaxAmount() + $baseTaxAmount);
     /* clime: tax calculation end */
     $address->setFeeAmount($baseInvoiceFee);
     $address->setBaseFeeAmount($baseInvoiceFee);
     $address->setFeeTaxAmount($taxAmount);
     $address->setBaseFeeTaxAmount($baseTaxAmount);
     $totInv = $baseInvoiceFee + $taxAmount;
     $quote->setFeeAmount($baseInvoiceFee + $taxAmount);
     $quote->setFeeTaxAmount($taxAmount);
     $address->setGrandTotal($address->getGrandTotal() + $address->getBaseFeeAmount());
     $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseFeeAmount());
 }
Esempio n. 13
0
 /**
  * @param Mage_Sales_Model_Quote_Address $address
  * @return Mage_Sales_Model_Quote_Address_Total_Abstract
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $quote = $address->getQuote();
     $payment = $quote->getPayment();
     if ($address->getAddressType() === 'billing') {
         return $this;
     }
     $configId = $payment->getPayoneConfigPaymentMethodId();
     if (empty($configId)) {
         return $this;
     }
     $config = $this->helperConfig()->getConfigPaymentMethodById($configId, $quote->getStoreId());
     if (empty($config)) {
         return $this;
     }
     $feeConfig = $config->getFeeConfigForQuote($quote);
     if (!is_array($feeConfig) or !array_key_exists('fee_config', $feeConfig)) {
         return $this;
     }
     $paymentFee = $feeConfig['fee_config'];
     $oldShippingAmount = $address->getBaseShippingAmount();
     $newShippingAmount = $oldShippingAmount + $paymentFee;
     $address->setBaseShippingAmount($newShippingAmount);
     $address->setShippingAmount($quote->getStore()->convertPrice($newShippingAmount, false));
     return parent::collect($address);
 }
Esempio n. 14
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $totalItems = Mage::helper('checkout/cart')->getSummaryCount();
     parent::collect($address);
     $this->_setAmount(0);
     $this->_setBaseAmount(0);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     $quote = $address->getQuote();
     $exist_amount = $quote->getFeeAmount();
     $cod = Mage::helper("emipro_codpayment")->cod_charges($quote);
     $fee = $cod["fees"];
     $balance = $fee - $exist_amount;
     try {
         $balance = $balance / $totalItems;
     } catch (Exception $e) {
     }
     if ($quote->getPayment()->getMethod() == "cashondelivery") {
         $baseCurrencyCode = $quote->getBaseCurrencyCode();
         $currentCurrencyCode = $quote->getQuoteCurrencyCode();
         $CodChange = Mage::helper('directory')->currencyConvert($balance, $baseCurrencyCode, $currentCurrencyCode);
         $address->setFeeAmount($CodChange);
         $address->setBaseFeeAmount($balance);
         $address->setGrandTotal($address->getGrandTotal() + $address->getFeeAmount());
         $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseFeeAmount());
     }
 }
 /**
  * Collect totals information about insurance
  *
  * @param Mage_Sales_Model_Quote_Address $address
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $this->_setAmount(0);
     $this->_setBaseAmount(0);
     if ($address->getAddressType() == 'billing') {
         return $this;
     }
     $helper = Mage::helper('referralreward');
     $points = (int) Mage::getSingleton('core/session')->getPointsDiscount();
     //if ($points) {
     $quote = $address->getQuote();
     $exist_amount = $quote->getReferralrewardAmount();
     $amount = -1 * $helper->convertPoints($points);
     //if ($amount != 0) {
     $balance = $amount - $exist_amount;
     $address->setReferralrewardAmount($balance);
     $address->setBaseReferralrewardAmount($balance);
     $quote->setReferralrewardAmount($balance);
     $address->setGrandTotal($address->getGrandTotal() + $address->getReferralrewardAmount());
     $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseReferralrewardAmount());
     //}
     //}
     /*if ($amount) {
           $this->_addAmount($amount);
           $this->_addBaseAmount($amount);
       }*/
     return $this;
 }
Esempio n. 16
0
 /**
  * Collect gift wrapping totals
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @return  Enterprise_GiftWrapping_Model_Total_Quote_Giftwrapping
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     if ($address->getAddressType() != Mage_Sales_Model_Quote_Address::TYPE_SHIPPING) {
         return $this;
     }
     $this->_quote = $address->getQuote();
     $this->_store = $this->_quote->getStore();
     $quote = $this->_quote;
     if ($quote->getIsMultiShipping()) {
         $this->_quoteEntity = $address;
     } else {
         $this->_quoteEntity = $quote;
     }
     $this->_collectWrappingForItems($address)->_collectWrappingForQuote($address)->_collectPrintedCard($address);
     $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getGwItemsBasePrice() + $address->getGwBasePrice() + $address->getGwCardBasePrice());
     $address->setGrandTotal($address->getGrandTotal() + $address->getGwItemsPrice() + $address->getGwPrice() + $address->getGwCardPrice());
     if ($quote->getIsNewGiftWrappingCollecting()) {
         $quote->setGwItemsBasePrice(0);
         $quote->setGwItemsPrice(0);
         $quote->setGwBasePrice(0);
         $quote->setGwPrice(0);
         $quote->setGwCardBasePrice(0);
         $quote->setGwCardPrice(0);
         $quote->setIsNewGiftWrappingCollecting(false);
     }
     $quote->setGwItemsBasePrice($address->getGwItemsBasePrice() + $quote->getGwItemsBasePrice());
     $quote->setGwItemsPrice($address->getGwItemsPrice() + $quote->getGwItemsPrice());
     $quote->setGwBasePrice($address->getGwBasePrice() + $quote->getGwBasePrice());
     $quote->setGwPrice($address->getGwPrice() + $quote->getGwPrice());
     $quote->setGwCardBasePrice($address->getGwCardBasePrice() + $quote->getGwCardBasePrice());
     $quote->setGwCardPrice($address->getGwCardPrice() + $quote->getGwCardPrice());
     return $this;
 }
Esempio n. 17
0
 /**
  * Collect fee address amount
  *
  * @param Mage_Sales_Model_Quote_Address $address
  * @return Brander_PaymentFee_Model_Sales_Quote_Address_Total_Fee
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $this->_setAmount(0);
     $this->_setBaseAmount(0);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     /* @var $quote Mage_Sales_Model_Quote */
     $quote = $address->getQuote();
     /* @var $feeModel Brander_PaymentFee_Model_Fee */
     $feeModel = Mage::getModel('payment_fee/fee');
     if ($feeModel->canApply($address)) {
         $exist_amount = $quote->getFeeAmount();
         $fee = $feeModel->getFee($address);
         $balance = $fee - $exist_amount;
         $address->setFeeAmount($balance);
         $address->setBaseFeeAmount($balance);
         $quote->setFeeAmount($balance);
         $address->setGrandTotal($address->getGrandTotal() + $address->getFeeAmount());
         $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseFeeAmount());
     }
     return $this;
 }
Esempio n. 18
0
 /**
  * Collect totals information about insurance
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     if ($address->getAddressType() == 'billing') {
         return $this;
     }
     $amount = number_format($address->getQuote()->getGiftCardValue(), 2);
     $this->_totaldiscountpay = $amount;
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     $this->initTotals($items, $address);
     foreach ($items as $item) {
         if ($item->getParentItemId()) {
             continue;
         }
         if ($item->getHasChildren() && $item->isChildrenCalculated()) {
             foreach ($item->getChildren() as $child) {
                 $this->process($child);
                 $this->_aggregateItemDiscount($child);
             }
         } else {
             $this->process($item);
             $this->_aggregateItemDiscount($item);
         }
     }
     $address->setBaseGrandTotal($address->getBaseGrandTotal() - $amount);
     $address->setGrandTotal($address->getGrandTotal() - $amount);
     return $this;
 }
Esempio n. 19
0
 /**
  * Collect address subtotal
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @return  Mage_Sales_Model_Quote_Address_Total_Subtotal
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $address->setTotalQty(0);
     $baseVirtualAmount = $virtualAmount = 0;
     /**
      * Process address items
      */
     $items = $this->_getAddressItems($address);
     foreach ($items as $item) {
         if ($this->_initItem($address, $item) && $item->getQty() > 0) {
             /**
              * Separatly calculate subtotal only for virtual products
              */
             if ($item->getProduct()->isVirtual()) {
                 $virtualAmount += $item->getRowTotal();
                 $baseVirtualAmount += $item->getBaseRowTotal();
             }
         } else {
             $this->_removeItem($address, $item);
         }
     }
     $address->setBaseVirtualAmount($baseVirtualAmount);
     $address->setVirtualAmount($virtualAmount);
     /**
      * Initialize grand totals
      */
     Mage::helper('sales')->checkQuoteAmount($address->getQuote(), $address->getSubtotal());
     Mage::helper('sales')->checkQuoteAmount($address->getQuote(), $address->getBaseSubtotal());
     return $this;
 }
 /**
  * Collect Weee taxes amount and prepare items prices for taxation and discount
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @return  Mage_Weee_Model_Total_Quote_Weee
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
     $this->_isTaxAffected = false;
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     $address->setAppliedTaxesReset(true);
     $address->setAppliedTaxes(array());
     $this->_store = $address->getQuote()->getStore();
     $this->_helper->setStore($this->_store);
     foreach ($items as $item) {
         if ($item->getParentItemId()) {
             continue;
         }
         $this->_resetItemData($item);
         if ($item->getHasChildren() && $item->isChildrenCalculated()) {
             foreach ($item->getChildren() as $child) {
                 $this->_resetItemData($child);
                 $this->_process($address, $child);
             }
             $this->_recalculateParent($item);
         } else {
             $this->_process($address, $item);
         }
     }
     if ($this->_isTaxAffected) {
         $address->unsSubtotalInclTax();
         $address->unsBaseSubtotalInclTax();
     }
     return $this;
 }
Esempio n. 21
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $address->setSveaPaymentFeeAmount(0);
     $address->setBaseSveaPaymentFeeAmount(0);
     $address->setSveaPaymentFeeTaxAmount(0);
     $address->setBaseSveaPaymentFeeTaxAmount(0);
     $this->_setAmount(0)->_setBaseAmount(0);
     $collection = $address->getQuote()->getPaymentsCollection();
     if ($collection->count() <= 0 || $address->getQuote()->getPayment()->getMethod() == null) {
         return $this;
     }
     if ($address->getQuote()->getPayment()->getMethod() !== 'svea_invoice') {
         return $this;
     }
     $items = $address->getAllItems();
     if (!count($items)) {
         return $this;
     }
     $methodInstance = $address->getQuote()->getPayment()->getMethodInstance();
     $basePaymentFee = (double) $methodInstance->getConfigData('handling_fee');
     if (empty($basePaymentFee)) {
         return $this;
     }
     $paymentFee = $address->getQuote()->getStore()->convertPrice($basePaymentFee, false);
     $address->setSveaPaymentFeeAmount($paymentFee);
     $address->setBaseSveaPaymentFeeAmount($basePaymentFee);
     $this->_setAmount($paymentFee)->_setBaseAmount($basePaymentFee);
     return $this;
 }
Esempio n. 22
0
 /**
  * Collect execiseduty address amount
  *
  * @param Mage_Sales_Model_Quote_Address $address
  * @return Magentix_Execiseduty_Model_Sales_Quote_Address_Total_Execiseduty
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $this->_setAmount(0);
     $this->_setBaseAmount(0);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     $quote = $address->getQuote();
     if (Magentix_Execiseduty_Model_Execiseduty::canApply($address)) {
         $session = Mage::getSingleton("core/session", array("name" => "frontend"));
         $zip = $session->getData("zip");
         $checkoutSession = Mage::getSingleton('checkout/session');
         foreach ($checkoutSession->getQuote()->getAllItems() as $item) {
             $_item = Mage::getModel('catalog/product')->load($item->getProductId());
             $fullSku = $_item->getSku();
             $x = explode('-', $fullSku);
             $sellerId = trim($x[1]);
             $excise = trim($_item->getExciseDuty());
             if ($excise == '' || $excise == null || $excise == 'null') {
                 $excise = 0;
             }
             $tax = trim($item->getTaxPercent());
             if ($tax == '' || $tax == null || $tax == 'null') {
                 $tax = 0;
             }
             $kart[] = array('sellerId' => $sellerId, 'qty' => $item->getQty(), 'subtotal' => $item->getRowTotal(), 'sku' => trim($x[0]), 'VAT_Percentage' => $tax, 'excise_Percentage' => $excise);
         }
         $products[] = array('pincode' => $zip, 'kartInfo' => $kart);
         $enocdeurl = json_encode($products);
         $output = substr($enocdeurl, 1, -1);
         //API URL
         //$apiurlshipping = Mage::getStoreConfig('configuration/configuration_group/shippingcostapiurl');
         $apiurlshipping = Mage::getStoreConfig('configuration/configuration_shippingservice/shippingcostapiurl');
         $apiUrl = $apiurlshipping . $output;
         $braceleft = str_replace('{', '%7B', $apiUrl);
         $braceright = str_replace('}', '%7D', $braceleft);
         $squerbraceleft = str_replace('[', '%5B', $braceright);
         $squerbraceright = str_replace(']', '%5D', $squerbraceleft);
         $finalulr = str_replace('"', '%22', $squerbraceright);
         //Curl Function
         $ch = curl_init($finalulr);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_URL, $finalulr);
         $result = curl_exec($ch);
         curl_close($ch);
         $shipp = json_decode($result, true);
         $charge = $shipp['message']['KartChargesConsolidation']['excise'];
         $address->setExecisedutyAmount($charge);
         $address->setBaseExecisedutyAmount($charge);
         $quote->setExecisedutyAmount($charge);
         $address->setGrandTotal($address->getGrandTotal() + $charge);
         $address->setBaseGrandTotal($address->getBaseGrandTotal() + $charge);
     }
     return $this;
 }
Esempio n. 23
0
 /**
  * Add discount totals information to address object
  * 
  * @param Mage_Sales_Model_Quote_Address $address 
  * @return Mage_Sales_Model_Quote_Address_Total_Shipping 
  */
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     parent::fetch($address);
     $amount = $address->getTotalAmount($this->getCode());
     if ($amount != 0) {
         $address->addTotal(array('code' => $this->getCode(), 'title' => $this->getLabel(), 'value' => $amount));
     }
     return $this;
 }
Esempio n. 24
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     // $this->_setAmount (0);
     // $this->_setBaseAmount (0);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     $quote = Mage::helper('pagarme')->_getQuote();
     $payment = $quote->getPayment()->getMethod();
     if (!strcmp($payment, 'pagarme_cc') || !strcmp($payment, 'pagarme_checkout')) {
         $maxInstallments = (int) Mage::getStoreConfig('payment/pagarme_cc/max_installments');
         $minInstallmentValue = (double) Mage::getStoreConfig('payment/pagarme_cc/min_installment_value');
         $interestRate = (double) Mage::getStoreConfig('payment/pagarme_cc/interest_rate');
         $freeInstallments = (int) Mage::getStoreConfig('payment/pagarme_cc/free_installments');
         $total = Mage::helper('pagarme')->getBaseSubtotalWithDiscount() + Mage::helper('pagarme')->getBaseShippingAmount();
         $n = floor($total / $minInstallmentValue);
         if ($n > $maxInstallments) {
             $n = $maxInstallments;
         } elseif ($n < 1) {
             $n = 1;
         }
         $data = new Varien_Object();
         $data->setAmount(Mage::helper('pagarme')->formatAmount($total))->setInterestRate($interestRate)->setMaxInstallments($n)->setFreeInstallments($freeInstallments);
         $post = Mage::app()->getRequest()->getPost();
         $payment_installment = 0;
         if (isset($post['payment']['installments'])) {
             $payment_installment = $post['payment']['installments'];
         } else {
             if (isset($post['payment']['pagarme_checkout_installments'])) {
                 $payment_installment = $post['payment']['pagarme_checkout_installments'];
             }
         }
         $installments = Mage::getModel('pagarme/api')->calculateInstallmentsAmount($data);
         $collection = $installments->getInstallments();
         foreach ($collection as $item) {
             if ($item->getInstallment() == $payment_installment) {
                 $famount = intval($item->getInstallmentAmount()) / 100;
                 $iqty = intval($item->getInstallment());
                 $balance = $famount * $iqty - $total;
                 if ($balance < 0) {
                     break;
                 }
                 // The 1 cent problem
                 $address->setFeeAmount($balance);
                 $address->setBaseFeeAmount($balance);
                 $quote->setFeeAmount($balance);
                 $address->setGrandTotal($address->getGrandTotal() + $address->getFeeAmount());
                 $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseFeeAmount());
                 break;
             }
         }
     }
     return $this;
 }
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     // Makes sure you only use the address type shipping
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     // reset totals by default (needed for some external checkout modules)
     $address->setPaymentInstallmentFeeAmount(0);
     $address->setBasePaymentInstallmentFeeAmount(0);
     $quote = $address->getQuote();
     if ($address->getAllItems()) {
         $currentAmount = $address->getPaymentInstallmentFeeAmount();
         $payment = $quote->getPayment();
         if ($payment && !empty($payment)) {
             $paymentMethod = $quote->getPayment()->getMethod();
             if ($paymentMethod == "adyen_cc" || substr($paymentMethod, 0, 14) == 'adyen_oneclick') {
                 $info = $payment->getMethodInstance();
                 $instance = $info->getInfoInstance();
                 $numberOfInstallments = $instance->getAdditionalInformation('number_of_installments');
                 if ($numberOfInstallments > 0) {
                     // get the Interest Rate of this installment
                     // get cc type
                     $ccType = $instance->getCcType();
                     // get installment for this specific card type
                     $ccTypeInstallments = "installments_" . $ccType;
                     $all_installments = Mage::helper('adyen/installments')->getInstallments(null, $ccTypeInstallments);
                     if (empty($all_installments)) {
                         // use default installments
                         $all_installments = Mage::helper('adyen/installments')->getInstallments();
                     }
                     $installmentKey = $numberOfInstallments - 1;
                     $installment = $all_installments[$installmentKey];
                     if ($installment != null && is_array($installment)) {
                         // check if interest rate is filled in
                         if (isset($installment[3]) && $installment[3] > 0) {
                             $this->_setAmount(0);
                             $this->_setBaseAmount(0);
                             $interestRate = $installment[3];
                             $grandTotal = $address->getGrandTotal();
                             $fee = $grandTotal / 100 * $interestRate;
                             $balance = $fee - $currentAmount;
                             $address->setPaymentInstallmentFeeAmount($address->getQuote()->getStore()->convertPrice($balance));
                             $address->setBasePaymentInstallmentFeeAmount($balance);
                             $address->setGrandTotal($address->getGrandTotal() + $address->getPaymentInstallmentFeeAmount());
                             $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBasePaymentInstallmentFeeAmount());
                         }
                     }
                 }
             }
         }
     }
     return $this;
 }
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $this->_setAmount(0);
     $this->_setBaseAmount(0);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
         //this makes only address type shipping to come through
     }
     $quote = $address->getQuote();
     if (Excellence_Fee_Model_Fee::canApply($address)) {
         $exist_amount = $quote->getFeeAmount();
         //$fee = Excellence_Fee_Model_Fee::getFee()
         $quote = Mage::getModel('checkout/cart')->getQuote();
         $items = $quote->getAllVisibleItems();
         foreach ($items as $item) {
             $product = $item->getProduct();
             $categories = $product->getCategoryCollection()->addAttributeToSelect('name')->addAttributeToFilter('is_active', array('eq' => 1));
             foreach ($categories as $cat) {
                 $catid[] = $cat->getId();
             }
         }
         //echo "<pre>";
         //print_r(array_count_values($catid));
         $cat_array = array_count_values($catid);
         $total_handling_fee = 0;
         foreach (array_count_values($catid) as $catid => $catcont) {
             //echo $catid . " == ". $catcont."<pre>";
             for ($i = 1; $i <= $catcont; $i++) {
                 $h_fee = Mage::getModel('catalog/category')->load($catid)->getData('handling_fee' . $i);
                 $total_handling_fee += $h_fee;
             }
         }
         //echo "Total Fee: " .$total_handling_fee;
         //die();
         $config_option = Mage::app()->getStore()->getConfig('tab1/general/max_handling_fee');
         if ($total_handling_fee > $config_option) {
             $final_total_handling_fee = $config_option;
         } else {
             $final_total_handling_fee = $total_handling_fee;
         }
         $fee = $final_total_handling_fee;
         $balance = $fee - $exist_amount;
         // 			$balance = $fee;
         //$this->_setAmount($balance);
         //$this->_setBaseAmount($balance);
         $address->setFeeAmount($balance);
         $address->setBaseFeeAmount($balance);
         $quote->setFeeAmount($balance);
         $address->setGrandTotal($address->getGrandTotal() + $address->getFeeAmount());
         $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseFeeAmount());
     }
 }
Esempio n. 27
0
 /**
  * Collect address subtotal
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @return  Mage_Sales_Model_Quote_Address_Total_Subtotal
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $address->setTotalQty(0);
     $baseVirtualAmount = $virtualAmount = 0;
     /**
      * Process address items
      */
     $items = $this->_getAddressItems($address);
     //$itemCount = count($items);
     foreach ($items as $item) {
         //============================================================================================
         if ($item instanceof Mage_Sales_Model_Quote_Address_Item) {
             $quoteItem = $item->getAddress()->getQuote()->getItemById($item->getQuoteItemId());
         } else {
             $quoteItem = $item;
             if ($quoteItem->getParentItem() && $quoteItem->isChildrenCalculated()) {
                 $options = Mage::getModel('bundle/product_type')->getOrderOptions($quoteItem->getParentItem()->getProduct());
                 $totalChildPrice = 0;
                 $itemCount = 0;
                 foreach ($options['bundle_options'] as $k => $option) {
                     foreach ($option['value'] as $sub) {
                         $childPrice = $sub['price'] * $sub['qty'];
                         $totalChildPrice = $totalChildPrice + $childPrice;
                         $itemCount = $itemCount + 1;
                     }
                 }
             }
         }
         //$itemCount = $itemCount - 1;
         //==============================================================================================
         if ($this->_initItem($address, $item, $totalChildPrice, $itemCount) && $item->getQty() > 0) {
             /**
              * Separatly calculate subtotal only for virtual products
              */
             if ($item->getProduct()->isVirtual()) {
                 $virtualAmount += $item->getRowTotal();
                 $baseVirtualAmount += $item->getBaseRowTotal();
             }
         } else {
             $this->_removeItem($address, $item);
         }
     }
     $address->setBaseVirtualAmount($baseVirtualAmount);
     $address->setVirtualAmount($virtualAmount);
     /**
      * Initialize grand totals
      */
     Mage::helper('sales')->checkQuoteAmount($address->getQuote(), $address->getSubtotal());
     Mage::helper('sales')->checkQuoteAmount($address->getQuote(), $address->getBaseSubtotal());
     return $this;
 }
Esempio n. 28
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     if ($address->getAddressType() == 'billing') {
         return $this;
     }
     if (Mage::helper('customfee')->canApply()) {
         $amount = $this->getFeeAmount($address->getSubtotal());
         $this->_addAmount($amount);
         $this->_addBaseAmount($amount);
     }
     return $this;
 }
Esempio n. 29
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $giftCardQuote = Mage::getModel('giftcard/quote');
     $quote = $address->getQuote();
     $baseDiscount = $giftCardQuote->calculateDiscount($address, $quote->getBaseCurrencyCode());
     $discount = $giftCardQuote->calculateDiscount($address, $quote->getQuoteCurrencyCode());
     $this->_addAmount($discount);
     $this->_addBaseAmount($baseDiscount);
     $address->setMtGiftCardTotal($discount);
     $address->setBaseMtGiftCardTotal($baseDiscount);
     return $this;
 }
Esempio n. 30
0
 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     $_helper = Mage::helper('msp_cashondelivery');
     if (!$_helper->getSession()->getQuoteId()) {
         return $this;
     }
     parent::fetch($address);
     $_model = Mage::getModel('msp_cashondelivery/cashondelivery');
     $amount = $_model->getExtraFeeForTotal();
     if ($amount > 0 && $_helper->getQuote()->getPayment()->getMethod() == $_model->getCode() && $address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING) {
         $address->addTotal(array('code' => $_model->getCode(), 'title' => $_helper->__('Cash On Delivery'), 'value' => $amount));
     }
     return $this;
 }