first commit
This commit is contained in:
164
modules/pk_favorites/classes/FavoriteProduct.php
Normal file
164
modules/pk_favorites/classes/FavoriteProduct.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* Promokit Favorites Module
|
||||
*
|
||||
* @package alysum
|
||||
* @version 1.0
|
||||
* @author https://promokit.eu
|
||||
* @copyright Copyright Ⓒ 2018 promokit.eu <@email:support@promokit.eu>
|
||||
* @license GNU General Public License version 2
|
||||
*/
|
||||
|
||||
use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever;
|
||||
use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter;
|
||||
use PrestaShop\PrestaShop\Core\Product\ProductListingPresenter;
|
||||
use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever;
|
||||
use PrestaShop\PrestaShop\Adapter\PricesDrop\PricesDropProductSearchProvider;
|
||||
use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext;
|
||||
use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery;
|
||||
use PrestaShop\PrestaShop\Core\Product\Search\SortOrder;
|
||||
|
||||
class FavoriteProduct extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
|
||||
public $id_product;
|
||||
|
||||
public $id_customer;
|
||||
|
||||
public $id_shop;
|
||||
|
||||
public $date_add;
|
||||
|
||||
public $date_upd;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'favorite_product',
|
||||
'primary' => 'id_favorite_product',
|
||||
'fields' => array(
|
||||
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
|
||||
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
|
||||
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
),
|
||||
);
|
||||
|
||||
public static function getFavoriteProducts($id_customer, $id_lang)
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT DISTINCT p.`id_product`, fp.`id_shop`, pl.`description_short`, pl.`link_rewrite`,
|
||||
pl.`name`, i.`id_image`, CONCAT(p.`id_product`, \'-\', i.`id_image`) as image
|
||||
FROM `'._DB_PREFIX_.'favorite_product` fp
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = fp.`id_product`)
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang
|
||||
.Shop::addSqlRestrictionOnLang('pl').'
|
||||
LEFT OUTER JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product`)
|
||||
'.Shop::addSqlAssociation('product_attribute', 'pa', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE product_shop.`active` = 1
|
||||
'.($id_customer ? ' AND fp.id_customer = '.(int)$id_customer : '').'
|
||||
'.Shop::addSqlRestriction(false, 'fp')
|
||||
);
|
||||
}
|
||||
|
||||
public function getFavoriteProductsIDs($id_customer)
|
||||
{
|
||||
$listArr = array();
|
||||
$shop = Context::getContext()->shop;
|
||||
$list = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT id_product FROM '._DB_PREFIX_.'favorite_product WHERE `id_customer` ='.$id_customer.' AND `id_shop` = '.$shop->id);
|
||||
foreach ($list as $prd) {
|
||||
$listArr[] = $prd['id_product'];
|
||||
}
|
||||
return $listArr;
|
||||
}
|
||||
|
||||
public function getFavoriteProduct($id_customer, $id_product, Shop $shop = null)
|
||||
{
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$id_favorite_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT `id_favorite_product`
|
||||
FROM `'._DB_PREFIX_.'favorite_product`
|
||||
WHERE `id_customer` = '.(int)$id_customer.'
|
||||
AND `id_product` = '.(int)$id_product.'
|
||||
AND `id_shop` = '.(int)$shop->id
|
||||
);
|
||||
|
||||
if ($id_favorite_product)
|
||||
return new FavoriteProduct($id_favorite_product);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function isCustomerFavoriteProduct($id_customer, $id_product, Shop $shop = null)
|
||||
{
|
||||
if (!$id_customer)
|
||||
return false;
|
||||
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
return (bool)Db::getInstance()->getValue('
|
||||
SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'favorite_product`
|
||||
WHERE `id_customer` = '.(int)$id_customer.'
|
||||
AND `id_product` = '.(int)$id_product.'
|
||||
AND `id_shop` = '.(int)$shop->id);
|
||||
}
|
||||
|
||||
public function getFavProducts($id_customer)
|
||||
{
|
||||
$list = FavoriteProduct::getFavoriteProductsIDs($id_customer);
|
||||
$p = array();
|
||||
$cntxt = Context::getContext();
|
||||
|
||||
|
||||
foreach ($list as $id) {
|
||||
|
||||
$product = new Product((int)$id, true, $cntxt->language->id, $cntxt->shop->id);
|
||||
|
||||
if (Validate::isLoadedObject($product) && isset($product->name[$cntxt->language->id])) {
|
||||
|
||||
$product = array((array)$product);
|
||||
$product[0]['id_product'] = $product[0]['id'];
|
||||
$p[$id] = FavoriteProduct::prepareBlocksProducts( $product );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $p;
|
||||
}
|
||||
|
||||
public function prepareBlocksProducts($block) {
|
||||
|
||||
$blocks_for_template = [];
|
||||
$products_for_template = [];
|
||||
$cntxt = Context::getContext();
|
||||
|
||||
$assembler = new ProductAssembler($cntxt);
|
||||
$presenterFactory = new ProductPresenterFactory($cntxt);
|
||||
$presentationSettings = $presenterFactory->getPresentationSettings();
|
||||
$presenter = new ProductListingPresenter(new ImageRetriever($cntxt->link), $cntxt->link, new PriceFormatter(), new ProductColorsRetriever(), $cntxt->getTranslator());
|
||||
$products_for_template = [];
|
||||
if ($block){
|
||||
foreach ($block as $key => $rawProduct) {
|
||||
|
||||
$products_for_template[$key] = $presenter->present($presentationSettings, $assembler->assembleProduct($rawProduct), $cntxt->language);
|
||||
$products_for_template[$key]['quantity_wanted'] = 1;
|
||||
if ($products_for_template[$key]['manufacturer_name'] == '') {
|
||||
$products_for_template[$key]['manufacturer_name'] = Manufacturer::getNameById($rawProduct['id_manufacturer']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $products_for_template[0];
|
||||
}
|
||||
}
|
||||
35
modules/pk_favorites/classes/index.php
Normal file
35
modules/pk_favorites/classes/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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 <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
12
modules/pk_favorites/config.xml
Normal file
12
modules/pk_favorites/config.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>pk_favorites</name>
|
||||
<displayName><![CDATA[Favorite Products]]></displayName>
|
||||
<version><![CDATA[1.0]]></version>
|
||||
<description><![CDATA[Display a page featuring the customer's favorite products.]]></description>
|
||||
<author><![CDATA[promokit.eu]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
<is_configurable>0</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
12
modules/pk_favorites/config_pl.xml
Normal file
12
modules/pk_favorites/config_pl.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>pk_favorites</name>
|
||||
<displayName><![CDATA[Favorite Products]]></displayName>
|
||||
<version><![CDATA[1.0]]></version>
|
||||
<description><![CDATA[Display a page featuring the customer's favorite products.]]></description>
|
||||
<author><![CDATA[promokit.eu]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
<is_configurable>0</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
39
modules/pk_favorites/controllers/front/account.php
Normal file
39
modules/pk_favorites/controllers/front/account.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Promokit Menu Module
|
||||
*
|
||||
* @package alysum
|
||||
* @version 1.0
|
||||
* @author https://promokit.eu
|
||||
* @copyright Copyright Ⓒ 2018 promokit.eu <@email:support@promokit.eu>
|
||||
* @license GNU General Public License version 2
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class pk_favoritesAccountModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
public $ssl = true;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
require_once($this->module->getLocalPath().'/classes/FavoriteProduct.php');
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
|
||||
if (!Context::getContext()->customer->isLogged())
|
||||
Tools::redirect('index.php?controller=authentication&redirect=module&module=pk_favorites&action=account');
|
||||
|
||||
if (Context::getContext()->customer->id)
|
||||
{
|
||||
$this->context->smarty->assign('favoriteProducts', FavoriteProduct::getFavProducts(Context::getContext()->customer->id));
|
||||
$this->setTemplate('module:pk_favorites/views/templates/front/pk_favorites-account.tpl');
|
||||
}
|
||||
}
|
||||
}
|
||||
72
modules/pk_favorites/controllers/front/actions.php
Normal file
72
modules/pk_favorites/controllers/front/actions.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Promokit Favorites Module
|
||||
*
|
||||
* @package alysum
|
||||
* @version 1.0
|
||||
* @author https://promokit.eu
|
||||
* @copyright Copyright Ⓒ 2018 promokit.eu <@email:support@promokit.eu>
|
||||
* @license GNU General Public License version 2
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class pk_favoritesActionsModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $id_product;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
require_once($this->module->getLocalPath().'classes/FavoriteProduct.php');
|
||||
$this->id_product = (int)Tools::getValue('id_product');
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::getValue('process') == 'remove')
|
||||
$this->processRemove();
|
||||
else if (Tools::getValue('process') == 'add')
|
||||
$this->processAdd();
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a favorite product
|
||||
*/
|
||||
public function processRemove()
|
||||
{
|
||||
// check if product exists
|
||||
$product = new Product($this->id_product);
|
||||
if (!Validate::isLoadedObject($product))
|
||||
die('0');
|
||||
|
||||
$favorite_product = FavoriteProduct::getFavoriteProduct((int)Context::getContext()->cookie->id_customer, (int)$product->id);
|
||||
if ($favorite_product && $favorite_product->delete())
|
||||
die('0');
|
||||
die(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a favorite product
|
||||
*/
|
||||
public function processAdd()
|
||||
{
|
||||
$product = new Product($this->id_product);
|
||||
// check if product exists
|
||||
if (!Validate::isLoadedObject($product) || FavoriteProduct::isCustomerFavoriteProduct((int)Context::getContext()->cookie->id_customer, (int)$product->id))
|
||||
die('1');
|
||||
$favorite_product = new FavoriteProduct();
|
||||
$favorite_product->id_product = $product->id;
|
||||
$favorite_product->id_customer = (int)Context::getContext()->cookie->id_customer;
|
||||
$favorite_product->id_shop = (int)Context::getContext()->shop->id;
|
||||
if ($favorite_product->add())
|
||||
die('0');
|
||||
die(1);
|
||||
}
|
||||
}
|
||||
35
modules/pk_favorites/controllers/front/index.php
Normal file
35
modules/pk_favorites/controllers/front/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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 <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
35
modules/pk_favorites/controllers/index.php
Normal file
35
modules/pk_favorites/controllers/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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 <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
35
modules/pk_favorites/index.php
Normal file
35
modules/pk_favorites/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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 <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
BIN
modules/pk_favorites/logo.png
Normal file
BIN
modules/pk_favorites/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
26
modules/pk_favorites/pk_favorites-account.php
Normal file
26
modules/pk_favorites/pk_favorites-account.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Promokit Favorites Module
|
||||
*
|
||||
* @package alysum
|
||||
* @version 1.0
|
||||
* @author https://promokit.eu
|
||||
* @copyright Copyright Ⓒ 2018 promokit.eu <@email:support@promokit.eu>
|
||||
* @license GNU General Public License version 2
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated 1.5.0 This file is deprecated, use moduleFrontController instead
|
||||
*/
|
||||
|
||||
/* SSL Management */
|
||||
$useSSL = true;
|
||||
|
||||
require('../../config/config.inc.php');
|
||||
Tools::displayFileAsDeprecated();
|
||||
|
||||
// init front controller in order to use Tools::redirect
|
||||
$controller = new FrontController();
|
||||
$controller->init();
|
||||
|
||||
Tools::redirect(Context::getContext()->link->getModuleLink('pk_favorites', 'account'));
|
||||
49
modules/pk_favorites/pk_favorites-ajax.php
Normal file
49
modules/pk_favorites/pk_favorites-ajax.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Promokit Favorites Module
|
||||
*
|
||||
* @package alysum
|
||||
* @version 1.0
|
||||
* @author https://promokit.eu
|
||||
* @copyright Copyright Ⓒ 2018 promokit.eu <@email:support@promokit.eu>
|
||||
* @license GNU General Public License version 2
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated 1.5.0 This file is deprecated, use moduleFrontController instead
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__).'/../../config/config.inc.php');
|
||||
require_once(dirname(__FILE__).'/../../init.php');
|
||||
include(dirname(__FILE__).'/classes/FavoriteProduct.php');
|
||||
|
||||
if (Tools::getValue('action') && Tools::getValue('id_product') && Context::getContext()->cookie->id_customer)
|
||||
{
|
||||
if (Tools::getValue('action') == 'remove')
|
||||
{
|
||||
// check if product exists
|
||||
$product = new Product((int)Tools::getValue('id_product'));
|
||||
if (!Validate::isLoadedObject($product))
|
||||
die('0');
|
||||
$favorite_product = FavoriteProduct::getFavoriteProduct((int)Context::getContext()->cookie->id_customer, (int)$product->id);
|
||||
if ($favorite_product)
|
||||
if ($favorite_product->delete())
|
||||
die('0');
|
||||
}
|
||||
elseif (Tools::getValue('action') == 'add')
|
||||
{
|
||||
$product = new Product((int)Tools::getValue('id_product'));
|
||||
// check if product exists
|
||||
if (!Validate::isLoadedObject($product)
|
||||
|| FavoriteProduct::isCustomerFavoriteProduct((int)Context::getContext()->cookie->id_customer, (int)$product->id))
|
||||
die('1');
|
||||
$favorite_product = new FavoriteProduct();
|
||||
$favorite_product->id_product = $product->id;
|
||||
$favorite_product->id_customer = (int)Context::getContext()->cookie->id_customer;
|
||||
$favorite_product->id_shop = (int)Context::getContext()->shop->id;
|
||||
if ($favorite_product->add())
|
||||
die('0');
|
||||
}
|
||||
}
|
||||
|
||||
die('1');
|
||||
119
modules/pk_favorites/pk_favorites.php
Normal file
119
modules/pk_favorites/pk_favorites.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* Promokit Menu Module
|
||||
*
|
||||
* @package alysum
|
||||
* @version 5.0
|
||||
* @author https://promokit.eu
|
||||
* @copyright Copyright Ⓒ 2018 promokit.eu <@email:support@promokit.eu>
|
||||
* @license GNU General Public License version 2
|
||||
*/
|
||||
|
||||
if (!defined('_CAN_LOAD_FILES_'))
|
||||
exit;
|
||||
|
||||
class Pk_Favorites extends Module
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'pk_favorites';
|
||||
$this->tab = 'front_office_features';
|
||||
$this->version = '1.0';
|
||||
$this->author = 'promokit.eu';
|
||||
$this->need_instance = 0;
|
||||
|
||||
$this->controllers = array('account');
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->displayName = $this->l('Favorite Products');
|
||||
$this->description = $this->l('Display a page featuring the customer\'s favorite products.');
|
||||
$this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
if (!parent::install()
|
||||
|| !$this->registerHook('displayMyAccountBlock')
|
||||
|| !$this->registerHook('displayCustomerAccount')
|
||||
|| !$this->registerHook('displayMoreButtons')
|
||||
|| !$this->registerHook('displayFavButton')
|
||||
|| !$this->registerHook('displayProductButtons')
|
||||
|| !$this->registerHook('displayHeader'))
|
||||
return false;
|
||||
|
||||
if (!Db::getInstance()->execute('
|
||||
CREATE TABLE `'._DB_PREFIX_.'favorite_product` (
|
||||
`id_favorite_product` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_product` int(10) unsigned NOT NULL,
|
||||
`id_customer` int(10) unsigned NOT NULL,
|
||||
`id_shop` int(10) unsigned NOT NULL,
|
||||
`date_add` datetime NOT NULL,
|
||||
`date_upd` datetime NOT NULL,
|
||||
PRIMARY KEY (`id_favorite_product`))
|
||||
ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
if (!parent::uninstall() || !Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'favorite_product`'))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function hookDisplayCustomerAccount($params)
|
||||
{
|
||||
return $this->fetch('module:'.$this->name.'/views/templates/hook/my-account.tpl');
|
||||
}
|
||||
|
||||
public function hookDisplayMyAccountBlock($params)
|
||||
{
|
||||
return $this->fetch('module:'.$this->name.'/views/templates/hook/my-account.tpl');
|
||||
}
|
||||
|
||||
public function hookdisplayProductButtons($params)
|
||||
{
|
||||
include_once(dirname(__FILE__).'/classes/FavoriteProduct.php');
|
||||
$this->smarty->assign(array(
|
||||
'pid' => Tools::getValue('id_product'),
|
||||
'isCustomerFavoriteProduct' => (FavoriteProduct::isCustomerFavoriteProduct($this->context->customer->id, Tools::getValue('id_product')) ? 1 : 0)
|
||||
));
|
||||
return $this->fetch('module:'.$this->name.'/views/templates/hook/pk_favorites-extra.tpl');
|
||||
}
|
||||
|
||||
public function hookDisplayFavButton($params)
|
||||
{
|
||||
include_once(dirname(__FILE__).'/classes/FavoriteProduct.php');
|
||||
$this->smarty->assign(array(
|
||||
'pid' => $params['product_id'],
|
||||
'isCustomerFavoriteProduct' => (FavoriteProduct::isCustomerFavoriteProduct($this->context->customer->id, $params['product_id']) ? 1 : 0)
|
||||
));
|
||||
return $this->fetch('module:'.$this->name.'/views/templates/hook/pk_favorites-extra.tpl');
|
||||
}
|
||||
|
||||
public function hookDisplayHeader($params)
|
||||
{
|
||||
$this->context->controller->registerStylesheet($this->name, 'modules/'.$this->name.'/views/assets/css/favoriteproducts.css', ['media' => 'all', 'priority' => 150]);
|
||||
$this->context->controller->registerJavascript($this->name, 'modules/'.$this->name.'/views/assets/js/favoriteproducts.js', ['position' => 'bottom', 'priority' => 150]);
|
||||
|
||||
Media::addJsDef(
|
||||
array(
|
||||
'favorites' => array(
|
||||
'favorite_products_url_add' => $this->context->link->getModuleLink('pk_favorites', 'actions', ['process' => 'add']),
|
||||
'favorite_products_url_remove' => $this->context->link->getModuleLink('pk_favorites', 'actions', ['process' => 'remove'], true),
|
||||
'favorite_products_id_product' => Tools::getValue('id_product') ? Tools::getValue('id_product') : false,
|
||||
'phrases' => array(
|
||||
'add' => $this->trans('Add to favorites', array(), 'Modules.Pkfavorites.Pkfavorites'),
|
||||
'remove' => $this->trans('Remove from favorites', array(), 'Modules.Pkfavorites.Pkfavorites'),
|
||||
'added' => $this->trans('The product has been added to your', array(), 'Modules.Pkfavorites.Pkfavorites').' <a href="'.$this->context->link->getModuleLink('pk_favorites', 'account').'">'.$this->trans('favorites', array(), 'Modules.Pkfavorites.Pkfavorites').'</a>',
|
||||
'removed' => $this->trans('The product has been removed from', array(), 'Modules.Pkfavorites.Pkfavorites').' <a href="'.$this->context->link->getModuleLink('pk_favorites', 'account').'">'.$this->trans('favorites', array(), 'Modules.Pkfavorites.Pkfavorites').'</a>',
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
20
modules/pk_favorites/translations/en.php
Normal file
20
modules/pk_favorites/translations/en.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
|
||||
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts_c249aeb21294d5e97598462b550e73eb'] = 'Favorite Products';
|
||||
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts_018770f4456d82ec755cd9d0180e4cce'] = 'Display a page featuring the customer\'s favorite products.';
|
||||
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-account_d95cf4ab2cbf1dfb63f066b50558b07d'] = 'My account';
|
||||
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-account_e5090b68524b1bbfd7983bfa9500b7c9'] = 'My favorite products.';
|
||||
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-account_44fd621c6504b8a5346946650682a842'] = 'No favorite products have been determined just yet. ';
|
||||
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-account_6f16227b3e634872e87b0501948310b6'] = 'Back to your account.';
|
||||
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-extra_8128d66be9351da562f9b01f591e00cd'] = 'Add this product to my list of favorites.';
|
||||
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-extra_b895a379bd5ea51680ead24ee13a1bb7'] = 'Remove this product from my favorite\'s list. ';
|
||||
$_MODULE['<{favoriteproducts}prestashop>my-account_e5090b68524b1bbfd7983bfa9500b7c9'] = 'My favorite products.';
|
||||
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-account_a34e0796b9c15d09300f67d972379722'] = 'My favorite products';
|
||||
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-account_a958dbb46713e59856c35f89e5092a5e'] = 'Back to your account';
|
||||
$_MODULE['<{favoriteproducts}prestashop>my-account_a34e0796b9c15d09300f67d972379722'] = 'My favorite products';
|
||||
|
||||
|
||||
return $_MODULE;
|
||||
35
modules/pk_favorites/translations/index.php
Normal file
35
modules/pk_favorites/translations/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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 <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
0
modules/pk_favorites/translations/pl.php
Normal file
0
modules/pk_favorites/translations/pl.php
Normal file
126
modules/pk_favorites/views/assets/css/favoriteproducts.css
Normal file
126
modules/pk_favorites/views/assets/css/favoriteproducts.css
Normal file
@@ -0,0 +1,126 @@
|
||||
.favoritesButton svg{
|
||||
width:16px;
|
||||
height:16px;
|
||||
margin-right: 5px
|
||||
}
|
||||
.remove-fav.in_progress {animation: unset;background:none}
|
||||
|
||||
.alert_note{
|
||||
position: absolute;
|
||||
color: #333;
|
||||
top: 100%;
|
||||
background: #fff;
|
||||
text-align:center;
|
||||
z-index: 99;
|
||||
display:none;
|
||||
padding: 10px;
|
||||
width: 150px;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 11px;
|
||||
line-height: 16px;
|
||||
}
|
||||
.alert_note a{
|
||||
text-decoration: underline;
|
||||
}
|
||||
.icon-button {
|
||||
font-size: 14px
|
||||
}
|
||||
.box-info-product .wrap_alert{
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
.box-info-product .wrap_alert .alert_note{
|
||||
margin-left: 10px;
|
||||
width: 142px;
|
||||
}
|
||||
.wrap_alert:hover .alert_note {
|
||||
display: block;
|
||||
}
|
||||
.svgic {
|
||||
display: inline-block;
|
||||
fill: currentColor;
|
||||
height: 20px;
|
||||
pointer-events: none;
|
||||
vertical-align: top;
|
||||
width: 20px;
|
||||
}
|
||||
.smooth02{transition:all .2s ease-in-out}
|
||||
.smooth05{transition:all .5s ease-in-out}
|
||||
.in_progress {
|
||||
background-image: url("../svg/loader.svg") !important;
|
||||
background-repeat:no-repeat !important;
|
||||
background-position: 50% 50%;
|
||||
background-size: cover;
|
||||
-webkit-animation: rotation 1s ease-in-out infinite;
|
||||
animation: rotation 1s ease-in-out infinite;
|
||||
}
|
||||
.in_progress use {
|
||||
opacity: 0
|
||||
}
|
||||
.pk-infomessage a {color:inherit;text-decoration: underline;}
|
||||
.pk-infomessage {
|
||||
position: fixed;
|
||||
z-index: 999;
|
||||
top:20px;
|
||||
right:20px;
|
||||
width:300px;
|
||||
}
|
||||
.pk-close-popup {
|
||||
position: absolute;
|
||||
top:10px;
|
||||
right:10px;
|
||||
display: block;
|
||||
}
|
||||
.pk-close-popup svg{
|
||||
width:14px;
|
||||
height: 14px;
|
||||
color:#fff;
|
||||
margin: 0 5px 0 0
|
||||
}
|
||||
.pk-infomessage-item {
|
||||
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.2);
|
||||
margin-bottom: 20px;
|
||||
font-size: 15px;
|
||||
line-height: 22px;
|
||||
}
|
||||
.pk-infomessage-item > div:first-child {
|
||||
padding: 20px;
|
||||
}
|
||||
.pk-infomessage-item.state-error {
|
||||
background-color: #dc5300;
|
||||
color:#fff;
|
||||
}
|
||||
.pk-infomessage-item.state-success {
|
||||
background-color: #03a912;
|
||||
color:#fff;
|
||||
}
|
||||
.pk-infomessage-item.state-info {
|
||||
background-color: #4aaee8;
|
||||
color:#fff;
|
||||
}
|
||||
.pk-close-timer {
|
||||
position: absolute;
|
||||
bottom:0;
|
||||
left:0;
|
||||
width:100%;
|
||||
height: 4px;
|
||||
background-color: rgba(0,0,0,0.3);
|
||||
}
|
||||
.flex-container {
|
||||
display: flex;
|
||||
}
|
||||
.align-items-center {
|
||||
align-items: center
|
||||
}
|
||||
.relative {position: relative;}
|
||||
@-webkit-keyframes rotation{
|
||||
0%{-webkit-transform: rotate(0deg);}
|
||||
100%{-webkit-transform: rotate(360deg);}
|
||||
}
|
||||
@keyframes rotation{
|
||||
0%{transform: rotate(0deg);}
|
||||
100%{transform: rotate(360deg);}
|
||||
}
|
||||
.product-miniature .favoritesButton > span {display: none}
|
||||
.favoritesButton.icon_checked {color:#F39C11;}
|
||||
.favoritesButton.icon_checked > svg {fill:currentColor;}
|
||||
.product-information .wrap_alert {margin-top: 40px}
|
||||
35
modules/pk_favorites/views/assets/css/index.php
Normal file
35
modules/pk_favorites/views/assets/css/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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 <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
35
modules/pk_favorites/views/assets/index.php
Normal file
35
modules/pk_favorites/views/assets/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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 <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
173
modules/pk_favorites/views/assets/js/favoriteproducts.js
Normal file
173
modules/pk_favorites/views/assets/js/favoriteproducts.js
Normal file
@@ -0,0 +1,173 @@
|
||||
(function($) {
|
||||
$.fn.pkPopupFav = function(options) {
|
||||
|
||||
var defaults = {action: 'show', state: 'success', text: 'Success'},
|
||||
options = $.extend(defaults, options),
|
||||
mainclass = 'pk-infomessage',
|
||||
itemclass = 'pk-infomessage-item',
|
||||
closeclass = 'pk-close-popup',
|
||||
timerclass = 'pk-close-timer',
|
||||
closebutton = '<a href="#" class="'+closeclass+'"><svg class="svgic"><use xlink:href="#si-cross"></use></svg></a>',
|
||||
timetoclose = 5000,
|
||||
$parent = $('body'),
|
||||
$th = $(this);
|
||||
|
||||
$parent.on('click', '.'+closeclass, function() {
|
||||
hidePopup($(this));
|
||||
return false;
|
||||
});
|
||||
|
||||
if ($('.'+mainclass).length == 0 ) {
|
||||
$parent.append('<div class="'+mainclass+'"></div>');
|
||||
}
|
||||
|
||||
if (options.action == 'show') {
|
||||
showPopup($th);
|
||||
}
|
||||
|
||||
if (options.action == 'hide') {
|
||||
hidePopup($th);
|
||||
}
|
||||
|
||||
function showPopup($el) {
|
||||
var classes = itemclass+' relative state-'+options.state;
|
||||
$('.'+mainclass).append('<div class="'+classes+'"><div>'+options.text+'</div>'+closebutton+'<div class="'+timerclass+'"></div></div>');
|
||||
$('.'+timerclass).animate({
|
||||
width: "0"
|
||||
}, timetoclose, 'linear', function() {
|
||||
hidePopup($(this));
|
||||
});
|
||||
}
|
||||
|
||||
function hidePopup($el) {
|
||||
$el.parent().animate({
|
||||
height: "0"
|
||||
}, 300, function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
var fButton = 'favoritesButton',
|
||||
removeButton = 'remove-fav';
|
||||
|
||||
$('body').on('click', '.'+fButton, function(){
|
||||
|
||||
if ($(this).hasClass('addToFav')) {
|
||||
addToFavorites($(this), false);
|
||||
}
|
||||
|
||||
if ($(this).hasClass('removeFromFav')) {
|
||||
removeFromFavorites($(this), false);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
$('body').on('click', '.'+removeButton, function(){
|
||||
|
||||
removeFromFavorites($(this), true);
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
// add remove button to favorites page
|
||||
if ( $('#favoriteproducts_block_account')[0] ) {
|
||||
$('#favoriteproducts_block_account .product-miniature').each(function (index, value) {
|
||||
$(this).append('<div class="'+removeButton+' btn"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></div>');
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function ToggleButtonState(button) {
|
||||
|
||||
button.toggleClass('removeFromFav').toggleClass('addToFav').toggleClass('icon_checked');
|
||||
|
||||
}
|
||||
|
||||
function hideProduct(item) {
|
||||
|
||||
item.closest('.product-miniature').slideUp();
|
||||
|
||||
}
|
||||
|
||||
function addToFavorites($th, icon_button) {
|
||||
|
||||
$.ajax({
|
||||
url: favorites.favorite_products_url_add + '&rand=' + new Date().getTime(),
|
||||
type: "POST",
|
||||
headers: { "cache-control": "no-cache" },
|
||||
data: {
|
||||
"id_product": $th.data('pid')
|
||||
},
|
||||
success: function(result){
|
||||
ToggleButtonState($th);
|
||||
$('body').pkPopupFav({state:"success", text: favorites.phrases.added});
|
||||
$th.find('span').text(favorites.phrases.remove);
|
||||
},
|
||||
error: function(){},
|
||||
beforeSend: function(){
|
||||
beforeSendCallback(icon_button, $th);
|
||||
},
|
||||
complete: function(){
|
||||
completeCallback(icon_button, $th);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function removeFromFavorites($th, icon_button) {
|
||||
|
||||
if (icon_button) {
|
||||
pid = $th.parent().data('id-product');
|
||||
} else {
|
||||
pid = $th.data('pid')
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: favorites.favorite_products_url_remove + '&rand=' + new Date().getTime(),
|
||||
type: "POST",
|
||||
headers: { "cache-control": "no-cache" },
|
||||
data: {
|
||||
"id_product": pid
|
||||
},
|
||||
success: function(result){
|
||||
if (icon_button) {
|
||||
hideProduct($th);
|
||||
} else {
|
||||
ToggleButtonState($th);
|
||||
}
|
||||
$('body').pkPopupFav({state:"info", text: favorites.phrases.removed});
|
||||
$th.find('span').text(favorites.phrases.add);
|
||||
},
|
||||
error: function(){},
|
||||
beforeSend: function(){
|
||||
beforeSendCallback(icon_button, $th);
|
||||
},
|
||||
complete: function(){
|
||||
completeCallback(icon_button, $th);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function completeCallback(icon_button, $th) {
|
||||
if (icon_button) {
|
||||
$th.removeClass('in_progress');
|
||||
} else {
|
||||
$th.find('svg').removeClass('in_progress');
|
||||
}
|
||||
}
|
||||
|
||||
function beforeSendCallback(icon_button, $th) {
|
||||
if (icon_button) {
|
||||
$th.addClass('in_progress');
|
||||
} else {
|
||||
$th.find('svg').addClass('in_progress');
|
||||
}
|
||||
}
|
||||
35
modules/pk_favorites/views/assets/js/index.php
Normal file
35
modules/pk_favorites/views/assets/js/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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 <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
2
modules/pk_favorites/views/assets/svg/loader.svg
Normal file
2
modules/pk_favorites/views/assets/svg/loader.svg
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve"><circle cx="50" cy="50" r="50"/><circle fill="#FFF" cx="50" cy="15" r="12.5"/></svg>
|
||||
|
After Width: | Height: | Size: 301 B |
35
modules/pk_favorites/views/index.php
Normal file
35
modules/pk_favorites/views/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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 <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
35
modules/pk_favorites/views/templates/front/index.php
Normal file
35
modules/pk_favorites/views/templates/front/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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 <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
@@ -0,0 +1,28 @@
|
||||
{extends file='customer/page.tpl'}
|
||||
|
||||
{block name='page_title'}
|
||||
{l s='Favorite products' d='Shop.Theme.Customeraccount'}
|
||||
{/block}
|
||||
|
||||
{block name='page_content'}
|
||||
<div id="favoriteproducts_block_account">
|
||||
{if $favoriteProducts}
|
||||
<div id="products" class="view_grid">
|
||||
<div class="product_list">
|
||||
<div class="products row">
|
||||
{foreach from=$favoriteProducts item=favoriteProduct}
|
||||
{include file="catalog/_partials/miniatures/product.tpl" product=$favoriteProduct}
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{else}
|
||||
<p class="warning">{l s='No favorite products have been determined just yet' mod='pk_favorites'}</p>
|
||||
{/if}
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block name='page_footer'}
|
||||
{block name='my_account_links'}
|
||||
{/block}
|
||||
{/block}
|
||||
35
modules/pk_favorites/views/templates/hook/index.php
Normal file
35
modules/pk_favorites/views/templates/hook/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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 <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
4
modules/pk_favorites/views/templates/hook/my-account.tpl
Normal file
4
modules/pk_favorites/views/templates/hook/my-account.tpl
Normal file
@@ -0,0 +1,4 @@
|
||||
<a id="favorites-link" href="{$link->getModuleLink('pk_favorites', 'account')}">
|
||||
<i class="rts" data-size="24" data-color="#000000">{if isset($roythemes.nc_i_fav)}{$roythemes.nc_i_fav}{else}fav1{/if}</i>
|
||||
<span>{l s='Favorites' mod='pk_favorites'}</span>
|
||||
</a>
|
||||
@@ -0,0 +1,67 @@
|
||||
{*
|
||||
* Promokit Favorites Module
|
||||
*
|
||||
* @package alysum
|
||||
* @version 1.0
|
||||
* @author https://promokit.eu
|
||||
* @copyright Copyright Ⓒ 2018 promokit.eu <@email:support@promokit.eu>
|
||||
* @license GNU General Public License version 2
|
||||
*}
|
||||
{assign var="pkfp_text" value=''}
|
||||
{assign var="pkfp_class" value=''}
|
||||
{if !$isCustomerFavoriteProduct AND $customer.is_logged}
|
||||
{assign var="pkfp_text" value={l s='Add to favorites' mod='pk_favorites'}}
|
||||
{assign var="pkfp_class" value='addToFav'}
|
||||
{else if $isCustomerFavoriteProduct AND $customer.is_logged}
|
||||
{assign var="pkfp_text" value={l s='Remove from favorites' mod='pk_favorites'}}
|
||||
{assign var="pkfp_class" value='removeFromFav icon_checked'}
|
||||
{else if !$customer.is_logged}
|
||||
{assign var="pkfp_text" value={l s='Add to favorites' mod='pk_favorites'}}
|
||||
{assign var="pkfp_title" value={l s='You have to login to add product to Favorites' mod='pk_favorites'}}
|
||||
{assign var="pkfp_class" value='loginToAdd'}
|
||||
{/if}
|
||||
{if $pkfp_text != ''}
|
||||
<a href="#" class="{if $page.page_name !== 'product' || ($page.page_name == 'product' && !$customer.is_logged)}tip_inside{/if} {if isset($roythemes.pl_hover_lay) && $roythemes.pl_hover_lay == "2"}action-btn{/if} noeffect flex-container align-items-center favoritesButton icon-button {$pkfp_class}" title="" data-pid="{$pid}">
|
||||
<i class="rts" data-size="24" data-color="#000000">{if isset($roythemes.nc_i_fav)}{$roythemes.nc_i_fav}{else}fav1{/if}</i>
|
||||
|
||||
{if $page.page_name == 'product'}
|
||||
{if !$customer.is_logged}
|
||||
<span>
|
||||
{l s='Add to favorites' mod='pk_favorites'}
|
||||
</span>
|
||||
<span class="tip">
|
||||
{l s='You must be logged in' mod='pk_favorites'}
|
||||
</span>
|
||||
{/if}
|
||||
{if $customer.is_logged}
|
||||
{if $isCustomerFavoriteProduct}
|
||||
<span>
|
||||
{l s='This product is in your Favorites' mod='pk_favorites'}</a>
|
||||
</span>
|
||||
{else}
|
||||
<span>
|
||||
{$pkfp_text}
|
||||
</span>
|
||||
{/if}
|
||||
{/if}
|
||||
{else}
|
||||
{if !$customer.is_logged}
|
||||
<span class="tip">
|
||||
{l s='You must be logged in' mod='pk_favorites'}
|
||||
</span>
|
||||
{/if}
|
||||
{if $customer.is_logged}
|
||||
{if $isCustomerFavoriteProduct}
|
||||
<span class="tip">
|
||||
{l s='This product is in your Favorites' mod='pk_favorites'}</a>
|
||||
</span>
|
||||
{else}
|
||||
<span class="tip">
|
||||
{$pkfp_text}
|
||||
</span>
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
</a>
|
||||
{/if}
|
||||
35
modules/pk_favorites/views/templates/index.php
Normal file
35
modules/pk_favorites/views/templates/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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 <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
Reference in New Issue
Block a user