Ejemplo n.º 1
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $session = Mage::getSingleton('checkout/session');
     $discount = $session->getData('onestepcheckout_admin_discount');
     if (!$discount) {
         return $this;
     }
     $items = $address->getAllItems();
     if (!count($items)) {
         return $this;
     }
     $session->setData('onestepcheckout_admin_discount', $discount);
     $address->setOnestepcheckoutDiscountAmount($discount);
     $address->setData('onestepcheckout_discount_amount', $discount);
     $address->setGrandTotal($address->getGrandTotal() - $address->getOnestepcheckoutDiscountAmount());
     $address->setBaseGrandTotal($address->getBaseGrandTotal() - $address->getOnestepcheckoutDiscountAmount());
     return $this;
 }
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $address->setData('zitec_dpd_cashondelivery_surcharge', 0);
     $address->setData('base_zitec_dpd_cashondelivery_surcharge', 0);
     $address->setData('zitec_dpd_cashondelivery_surcharge_tax', 0);
     $address->setData('base_zitec_dpd_cashondelivery_surcharge_tax', 0);
     $paymentMethod = $address->getQuote()->getPayment()->getMethod();
     if ($paymentMethod == Mage::helper('zitec_dpd')->getDpdPaymentCode() && $address->getAddressType() == 'shipping') {
         $quote = $address->getQuote();
         /* @var $quote Mage_Sales_Model_Quote */
         $shippingAddress = $quote->getShippingAddress();
         $request = new Varien_Object();
         $request->setWebsiteId(Mage::helper('zitec_dpd/payment')->getWebsiteId());
         $request->setDestCountryId($shippingAddress->getCountryId());
         $request->setDestRegionId($shippingAddress->getRegionId());
         $request->setDestPostcode($shippingAddress->getPostcode());
         $request->setPackageWeight($shippingAddress->getWeight());
         if ($this->_getTaxHelper()->shippingPriceIncludesTax($address->getQuote()->getStoreId())) {
             $request->setData('zitec_table_price', $shippingAddress->getBaseSubtotalInclTax());
         } else {
             $request->setData('zitec_table_price', $shippingAddress->getBaseSubtotal());
         }
         $request->setMethod(str_replace(Mage::helper('zitec_dpd')->getDPDCarrierCode() . '_', '', $shippingAddress->getShippingMethod()));
         $tablerateSurcharge = Mage::getResourceModel('zitec_dpd/carrier_tablerate')->getCashOnDeliverySurcharge($request);
         if (is_null($tablerateSurcharge)) {
             return $this;
         } elseif (!empty($tablerateSurcharge)) {
             $baseCashondeliverySurcharge = $this->_getHelper()->calculateQuoteBaseCashOnDeliverySurcharge($quote, $tablerateSurcharge);
         } else {
             $baseCashondeliverySurcharge = $this->_getHelper()->returnDefaultBaseCashOnDeliverySurcharge($quote);
         }
         if (!isset($baseCashondeliverySurcharge)) {
             return $this;
         }
         $baseCurrencyCode = $quote->getStore()->getBaseCurrencyCode();
         $currentCurrencyCode = $quote->getStore()->getCurrentCurrencyCode();
         $cashondeliverySurcharge = Mage::helper('directory')->currencyConvert($baseCashondeliverySurcharge, $baseCurrencyCode, $currentCurrencyCode);
         $address->setData('zitec_dpd_cashondelivery_surcharge', $cashondeliverySurcharge);
         $address->setData('base_zitec_dpd_cashondelivery_surcharge', $baseCashondeliverySurcharge);
         $this->_calculateSurchargeSalesTax($address);
         $quote->save();
     }
     $address->setGrandTotal($address->getGrandTotal() + $address->getData('zitec_dpd_cashondelivery_surcharge'));
     $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getData('base_zitec_dpd_cashondelivery_surcharge'));
     return $this;
 }
Ejemplo n.º 3
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $store = $address->getQuote()->getStore();
     $session = Mage::getSingleton('checkout/session');
     $discount = $session->getData('webpos_admin_discount');
     if (!$discount) {
         return $this;
     }
     $items = $address->getAllItems();
     if (!count($items)) {
         return $this;
     }
     $session->setData('webpos_admin_discount', $discount);
     $address->setWebposDiscountAmount($discount);
     $address->setData('webpos_discount_amount', $discount);
     /* Daniel - tax for discount */
     $afterDiscount = Mage::getStoreConfig('tax/calculation/apply_after_discount');
     if ($afterDiscount) {
         $country = Mage::getModel('checkout/session')->getQuote()->getShippingAddress()->getCountry();
         $oldTax = $address->getTaxAmount();
         $oldBaseTax = $address->getBaseTaxAmount();
         if ($country) {
             $rateTax = Mage::getModel('tax/calculation_rate')->getCollection()->addFieldToFilter('tax_country_id', $country)->setOrder('rate', 'DESC')->getFirstItem();
             $address->setTaxAmount(($address->getBaseSubtotal() - $discount + $address->getShippingAmount() + $address->getDiscountAmount()) * $rateTax->getRate() / 100)->setBaseTaxAmount(($address->getBaseSubtotal() - $discount + $address->getShippingAmount() + $address->getDiscountAmount()) * $rateTax->getRate() / 100);
             $taxCalculationModel = Mage::getSingleton('tax/calculation');
             $request = Mage::getSingleton('tax/calculation')->getRateRequest($address, $address->getQuote()->getBillingAddress(), $address->getQuote()->getCustomerTaxClassId(), $store);
             $rate = Mage::getSingleton('tax/calculation')->getRate($request);
             $this->_saveAppliedTaxes($address, $taxCalculationModel->getAppliedRates($request), $address->getTaxAmount(), $address->getBaseTaxAmount(), $rate);
         }
         $address->setGrandTotal($address->getGrandTotal() - $address->getWebposDiscountAmount());
         $address->setBaseGrandTotal($address->getBaseGrandTotal() - $address->getWebposDiscountAmount());
     } else {
         $address->setGrandTotal($address->getGrandTotal() - $address->getWebposDiscountAmount());
         $address->setBaseGrandTotal($address->getBaseGrandTotal() - $address->getWebposDiscountAmount());
     }
     /* end */
     return $this;
 }
Ejemplo n.º 4
0
 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);
 }
 /**
  * @param Mage_Sales_Model_Quote_Address $address
  */
 protected function _country(&$address)
 {
     $_country = Mage::app()->getLocale()->getCountryTranslation($address->getData("country_id"));
     $address->setData("country", $_country);
 }
Ejemplo n.º 6
0
 /**
  * @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();
 }