// Merge -> revision 8097

This commit is contained in:
rMalie
2011-08-17 16:10:20 +00:00
parent 5b26bb28b8
commit 66d4533e68
41 changed files with 107 additions and 135 deletions
+9 -6
View File
@@ -71,6 +71,9 @@ class DiscountCore extends ObjectModel
/** @var integer Minimum cart total amount required to use the discount */
public $minimal;
/** @var boolean include_tax selected for the choice of the calcul method in the cart*/
public $include_tax;
/** @var integer display the discount in the summary */
public $cart_display;
@@ -115,6 +118,7 @@ class DiscountCore extends ObjectModel
'date_from' => array('sqlId' => 'date_from'),
'date_to' => array('sqlId' => 'date_to'),
'minimal' => array('sqlId' => 'minimal'),
'include_tax' => array('sqlId' => 'include_tax'),
'active' => array('sqlId' => 'active'),
'cart_display' => array('sqlId' => 'cart_display'),
'date_add' => array('sqlId' => 'date_add'),
@@ -141,6 +145,7 @@ class DiscountCore extends ObjectModel
$fields['date_from'] = pSQL($this->date_from);
$fields['date_to'] = pSQL($this->date_to);
$fields['minimal'] = (float)($this->minimal);
$fields['include_tax'] = (int)($this->include_tax);
$fields['behavior_not_exhausted'] = (int)$this->behavior_not_exhausted;
$fields['active'] = (int)($this->active);
$fields['cart_display'] = (int)($this->cart_display);
@@ -297,11 +302,9 @@ class DiscountCore extends ObjectModel
foreach ($products AS $product)
if (count($categories) AND Product::idIsOnCategoryId($product['id_product'], $categories))
$totalAmount += $useTax ? $product['price_wt'] * $product['quantity']: $product['price'] * $product['quantity'];
$totalAmount += $this->include_tax ? $product['total_wt'] : $product['total'];
if ($this->minimal > 0 AND $totalAmount < $this->minimal)
return 0;
switch ($this->id_discount_type)
{
/* Relative value (% of the order total) */
@@ -311,7 +314,7 @@ class DiscountCore extends ObjectModel
foreach ($products AS $product)
if (Product::idIsOnCategoryId($product['id_product'], $categories))
if ($this->cumulable_reduction OR (!$product['reduction_applies'] AND !$product['on_sale']))
$amount += ($useTax ? $product['total_wt'] : $product['total']) * $percentage;
$amount += ($this->include_tax ? $product['total_wt'] : $product['total']) * $percentage;
return $amount;
/* Absolute value */
@@ -322,7 +325,7 @@ class DiscountCore extends ObjectModel
return 0;
$taxDiscount = Cart::getTaxesAverageUsed((int)($cart->id));
if (!$useTax AND isset($taxDiscount) AND $taxDiscount != 1)
if (!$this->include_tax AND isset($taxDiscount) AND $taxDiscount != 1)
$this->value = abs($this->value / (1 + $taxDiscount * 0.01));
// Main return
@@ -483,4 +486,4 @@ class DiscountCore extends ObjectModel
{
return Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'discount` WHERE `id_discount` = '.(int)$id_discount);
}
}
}
+7 -6
View File
@@ -87,7 +87,7 @@ class FrontControllerCore
* Use the Context to access objects instead.
* Example: $this->context->cart
*/
global $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files, $currency;
global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files, $currency;
if (self::$initialized)
return;
@@ -97,7 +97,7 @@ class FrontControllerCore
$this->id_current_shop = Context::getContext()->shop->getID();
$this->id_current_group_shop = Context::getContext()->shop->getGroupID();
$this->css_files = array();
$this->js_files = array();
@@ -105,7 +105,7 @@ class FrontControllerCore
$css_files = $this->css_files;
$js_files = $this->js_files;
if ($this->ssl AND (empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) == 'off') AND Configuration::get('PS_SSL_ENABLED'))
if ($this->ssl AND !Tools::usingSecureMode() AND Configuration::get('PS_SSL_ENABLED'))
{
header('HTTP/1.1 301 Moved Permanently');
header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']);
@@ -127,8 +127,9 @@ class FrontControllerCore
$this->context->smarty->ps_language = $this->context->language;
$protocol_link = (Configuration::get('PS_SSL_ENABLED') OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';
$protocol_content = ((isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';
$protocol_link = (Configuration::get('PS_SSL_ENABLED') OR Tools::usingSecureMode()) ? 'https://' : 'http://';
$useSSL = (isset($this->ssl) AND $this->ssl AND Configuration::get('PS_SSL_ENABLED')) OR Tools::usingSecureMode()?true:false;
$protocol_content = ($useSSL) ? 'https://' : 'http://';
$link = new Link($protocol_link, $protocol_content);
$this->context->link = $link;
@@ -267,7 +268,7 @@ class FrontControllerCore
'page_name' => $page_name,
'base_dir' => _PS_BASE_URL_.__PS_BASE_URI__,
'base_dir_ssl' => $protocol_link.Tools::getShopDomainSsl().__PS_BASE_URI__,
'content_dir' => $protocol_content.Tools::getShopDomain().__PS_BASE_URI__,
'content_dir' => $protocol_content.(($useSSL)?Tools::getShopDomainSsl():Tools::getShopDomain()).__PS_BASE_URI__,
'tpl_dir' => _PS_THEME_DIR_,
'modules_dir' => _MODULE_DIR_,
'mail_dir' => _MAIL_DIR_,
+16 -12
View File
@@ -130,9 +130,10 @@ class MetaCore extends ObjectModel
return false;
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
(int)(Configuration::get('PS_REWRITING_SETTINGS')),
(int)(Configuration::get('PS_HTACCESS_CACHE_CONTROL')),
''
(int)Configuration::get('PS_REWRITING_SETTINGS'),
(int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'),
'',
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
);
}
@@ -141,9 +142,10 @@ class MetaCore extends ObjectModel
if (!parent::add($autodate, $nullValues));
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
(int)(Configuration::get('PS_REWRITING_SETTINGS')),
(int)(Configuration::get('PS_HTACCESS_CACHE_CONTROL')),
''
(int)Configuration::get('PS_REWRITING_SETTINGS'),
(int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'),
'',
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
);
}
@@ -153,9 +155,10 @@ class MetaCore extends ObjectModel
return false;
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
(int)(Configuration::get('PS_REWRITING_SETTINGS')),
(int)(Configuration::get('PS_HTACCESS_CACHE_CONTROL')),
''
(int)Configuration::get('PS_REWRITING_SETTINGS'),
(int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'),
'',
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
);
}
@@ -171,9 +174,10 @@ class MetaCore extends ObjectModel
}
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
(int)(Configuration::get('PS_REWRITING_SETTINGS')),
(int)(Configuration::get('PS_HTACCESS_CACHE_CONTROL')),
''
(int)Configuration::get('PS_REWRITING_SETTINGS'),
(int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'),
'',
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
);
}
+15 -1
View File
@@ -3420,4 +3420,18 @@ class ProductCore extends ObjectModel
return false;
return true;
}
}
/**
* Checks if reference exists
* @return boolean
*/
public function existsRefInDatabase($reference)
{
$row = Db::getInstance()->getRow('
SELECT `reference`
FROM `'._DB_PREFIX_.'product` p
WHERE p.reference = "'.$reference.'"');
return isset($row['reference']);
}
}
+4
View File
@@ -224,6 +224,10 @@ class ToolsCore
*/
public static function usingSecureMode()
{
if (empty($_SERVER['HTTPS'])) {
if(!empty($_SERVER['SSL']))
$_SERVER['HTTPS'] = $_SERVER['SSL'];
}
return !(empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) == 'off');
}