Example #1
0
 public function reviewscollection()
 {
     if (Mage::getSingleton('customer/session')->isLoggedIn()) {
         $customer_id = Mage::getSingleTon('customer/session')->getId();
         $customer_reviews = Mage::getResourceModel('reviewsplus/reviewsplus')->customerreviews($customer_id);
         return $customer_reviews;
     }
 }
 protected function _construct()
 {
     $this->db = new Varien_Data_Collection_Db();
     $this->db->__construct(Mage::getSingleTon('core/resource')->getConnection('comprejunto'));
     $this->_init('comprejunto/comprejunto');
 }
Example #3
0
File: Form.php Project: ext/magento
 public function termsx()
 {
     $total = Mage::getSingleTon('checkout/session')->getQuote()->getShippingAddress()->getGrandTotal();
     return Mage::helper('partpayment')->getPlclass($total);
 }
 protected function _construct()
 {
     $this->db = new Varien_Data_Collection_Db();
     $this->db->__construct(Mage::getSingleTon('core/resource')->getConnection('motoboyconfig_write'));
     $this->_init('motoboyconfig/motoboyconfig');
 }
Example #5
0
 protected function _construct()
 {
     $this->db = new Varien_Data_Collection_Db();
     $this->db->__construct(Mage::getSingleTon('core/resource')->getConnection('osc_write'));
     $this->_init('osc/status');
 }
Example #6
0
 protected function _construct()
 {
     $this->db = new Varien_Data_Collection_Db();
     $this->db->__construct(Mage::getSingleTon('core/resource')->getConnection('marcascategoria_write'));
     $this->_init('marcascategoria/marcas');
 }
Example #7
0
File: Data.php Project: ext/magento
 function getPlclass($total)
 {
     $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
     $currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
     $_directory = Mage::helper('directory');
     $payment_option = array();
     $quote = Mage::getSingleTon('checkout/session')->getQuote();
     $address = $quote->getShippingAddress();
     $isoCode3 = 'SWE';
     //Mage::getModel('directory/country')->load($address->getCountryId())->getIso3Code();
     $isoCode2 = Mage::getModel('directory/country')->load($address->getCountryId())->getIso2Code();
     $collection = Mage::getModel('partpayment/pclass')->getCollection()->addFieldToFilter('country', $isoCode2)->addFieldToFilter('store_id', Mage::app()->getStore()->getId());
     if ($collection->getSize() == 0) {
         $collection = Mage::getModel('partpayment/pclass')->getCollection()->addFieldToFilter('country', $isoCode2)->addFieldToFilter('store_id', 0);
     }
     // Maps countries to currencies
     $country_to_currency = array('NOR' => 'NOK', 'SWE' => 'SEK', 'FIN' => 'EUR', 'DNK' => 'DKK', 'DEU' => 'EUR', 'NLD' => 'EUR');
     $country_to_currency = array('NOR' => 'NOK', 'SWE' => 'SEK', 'FIN' => 'EUR', 'DNK' => 'DKK', 'DEU' => 'EUR', 'NLD' => 'EUR');
     foreach ($collection as $pclass) {
         // 0 - Campaign
         // 1 - Account
         // 2 - Special
         // 3 - Fixed
         if (!in_array($pclass->getType(), array(0, 2, 1, 3, 4))) {
             continue;
         }
         if ($pclass->getType() == 2) {
             $monthly_cost = -1;
         } else {
             if ($total < $pclass->getMinamount() || $total > $pclass->getMaxamount() && $pclass->getMaxamount() > 0) {
                 continue;
             }
             if ($pclass->getType() == 3) {
                 continue;
             } else {
                 $sum = $total;
                 $lowest_payment = $this->getLowestPaymentAccount($isoCode3);
                 $monthly_cost = 0;
                 $monthly_fee = $pclass->getHandlingfee();
                 $start_fee = $pclass->getStartfee();
                 $sum += $start_fee;
                 $base = $pclass->getType() == 1;
                 $minimum_payment = $pclass->getType() === 1 ? $this->getLowestPaymentAccount($isoCode3) : 0;
                 if ($pclass->getNbrofmonths() == 0) {
                     $payment = $sum;
                 } elseif ((int) $pclass->getInterestrate() == 0) {
                     $payment = $sum / $pclass->getNbrofmonths();
                 } else {
                     // Because Interest rate is in decimal for example 0.12 no need to multiply by 100
                     $interest_rate = $pclass->getInterestrate() / 12;
                     $payment = $sum * $interest_rate / (1 - pow(1 + $interest_rate, -$pclass->getNbrofmonths()));
                 }
                 $payment += $monthly_fee;
                 $balance = $sum;
                 $pay_data = array();
                 $months = $pclass->getNbrofmonths();
                 while ($months != 0 && $balance > 0.01) {
                     // Because Interest rate is in decimal for example 0.12 no need to multiply by 100
                     $interest = $balance * $pclass->getInterestrate() / 12;
                     $new_balance = $balance + $interest + $monthly_fee;
                     if ($minimum_payment >= $new_balance || $payment >= $new_balance) {
                         $pay_data[] = $new_balance;
                         break;
                     }
                     $new_payment = max($payment, $minimum_payment);
                     if ($base) {
                         $new_payment = max($new_payment, $balance / 24.0 + $monthly_fee + $interest);
                     }
                     $balance = $new_balance - $new_payment;
                     $pay_data[] = $new_payment;
                     $months -= 1;
                 }
                 $monthly_cost = round(isset($pay_data[0]) ? $pay_data[0] : 0, 0);
                 if ($monthly_cost < 0.01) {
                     continue;
                 }
                 if ($pclass->getType() == 1 && $monthly_cost < $lowest_payment) {
                     $monthly_cost = $lowest_payment;
                 }
                 if ($pclass->getType() == 0 && $monthly_cost < $lowest_payment) {
                     continue;
                 }
             }
         }
         $monthly_cost = $_directory->currencyConvert($monthly_cost, $baseCurrencyCode, $currentCurrencyCode);
         $payment_option_temp['monthly_cost'] = $monthly_cost;
         $payment_option_temp['nbrofmonths'] = $pclass->getNbrofmonths();
         $payment_option_temp['pclass_id'] = $pclass->getPaymentplanid();
         $payment_option_temp['months'] = $pclass->getNbrofmonths();
         $payment_option_temp['description'] = $pclass->getDescription();
         $payment_option[] = $payment_option_temp;
     }
     return $payment_option;
 }
Example #8
0
 public function getTitle()
 {
     $quote = Mage::getSingleTon('checkout/session')->getQuote();
     $address = $quote->getShippingAddress();
     $title = '';
     if ($address) {
         $total = $address->getGrandTotal();
         $title = Mage::helper('partpayment')->getLowPclass($total);
     }
     $preTitle = strlen(Mage::getStoreConfig('payment/partpayment/title')) > 0 ? Mage::helper('partpayment')->__(Mage::getStoreConfig('payment/partpayment/title')) : Mage::helper('partpayment')->__('Billmate Partpayment');
     return $preTitle . $title;
     //return $this->getConfigData('title').$title;
 }