diff --git a/modules/favoriteproducts/favoriteproducts.js b/modules/favoriteproducts/favoriteproducts.js new file mode 100755 index 000000000..cc6e731d9 --- /dev/null +++ b/modules/favoriteproducts/favoriteproducts.js @@ -0,0 +1,74 @@ +$('document').ready(function(){ + $('#favoriteproducts_block_extra_add').click(function(){ + $.ajax({ + url: favorite_products_url_add, + type: "POST", + data: { + "id_product": favorite_products_id_product + }, + success: function(result){ + if (result == '0') + { + $('#favoriteproducts_block_extra_add').slideUp(function() { + $('#favoriteproducts_block_extra_added').slideDown("slow"); + }); + + } + } + }); + }); + $('#favoriteproducts_block_extra_remove').click(function(){ + $.ajax({ + url: favorite_products_url_remove, + type: "POST", + data: { + "id_product": favorite_products_id_product + }, + success: function(result){ + if (result == '0') + { + $('#favoriteproducts_block_extra_remove').slideUp(function() { + $('#favoriteproducts_block_extra_removed').slideDown("slow"); + }); + + } + } + }); + }); + $('#favoriteproducts_block_extra_added').click(function(){ + $.ajax({ + url: favorite_products_url_remove, + type: "POST", + data: { + "id_product": favorite_products_id_product + }, + success: function(result){ + if (result == '0') + { + $('#favoriteproducts_block_extra_added').slideUp(function() { + $('#favoriteproducts_block_extra_removed').slideDown("slow"); + }); + + } + } + }); + }); + $('#favoriteproducts_block_extra_removed').click(function(){ + $.ajax({ + url: favorite_products_url_add, + type: "POST", + data: { + "id_product": favorite_products_id_product + }, + success: function(result){ + if (result == '0') + { + $('#favoriteproducts_block_extra_removed').slideUp(function() { + $('#favoriteproducts_block_extra_added').slideDown("slow"); + }); + + } + } + }); + }); +}) \ No newline at end of file diff --git a/modules/favoriteproducts/favoriteproducts.php b/modules/favoriteproducts/favoriteproducts.php index 3918eae15..693466390 100644 --- a/modules/favoriteproducts/favoriteproducts.php +++ b/modules/favoriteproducts/favoriteproducts.php @@ -107,6 +107,8 @@ class FavoriteProducts extends Module public function hookDisplayHeader($params) { $this->context->controller->addCSS($this->_path.'favoriteproducts.css', 'all'); + $this->context->controller->addJS($this->_path.'favoriteproducts.js'); + return $this->display(__FILE__, 'favoriteproducts-header.tpl'); } } diff --git a/modules/favoriteproducts/views/templates/hook/favoriteproducts-extra.tpl b/modules/favoriteproducts/views/templates/hook/favoriteproducts-extra.tpl index 3f88271ee..1853069eb 100644 --- a/modules/favoriteproducts/views/templates/hook/favoriteproducts-extra.tpl +++ b/modules/favoriteproducts/views/templates/hook/favoriteproducts-extra.tpl @@ -24,83 +24,6 @@ * International Registered Trademark & Property of PrestaShop SA *} - - {if !$isCustomerFavoriteProduct AND $isLogged}
  • {l s='Add this product to my favorites' mod='favoriteproducts'} diff --git a/modules/favoriteproducts/views/templates/hook/favoriteproducts-header.tpl b/modules/favoriteproducts/views/templates/hook/favoriteproducts-header.tpl new file mode 100755 index 000000000..9da6adc5e --- /dev/null +++ b/modules/favoriteproducts/views/templates/hook/favoriteproducts-header.tpl @@ -0,0 +1,31 @@ +{* +* 2007-2012 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2012 PrestaShop SA +* @version Release: $Revision: 14978 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + + diff --git a/modules/favoriteproducts/views/templates/hook/my-account.tpl b/modules/favoriteproducts/views/templates/hook/my-account.tpl index 3e96ae38c..15d0e12b1 100644 --- a/modules/favoriteproducts/views/templates/hook/my-account.tpl +++ b/modules/favoriteproducts/views/templates/hook/my-account.tpl @@ -25,7 +25,7 @@ *}
  • - + {l s='My favorite products' mod='favorite products'}