/** * The constructor * * @param int|string $country country * * @return void */ public function __construct($country = null) { global $currency; $this->_country = KlarnaUtils::deduceCountry('part'); $this->_language = KlarnaUtils::getLanguageCode(); $this->_currency = $currency; if ($country === null && $this->_country == null) { $this->_country = strtoupper($_SESSION['language_code']); } if ($this->_country === null) { Klarna::printDebug(__METHOD__, array('currency' => $this->_currency, 'language' => $this->_language)); $this->_enabled = false; return; } $this->_utils = new KlarnaUtils($this->_country); $this->_enabled = KlarnaConstant::isEnabled('part', $this->_country); if ($this->_enabled === true && !KlarnaConstant::isActivated('part', $this->_country)) { $this->_enabled = false; } $this->_locale = KiTT::locale($this->_country, $this->_language, $this->_currency); }
/** * Check if pclasses for given option exists and show warning if it doesn't * * @param string $option 'part' or 'spec' * * @return void */ public function checkForPClasses($option) { $sql = ""; $module = ""; if ($option == KiTT::PART) { $module = 'Part Payment Module'; $sql = "type <> 2"; } else { if (KiTT::SPEC) { $module = 'Special Campaigns Module'; $sql = "type = 2"; } else { return; } } if (KlarnaConstant::isEnabled($option, $this->_country)) { // instantiate MySQLStorage to ensure the table exists $pcURI = KlarnaConstant::pcURI(); $pcstorage = new MySQLStorage(); $pcstorage->load($pcURI); $count = $this->_klarnaDB->query("SELECT COUNT(type) as num FROM klarna_pclasses WHERE {$sql}")->getArray(); if ($count['num'] == 0 && !isset($_GET['get_pclasses']) && headers_sent()) { $templateLoader = KiTT::templateLoader(KiTT::Locale($this->_country)); $no_pclasses = $templateLoader->load('no_pclasses.mustache'); echo $no_pclasses->render(array('module' => $module)); } } }
/** * Check if the instanced payment module should be shown. * * @param KiTT_Payment_Option $view KiTT Payment Option instance * * @return boolean */ private function _isEnabled($view) { return KlarnaConstant::isActivated($this->_option, $this->_country) && KlarnaConstant::isEnabled($this->_option, $this->_country) && $view->isAvailable(); }