Example #1
0
 public function delete()
 {
     if ($this->currency_id == JeproshopSettingModelSetting::getValue('default_currency')) {
         $db = JFactory::getDBO();
         $query = "SELECT " . $db->quoteName('currency_id') . " FROM " . $db->quoteName('#__jeproshop_currency') . " WHERE " . $db->quoteName('currency_id') . " = " . (int) $this->currency_id . " AND " . $db->quoteName('deleted') . " = 0";
         $db->setQuery($query);
         $result = $db->loadObject();
         if (!$result->currency_id) {
             return false;
         }
         JeproshopSettingModelSetting::updateValue('default_currency', $result->currency_id);
     }
     $this->deleted = 1;
     return $this->update();
 }
Example #2
0
 public static function deleteItems($product_id)
 {
     $db = JFactory::getDBO();
     $query = "UPDATE " . $db->quoteName('#__jeproshop_product') . " SET " . $db->quoteName('cache_is_pack');
     $query .= " = 0 WHERE product_id = " . (int) $product_id;
     $db->setQuery($query);
     $result = $db->query();
     $query = "DELETE FROM " . $db->quoteName('#__jeproshop_product_pack') . " WHERE " . $db->quoteName('product_pack_id');
     $query .= " = " . (int) $product_id;
     $db->setQuery($query);
     $result &= $db->query();
     return $result && JeproshopSettingModelSetting::updateValue('pack_feature_active', JeproshopProductPack::isCurrentlyUsed());
 }
Example #3
0
 public static function deleteByProductId($product_id)
 {
     $db = JFactory::getDBO();
     $query = "DELETE FROM " . $db->quoteName('#__jeproshop_specific_price') . " WHERE " . $db->quoteName('product_id') . " = " . (int) $product_id;
     $db->setQuery($query);
     if ($db->query()) {
         // Refresh cache of feature detachable
         JeproshopSettingModelSetting::updateValue('specific_price_feature_active', JeproshopSpecificPriceRuleModelSpecificPriceRule::isCurrentlyUsed('specific_price'));
         return true;
     }
     return false;
 }
Example #4
0
 protected function geolocationManagement($default_country)
 {
     $context = JeproshopContext::getContext();
     if (!in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1'))) {
         /* Check if Maxmind Database exists */
         if (file_exists(COM_JEPROSHOP_GEOIP_DIR . 'GeoLiteCity.dat')) {
             if (!isset($context->cookie->iso_code_country) || isset($context->cookie->iso_code_country) && !in_array(strtoupper($context->cookie->iso_code_country), explode(';', JeproshopSettingModelSetting::getValue('allowed_countries')))) {
                 include_once COM_JEPROSHOP_GEOIP_DIR . 'geoipcity.inc';
                 $gi = geoip_open(realpath(COM_JEPROSHOP_GEOIP_DIR . 'GeoLiteCity.dat'), COM_JEPROSHOP_GEOIP_STANDARD);
                 $record = geoip_record_by_addr($gi, Tools::getRemoteAddr());
                 if (is_object($record)) {
                     if (!in_array(strtoupper($record->country_code), explode(';', JeproshopSettingModelSetting::getValue('allowed_countries'))) && !self::isInWhitelistForGeolocation()) {
                         if (JeproshopSettingModelSetting::getValue('geolocation_behavior') == COM_JEPROSHOP_GEOLOCATION_NO_CATALOG) {
                             $this->restricted_country = true;
                         } elseif (JeproshopSettingModelSetting::getValue('PS_GEOLOCATION_BEHAVIOR') == COM_JEPROSHOP_GEOLOCATION_NO_ORDER) {
                             $context->smarty->assign(array('restricted_country_mode' => true, 'geolocation_country' => $record->country_name));
                         }
                     } else {
                         $has_been_set = !isset($context->cookie->iso_code_country);
                         $context->cookie->iso_code_country = strtoupper($record->country_code);
                     }
                 }
             }
             if (isset($context->cookie->iso_code_country) && $context->cookie->iso_code_country && !Validate::isLanguageIsoCode($this->context->cookie->iso_code_country)) {
                 $this->context->cookie->iso_code_country = Country::getIsoById(JeproshopSettingModelSetting::get('PS_COUNTRY_DEFAULT'));
             }
             if (isset($this->context->cookie->iso_code_country) && ($id_country = Country::getByIso(strtoupper($this->context->cookie->iso_code_country)))) {
                 /* Update defaultCountry */
                 if ($default_country->iso_code != $this->context->cookie->iso_code_country) {
                     $default_country = new Country($id_country);
                 }
                 if (isset($has_been_set) && $has_been_set) {
                     $this->context->cookie->id_currency = (int) Currency::getCurrencyInstance($default_country->id_currency ? (int) $default_country->id_currency : Configuration::get('PS_CURRENCY_DEFAULT'))->id;
                 }
                 return $default_country;
             } elseif (JeproshopSettingModelSetting::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_ && !FrontController::isInWhitelistForGeolocation()) {
                 $this->restricted_country = true;
             } elseif (JeproshopSettingModelSetting::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_ && !FrontController::isInWhitelistForGeolocation()) {
                 $this->context->smarty->assign(array('restricted_country_mode' => true, 'geolocation_country' => 'Undefined'));
             }
         } else {
             JeproshopSettingModelSetting::updateValue('PS_GEOLOCATION_ENABLED', 0);
         }
     }
     return false;
 }