diff --git a/classes/Cart.php b/classes/Cart.php index 224b44a39..14587ef2b 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -959,7 +959,7 @@ class CartCore extends ObjectModel $price = Product::getPriceStatic((int)($product['id_product']), true, (int)($product['id_product_attribute']), 2, NULL, false, true, $product['cart_quantity'], false, ((int)($this->id_customer) ? (int)($this->id_customer) : NULL), (int)($this->id), ((int)($this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) ? (int)($this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) : NULL)); $total_price = Tools::ps_round($price, 2) * (int)($product['cart_quantity']); if (!$withTaxes) - $total_price = Tools::ps_round($total_price / (1 + ($product['rate'] / 100)), 2); + $total_price = Tools::ps_round($total_price / (1 + ((float)(Tax::getProductTaxRate((int)$product['id_product'], (int)$this->{Configuration::get('PS_TAX_ADDRESS_TYPE')})) / 100)), 2); } $order_total += $total_price; } diff --git a/classes/FrontController.php b/classes/FrontController.php index 134a145c7..c8ee702e0 100755 --- a/classes/FrontController.php +++ b/classes/FrontController.php @@ -128,11 +128,11 @@ class FrontControllerCore $this->context->smarty->ps_language = $this->context->language; $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; + $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; - + if ($this->auth AND !$this->context->customer->isLogged($this->guestAllowed)) Tools::redirect('index.php?controller=authentication'.($this->authRedirection ? '&back='.$this->authRedirection : '')); diff --git a/classes/Order.php b/classes/Order.php index 63d4aa9af..e6e8618ea 100644 --- a/classes/Order.php +++ b/classes/Order.php @@ -420,22 +420,30 @@ class OrderCore extends ObjectModel $group_reduction = 1; if ($row['group_reduction'] > 0) - $group_reduction = $row['group_reduction'] / 100; + $group_reduction = 1 - $row['group_reduction'] / 100; - if ($row['reduction_percent']) + if ($row['reduction_percent'] != 0) { if ($this->_taxCalculationMethod == PS_TAX_EXC) - $row['product_price'] = $row['product_price'] - $row['product_price'] * ($row['reduction_percent'] * 0.01 * $group_reduction); + $row['product_price'] = ($row['product_price'] - $row['product_price'] * ($row['reduction_percent'] * 0.01)); else - $row['product_price_wt'] = Tools::ps_round($row['product_price_wt'] - $row['product_price_wt'] * ($row['reduction_percent'] * 0.01 * $group_reduction), 2); + $row['product_price_wt'] = Tools::ps_round(($row['product_price_wt'] - $row['product_price_wt'] * ($row['reduction_percent'] * 0.01)), 2); } - if ($row['reduction_amount']) + if ($row['reduction_amount'] != 0) { if ($this->_taxCalculationMethod == PS_TAX_EXC) - $row['product_price'] = $row['product_price'] - ($row['reduction_amount'] / (1 + $row['tax_rate'] / 100)) * $group_reduction; + $row['product_price'] = ($row['product_price'] - ($row['reduction_amount'] / (1 + $row['tax_rate'] / 100))); else - $row['product_price_wt'] = Tools::ps_round($row['product_price_wt'] - $row['reduction_amount'] * $group_reduction, 2); + $row['product_price_wt'] = Tools::ps_round(($row['product_price_wt'] - $row['reduction_amount']), 2); + } + + if ($row['group_reduction'] > 0) + { + if ($this->_taxCalculationMethod == PS_TAX_EXC) + $row['product_price'] = $row['product_price'] * $group_reduction; + else + $row['product_price_wt'] = Tools::ps_round($row['product_price_wt'] * $group_reduction , 2); } if (($row['reduction_percent'] OR $row['reduction_amount'] OR $row['group_reduction']) AND $this->_taxCalculationMethod == PS_TAX_EXC) @@ -453,6 +461,7 @@ class OrderCore extends ObjectModel $row['total_price'] = $row['product_quantity'] * $row['product_price']; } + /** * Get order products * diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 6168aaa0d..84331d484 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -222,7 +222,7 @@ abstract class PaymentModuleCore extends Module if (!empty($product['ecotax'])) $ecotaxTaxRate = Tax::getProductEcotaxRate($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); - $product_price = (float)Product::getPriceStatic((int)($product['id_product']), false, ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL), (Product::getTaxCalculationMethod((int)($order->id_customer)) == PS_TAX_EXC ? 2 : 6), NULL, false, false, $product['cart_quantity'], false, (int)($order->id_customer), (int)($order->id_cart), (int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), $specificPrice, false); + $product_price = (float)Product::getPriceStatic((int)($product['id_product']), false, ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL), (Product::getTaxCalculationMethod((int)($order->id_customer)) == PS_TAX_EXC ? 2 : 6), NULL, false, false, $product['cart_quantity'], false, (int)($order->id_customer), (int)($order->id_cart), (int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), $specificPrice, true, false); $quantityDiscount = SpecificPrice::getQuantityDiscount((int)$product['id_product'], $this->context->shop->getID(), (int)$cart->id_currency, (int)$vat_address->id_country, (int)$customer->id_default_group, (int)$product['cart_quantity']); $unitPrice = Product::getPriceStatic((int)$product['id_product'], true, ($product['id_product_attribute'] ? intval($product['id_product_attribute']) : NULL), 2, NULL, false, true, 1, false, (int)$order->id_customer, NULL, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); $quantityDiscountValue = $quantityDiscount ? ((Product::getTaxCalculationMethod((int)$order->id_customer) == PS_TAX_EXC ? Tools::ps_round($unitPrice, 2) : $unitPrice) - $quantityDiscount['price'] * (1 + $tax_rate / 100)) : 0.00; diff --git a/classes/Product.php b/classes/Product.php index f7fce0049..6442a03a9 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -3050,8 +3050,18 @@ class ProductCore extends ObjectModel return true; } + + /** + * Checks if the product is in at least one of the submited categories + * + * @param int $id_product + * @param array $categories array of category arrays + * @return boolean is the product in at least one category + */ public static function idIsOnCategoryId($id_product, $categories) { + if (!((int)$id_product > 0) || !is_array($categories) || empty($categories)) + return false; $sql = 'SELECT id_product FROM `'._DB_PREFIX_.'category_product` WHERE `id_product`='.(int)($id_product).' AND `id_category` IN('; foreach ($categories AS $category) $sql .= (int)($category['id_category']).','; diff --git a/classes/ProductDownload.php b/classes/ProductDownload.php index 8804990d1..ab743b0e8 100644 --- a/classes/ProductDownload.php +++ b/classes/ProductDownload.php @@ -88,7 +88,7 @@ class ProductDownloadCore extends ObjectModel public function __construct($id_product_download = NULL) { parent::__construct($id_product_download); - // TODO check if the file is present on hard drive + // @TODO check if the file is present on hard drive } public function delete($deleteFile=false) diff --git a/classes/Tools.php b/classes/Tools.php index 895a8e35e..be88d90e8 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -224,12 +224,14 @@ class ToolsCore */ public static function usingSecureMode() { - if (empty($_SERVER['HTTPS'])) { - if(!empty($_SERVER['SSL'])) - $_SERVER['HTTPS'] = $_SERVER['SSL']; + if (isset($_SERVER['HTTPS'])) + return ($_SERVER['HTTPS'] == 1 || strtolower($_SERVER['HTTPS']) == 'on'); + // $_SERVER['SSL'] exists only in some specific configuration + if (isset($_SERVER['SSL'])) + return ($_SERVER['SSL'] == 1 || strtolower($_SERVER['SSL']) == 'on'); + + return false; } - return !(empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) == 'off'); - } /** * Get the current url prefix protocol (https/http) diff --git a/install-dev/sql/upgrade/1.4.5.0.sql b/install-dev/sql/upgrade/1.4.5.0.sql index e5462a6d6..1dd9af63e 100644 --- a/install-dev/sql/upgrade/1.4.5.0.sql +++ b/install-dev/sql/upgrade/1.4.5.0.sql @@ -13,4 +13,6 @@ AND `id_lang` = ( LIMIT 1 ); -ALTER TABLE `PREFIX_discount` ADD `include_tax` TINYINT(1) NOT NULL DEFAULT '0'; \ No newline at end of file +ALTER TABLE `PREFIX_discount` ADD `include_tax` TINYINT(1) NOT NULL DEFAULT '0'; + +UPDATE `PREFIX_order_detail`set `product_price` = `product_price` /( 1-(`group_reduction`/100)); \ No newline at end of file diff --git a/js/admin-categories-tree.js b/js/admin-categories-tree.js index 3137cc982..c75988e23 100755 --- a/js/admin-categories-tree.js +++ b/js/admin-categories-tree.js @@ -46,6 +46,10 @@ $(document).ready(function(){ }); $('#categories-treeview li#1 span').trigger('click'); + $('#categories-treeview li#1').children('div').remove(); + $('#categories-treeview li#1'). + removeClass('collapsable lastCollapsable'). + addClass('last static'); $('#expand_all').click( function () { expandAllCategories(); @@ -127,6 +131,9 @@ function expandAllCategories() // if no category to expand, no action if (!needExpandAllCategories()) return; + // force to open main category + if ($('li#1').is('.expandable')) + $('li#1').children('span.folder').trigger('click'); readyToExpand = true; if (setCategoryToExpand()) interval = setInterval(openCategory, 10); diff --git a/js/jquery/treeview/jquery.treeview.js b/js/jquery/treeview/jquery.treeview.js index 8cc4ec9f0..668a6ce3b 100755 --- a/js/jquery/treeview/jquery.treeview.js +++ b/js/jquery/treeview/jquery.treeview.js @@ -135,6 +135,9 @@ // handle toggle event function toggler() { + // Added by Prestashop + if ($(this).parent().is('.static')) + return; $(this) .parent() // swap classes for hitarea diff --git a/modules/blocklayered/blocklayered.js b/modules/blocklayered/blocklayered.js index 2d333da2c..46de9e745 100644 --- a/modules/blocklayered/blocklayered.js +++ b/modules/blocklayered/blocklayered.js @@ -171,6 +171,10 @@ function reloadContent(params_plus) return false; }); ajaxCart.overrideButtonsInThePage(); + + if(typeof(reloadProductComparison) == 'function') { + reloadProductComparison(); + } } }); ajaxQueries.push(ajaxQuery); diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index d56d75064..e03716a58 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -1247,7 +1247,8 @@ class BlockLayered extends Module 'nArray' => $nArray = (int)Configuration::get('PS_PRODUCTS_PER_PAGE') != 10 ? array((int)Configuration::get('PS_PRODUCTS_PER_PAGE'), 10, 20, 50) : array(10, 20, 50) ); $this->context->smarty->assign($pagination_infos); - + + $this->context->smarty->assign('comparator_max_item', (int)Configuration::get('PS_COMPARATOR_MAX_ITEM')); $this->context->smarty->assign('products', $products); /* We are sending an array in jSon to the .js controller, it will update both the filters and the products zones */ diff --git a/modules/dibs/config.xml b/modules/dibs/config.xml index 6bc1a08a0..09778362a 100644 --- a/modules/dibs/config.xml +++ b/modules/dibs/config.xml @@ -2,7 +2,7 @@ dibs - + diff --git a/modules/dibs/dibs.php b/modules/dibs/dibs.php index e73ecb2e2..075e21f97 100644 --- a/modules/dibs/dibs.php +++ b/modules/dibs/dibs.php @@ -79,6 +79,7 @@ class dibs extends PaymentModule * @var array */ public static $dibs_subscription_link = array( + 'fr' => 'http://www.dibspayment.com/order/fr_request/', 'en' => 'http://www.dibspayment.com/order/uk_request_2eng', 'da' => 'http://www.dibs.dk/bestil/internet/', 'sv' => 'http://www.dibs.se/bestall/internet/', @@ -89,7 +90,7 @@ class dibs extends PaymentModule { $this->name = 'dibs'; $this->tab = 'payments_gateways'; - $this->version = '1.0'; + $this->version = '1.1'; $this->author = 'PrestaShop'; parent::__construct(); @@ -116,6 +117,13 @@ class dibs extends PaymentModule $this->warning = $this->l('For security reasons, you must set key #1 and key #2 used by MD5 control of DIBS API.'); if (!self::$ID_MERCHANT OR self::$ID_MERCHANT === '') $this->warning = $this->l('You have to set your merchant ID to use DIBS API.'); + + /* For 1.4.3 and less compatibility */ + $updateConfig = array('PS_OS_CHEQUE', 'PS_OS_PAYMENT', 'PS_OS_PREPARATION', 'PS_OS_SHIPPING', 'PS_OS_CANCELED', 'PS_OS_REFUND', 'PS_OS_ERROR', 'PS_OS_OUTOFSTOCK', 'PS_OS_BANKWIRE', 'PS_OS_PAYPAL', 'PS_OS_WS_PAYMENT'); + if (!Configuration::get('PS_OS_PAYMENT')) + foreach ($updateConfig as $u) + if (!Configuration::get($u) && defined('_'.$u.'_')) + Configuration::updateValue($u, constant('_'.$u.'_')); } public function install() @@ -183,8 +191,9 @@ class dibs extends PaymentModule private function _displayPresentation() { $href = ''; - if (isset(dibs::$dibs_subscription_link[Configuration::get('PS_LANG_DEFAULT')])) - $href = dibs::$dibs_subscription_link[Configuration::get('PS_LANG_DEFAULT')]; + $langIsoCode = Language::getIsoById(Configuration::get('PS_LANG_DEFAULT')); + if (isset(dibs::$dibs_subscription_link[$langIsoCode])) + $href = dibs::$dibs_subscription_link[$langIsoCode]; else $href = dibs::$dibs_subscription_link['en']; $out = ' diff --git a/modules/dibs/img/fr.jpg b/modules/dibs/img/fr.jpg new file mode 100755 index 000000000..4cd7f3806 Binary files /dev/null and b/modules/dibs/img/fr.jpg differ diff --git a/modules/gsitemap/gsitemap.php b/modules/gsitemap/gsitemap.php index c072fb9e7..331714554 100644 --- a/modules/gsitemap/gsitemap.php +++ b/modules/gsitemap/gsitemap.php @@ -37,7 +37,7 @@ class Gsitemap extends Module { $this->name = 'gsitemap'; $this->tab = 'seo'; - $this->version = '1.6'; + $this->version = '1.7'; $this->author = 'PrestaShop'; $this->need_instance = 0; @@ -234,7 +234,7 @@ XML; LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_shop ='.$shopID.') LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (p.id_category_default = cl.id_category AND pl.id_lang = cl.id_lang AND cl.id_shop = '.$shopID.') LEFT JOIN '._DB_PREFIX_.'image i ON p.id_product = i.id_product - LEFT JOIN '._DB_PREFIX_.'image_lang il ON (i.id_image = il.id_image AND il.id_lang = pl.id_lang) + LEFT JOIN '._DB_PREFIX_.'image_lang il ON (i.id_image = il.id_image) LEFT JOIN '._DB_PREFIX_.'lang l ON (pl.id_lang = l.id_lang) WHERE l.`active` = 1 AND p.`active` = 1 @@ -243,7 +243,22 @@ XML; ORDER BY pl.id_product, pl.id_lang ASC'; $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); + $tmp = null; + $res = null; foreach($products AS $product) + { + if ($tmp == $product['id_product']) + $res[$tmp]['images'] []= array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']); + else + { + $tmp = $product['id_product']; + $res[$tmp] = $product; + unset($res[$tmp]['id_image'], $res[$tmp]['legend_image']); + $res[$tmp]['images'] []= array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']); + } + } + + foreach ($res as $product) { if (($priority = 0.7 - ($product['level_depth'] / 10)) < 0.1) $priority = 0.1; @@ -316,12 +331,15 @@ XML; private function _addSitemapNodeImage($xml, $product) { - $image = $xml->addChild('image', null, 'http://www.google.com/schemas/sitemap-image/1.1'); - $image->addChild('loc', htmlspecialchars($this->context->link->getImageLink($product['link_rewrite'], (int)$product['id_product'].'-'.(int)$product['id_image'])), 'http://www.google.com/schemas/sitemap-image/1.1'); - - $legend_image = preg_replace('/(&+)/i', '&', $product['legend_image']); - $image->addChild('caption', $legend_image, 'http://www.google.com/schemas/sitemap-image/1.1'); - $image->addChild('title', $legend_image, 'http://www.google.com/schemas/sitemap-image/1.1'); + foreach ($product['images'] as $img) + { + $image = $xml->addChild('image', null, 'http://www.google.com/schemas/sitemap-image/1.1'); + $image->addChild('loc', htmlspecialchars($this->context->link->getImageLink($product['link_rewrite'], (int)$product['id_product'].'-'.(int)$img['id_image'])), 'http://www.google.com/schemas/sitemap-image/1.1'); + + $legend_image = preg_replace('/(&+)/i', '&', $img['legend_image']); + $image->addChild('caption', $legend_image, 'http://www.google.com/schemas/sitemap-image/1.1'); + $image->addChild('title', $legend_image, 'http://www.google.com/schemas/sitemap-image/1.1'); + } } private function _displaySitemap() diff --git a/modules/statslive/statslive.php b/modules/statslive/statslive.php index c10b5b48b..419696d6b 100644 --- a/modules/statslive/statslive.php +++ b/modules/statslive/statslive.php @@ -79,7 +79,7 @@ class StatsLive extends Module */ private function getVisitorsOnline() { - if (Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS')) + if (Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS')) { $sql = 'SELECT c.id_guest, c.ip_address, c.date_add, c.http_referer, pt.name as page FROM `'._DB_PREFIX_.'connections` c @@ -90,7 +90,7 @@ class StatsLive extends Module WHERE (g.id_customer IS NULL OR g.id_customer = 0) '.$this->sqlShopRestriction(false, 'c').' AND cp.`time_end` IS NULL - AND cp.`time_start` > '.strtotime('-15 minutes').' + AND TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900 GROUP BY c.id_connections ORDER BY c.date_add DESC'; } diff --git a/themes/prestashop/js/products-comparison.js b/themes/prestashop/js/products-comparison.js index c9b3a78b5..ed4e4cc1c 100644 --- a/themes/prestashop/js/products-comparison.js +++ b/themes/prestashop/js/products-comparison.js @@ -25,6 +25,10 @@ */ $('document').ready(function(){ + reloadProductComparison(); +}); + +reloadProductComparison = function() { $('a.cmp_remove').click(function(){ var idProduct = $(this).attr('rel').replace('ajax_id_product_', ''); @@ -75,4 +79,4 @@ $('document').ready(function(){ }); } }); -}); \ No newline at end of file +} \ No newline at end of file