This commit is contained in:
2025-04-01 00:38:54 +02:00
parent d4d4c0c09d
commit 87da06293a
22351 changed files with 5168854 additions and 7538 deletions

View File

@@ -0,0 +1,5 @@
2014-04-22 14:58:26 +0200 // blockwishlist: attempt at better wording.
2014-04-07 12:22:33 +0200 // managewishlist: better wording.
2014-03-25 10:21:04 +0100 [-] : Blockwishlist Fix bug #PSCSX-654, could not delete a wishlist
2014-03-24 17:55:14 +0100 // MO blockwishlist : Added ps_versions_compliancy
2014-03-21 10:53:56 +0100 Initial commit

View File

@@ -0,0 +1,16 @@
help:
@egrep "^#" Makefile
# target: docker-build|db - Setup/Build PHP & (node)JS dependencies
db: docker-build
docker-build: build-back build-front
build-back:
docker-compose run --rm php sh -c "composer install"
build-back-prod:
docker-compose run --rm php sh -c "composer install --no-dev -o"
build-front:
docker-compose run --rm node sh -c "npm install"
docker-compose run --rm node sh -c "npm run build"

View File

@@ -0,0 +1,37 @@
# Wishlist block
## About
Adds a block containing the customer\'s wishlists.
## Contributing
PrestaShop modules are open-source extensions to the PrestaShop e-commerce solution. Everyone is welcome and even encouraged to contribute with their own improvements.
### Requirements
Contributors **must** follow the following rules:
* **Make your Pull Request on the "dev" branch**, NOT the "master" branch.
* Do not update the module's version number.
* Follow [the coding standards][1].
### Process in details
Contributors wishing to edit a module's files should follow the following process:
1. Create your GitHub account, if you do not have one already.
2. Fork the blockwishlist project to your GitHub account.
3. Clone your fork to your local machine in the ```/modules``` directory of your PrestaShop installation.
4. Create a branch in your local clone of the module for your changes.
5. Change the files in your branch. Be sure to follow [the coding standards][1]!
6. Push your changed branch to your fork in your GitHub account.
7. Create a pull request for your changes **on the _'dev'_ branch** of the module's project. Be sure to follow [the commit message norm][2] in your pull request. If you need help to make a pull request, read the [Github help page about creating pull requests][3].
8. Wait for one of the core developers either to include your change in the codebase, or to comment on possible improvements you should make to your code.
That's it: you have contributed to this open-source project! Congratulations!
[1]: http://doc.prestashop.com/display/PS16/Coding+Standards
[2]: http://doc.prestashop.com/display/PS16/How+to+write+a+commit+message
[3]: https://help.github.com/articles/using-pull-requests

View File

@@ -0,0 +1,611 @@
<?php
/*
* 2007-2016 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-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class WishList extends ObjectModel
{
/** @var integer Wishlist ID */
public $id;
/** @var integer Customer ID */
public $id_customer;
/** @var integer Token */
public $token;
/** @var integer Name */
public $name;
/** @var string Object creation date */
public $date_add;
/** @var string Object last modification date */
public $date_upd;
/** @var string Object last modification date */
public $id_shop;
/** @var string Object last modification date */
public $id_shop_group;
/** @var integer default */
public $default;
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'wishlist',
'primary' => 'id_wishlist',
'fields' => array(
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'token' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true),
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_shop_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'default' => array('type' => self::TYPE_BOOL, 'validate' => 'isUnsignedId'),
)
);
public function delete()
{
// Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'wishlist_email` WHERE `id_wishlist` = '.(int)($this->id));
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'wishlist_product` WHERE `id_wishlist` = '.(int)($this->id));
if ($this->default)
{
$result = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'wishlist` WHERE `id_customer` = '.(int)$this->id_customer.' AND `id_wishlist` != '.(int)$this->id.' LIMIT 1');
foreach ($result as $res)
Db::getInstance()->update('wishlist', array('default' => '1'), 'id_wishlist = '.(int)$res['id_wishlist']);
}
if (isset($this->context->cookie->id_wishlist))
unset($this->context->cookie->id_wishlist);
return (parent::delete());
}
/**
* Increment counter
*
* @return boolean succeed
*/
public static function incCounter($id_wishlist)
{
if (!Validate::isUnsignedId($id_wishlist))
die (Tools::displayError());
$result = Db::getInstance()->getRow('
SELECT `counter`
FROM `'._DB_PREFIX_.'wishlist`
WHERE `id_wishlist` = '.(int)$id_wishlist
);
if ($result == false || !count($result) || empty($result) === true)
return (false);
return Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'wishlist` SET
`counter` = '.(int)($result['counter'] + 1).'
WHERE `id_wishlist` = '.(int)$id_wishlist
);
}
public static function isExistsByNameForUser($name)
{
if (Shop::getContextShopID())
$shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID();
elseif (Shop::getContextShopGroupID())
$shop_restriction = 'AND id_shop_group = '.(int)Shop::getContextShopGroupID();
else
$shop_restriction = '';
$context = Context::getContext();
return Db::getInstance()->getValue('
SELECT COUNT(*) AS total
FROM `'._DB_PREFIX_.'wishlist`
WHERE `name` = \''.pSQL($name).'\'
AND `id_customer` = '.(int)$context->customer->id.'
'.$shop_restriction
);
}
/**
* Return true if wishlist exists else false
*
* @return boolean exists
*/
public static function exists($id_wishlist, $id_customer, $return = false)
{
if (!Validate::isUnsignedId($id_wishlist) OR
!Validate::isUnsignedId($id_customer))
die (Tools::displayError());
$result = Db::getInstance()->getRow('
SELECT `id_wishlist`, `name`, `token`
FROM `'._DB_PREFIX_.'wishlist`
WHERE `id_wishlist` = '.(int)($id_wishlist).'
AND `id_customer` = '.(int)($id_customer).'
AND `id_shop` = '.(int)Context::getContext()->shop->id);
if (empty($result) === false AND $result != false AND sizeof($result))
{
if ($return === false)
return (true);
else
return ($result);
}
return (false);
}
/**
* Get Customers having a wishlist
*
* @return array Results
*/
public static function getCustomers()
{
$cache_id = 'WhishList::getCustomers';
if (!Cache::isStored($cache_id))
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.`id_customer`, c.`firstname`, c.`lastname`
FROM `'._DB_PREFIX_.'wishlist` w
INNER JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = w.`id_customer`
ORDER BY c.`firstname` ASC'
);
Cache::store($cache_id, $result);
}
return Cache::retrieve($cache_id);
}
/**
* Get ID wishlist by Token
*
* @return array Results
*/
public static function getByToken($token)
{
if (!Validate::isMessage($token))
die (Tools::displayError());
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT w.`id_wishlist`, w.`name`, w.`id_customer`, c.`firstname`, c.`lastname`
FROM `'._DB_PREFIX_.'wishlist` w
INNER JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = w.`id_customer`
WHERE `token` = \''.pSQL($token).'\''));
}
/**
* Get Wishlists by Customer ID
*
* @return array Results
*/
public static function getByIdCustomer($id_customer)
{
if (!Validate::isUnsignedId($id_customer))
die (Tools::displayError());
if (Shop::getContextShopID())
$shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID();
elseif (Shop::getContextShopGroupID())
$shop_restriction = 'AND id_shop_group = '.(int)Shop::getContextShopGroupID();
else
$shop_restriction = '';
$cache_id = 'WhishList::getByIdCustomer_'.(int)$id_customer.'-'.(int)Shop::getContextShopID().'-'.(int)Shop::getContextShopGroupID();
if (!Cache::isStored($cache_id))
{
$result = Db::getInstance()->executeS('
SELECT w.`id_wishlist`, w.`name`, w.`token`, w.`date_add`, w.`date_upd`, w.`counter`, w.`default`
FROM `'._DB_PREFIX_.'wishlist` w
WHERE `id_customer` = '.(int)($id_customer).'
'.$shop_restriction.'
ORDER BY w.`name` ASC');
Cache::store($cache_id, $result);
}
return Cache::retrieve($cache_id);
}
public static function refreshWishList($id_wishlist)
{
$old_carts = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT wp.id_product, wp.id_product_attribute, wpc.id_cart, UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(wpc.date_add) AS timecart
FROM `'._DB_PREFIX_.'wishlist_product_cart` wpc
JOIN `'._DB_PREFIX_.'wishlist_product` wp ON (wp.id_wishlist_product = wpc.id_wishlist_product)
JOIN `'._DB_PREFIX_.'cart` c ON (c.id_cart = wpc.id_cart)
JOIN `'._DB_PREFIX_.'cart_product` cp ON (wpc.id_cart = cp.id_cart)
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.id_cart = c.id_cart)
WHERE (wp.id_wishlist='.(int)($id_wishlist).' AND o.id_cart IS NULL)
HAVING timecart >= 3600*6');
if (isset($old_carts) AND $old_carts != false)
foreach ($old_carts AS $old_cart)
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'cart_product`
WHERE id_cart='.(int)($old_cart['id_cart']).' AND id_product='.(int)($old_cart['id_product']).' AND id_product_attribute='.(int)($old_cart['id_product_attribute'])
);
$freshwish = Db::getInstance()->executeS('
SELECT wpc.id_cart, wpc.id_wishlist_product
FROM `'._DB_PREFIX_.'wishlist_product_cart` wpc
JOIN `'._DB_PREFIX_.'wishlist_product` wp ON (wpc.id_wishlist_product = wp.id_wishlist_product)
JOIN `'._DB_PREFIX_.'cart` c ON (c.id_cart = wpc.id_cart)
LEFT JOIN `'._DB_PREFIX_.'cart_product` cp ON (cp.id_cart = wpc.id_cart AND cp.id_product = wp.id_product AND cp.id_product_attribute = wp.id_product_attribute)
WHERE (wp.id_wishlist = '.(int)($id_wishlist).' AND ((cp.id_product IS NULL AND cp.id_product_attribute IS NULL)))
');
$res = Db::getInstance()->executeS('
SELECT wp.id_wishlist_product, cp.quantity AS cart_quantity, wpc.quantity AS wish_quantity, wpc.id_cart
FROM `'._DB_PREFIX_.'wishlist_product_cart` wpc
JOIN `'._DB_PREFIX_.'wishlist_product` wp ON (wp.id_wishlist_product = wpc.id_wishlist_product)
JOIN `'._DB_PREFIX_.'cart` c ON (c.id_cart = wpc.id_cart)
JOIN `'._DB_PREFIX_.'cart_product` cp ON (cp.id_cart = wpc.id_cart AND cp.id_product = wp.id_product AND cp.id_product_attribute = wp.id_product_attribute)
WHERE wp.id_wishlist='.(int)($id_wishlist)
);
if (isset($res) AND $res != false)
foreach ($res AS $refresh)
if ($refresh['wish_quantity'] > $refresh['cart_quantity'])
{
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'wishlist_product`
SET `quantity`= `quantity` + '.((int)($refresh['wish_quantity']) - (int)($refresh['cart_quantity'])).'
WHERE id_wishlist_product='.(int)($refresh['id_wishlist_product'])
);
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'wishlist_product_cart`
SET `quantity`='.(int)($refresh['cart_quantity']).'
WHERE id_wishlist_product='.(int)($refresh['id_wishlist_product']).' AND id_cart='.(int)($refresh['id_cart'])
);
}
if (isset($freshwish) AND $freshwish != false)
foreach ($freshwish AS $prodcustomer)
{
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'wishlist_product` SET `quantity`=`quantity` +
(
SELECT `quantity` FROM `'._DB_PREFIX_.'wishlist_product_cart`
WHERE `id_wishlist_product`='.(int)($prodcustomer['id_wishlist_product']).' AND `id_cart`='.(int)($prodcustomer['id_cart']).'
)
WHERE `id_wishlist_product`='.(int)($prodcustomer['id_wishlist_product']).' AND `id_wishlist`='.(int)($id_wishlist)
);
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'wishlist_product_cart`
WHERE `id_wishlist_product`='.(int)($prodcustomer['id_wishlist_product']).' AND `id_cart`='.(int)($prodcustomer['id_cart'])
);
}
}
/**
* Get Wishlist products by Customer ID
*
* @return array Results
*/
public static function getProductByIdCustomer($id_wishlist, $id_customer, $id_lang, $id_product = null, $quantity = false)
{
if (!Validate::isUnsignedId($id_customer) OR
!Validate::isUnsignedId($id_lang) OR
!Validate::isUnsignedId($id_wishlist))
die (Tools::displayError());
$products = Db::getInstance()->executeS('
SELECT wp.`id_product`, wp.`quantity`, p.`quantity` AS product_quantity, pl.`name`, wp.`id_product_attribute`, wp.`priority`, pl.link_rewrite, cl.link_rewrite AS category_rewrite
FROM `'._DB_PREFIX_.'wishlist_product` wp
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = wp.`id_product`
'.Shop::addSqlAssociation('product', 'p').'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = wp.`id_product`'.Shop::addSqlRestrictionOnLang('pl').'
LEFT JOIN `'._DB_PREFIX_.'wishlist` w ON w.`id_wishlist` = wp.`id_wishlist`
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON cl.`id_category` = product_shop.`id_category_default` AND cl.id_lang='.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
WHERE w.`id_customer` = '.(int)($id_customer).'
AND pl.`id_lang` = '.(int)($id_lang).'
AND wp.`id_wishlist` = '.(int)($id_wishlist).
(empty($id_product) === false ? ' AND wp.`id_product` = '.(int)($id_product) : '').
($quantity == true ? ' AND wp.`quantity` != 0': '').'
GROUP BY p.id_product, wp.id_product_attribute');
if (empty($products) === true OR !sizeof($products))
return array();
for ($i = 0; $i < sizeof($products); ++$i)
{
if (isset($products[$i]['id_product_attribute']) AND
Validate::isUnsignedInt($products[$i]['id_product_attribute']))
{
$result = Db::getInstance()->executeS('
SELECT al.`name` AS attribute_name, pa.`quantity` AS "attribute_quantity"
FROM `'._DB_PREFIX_.'product_attribute_combination` pac
LEFT JOIN `'._DB_PREFIX_.'attribute` a ON (a.`id_attribute` = pac.`id_attribute`)
LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`)
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)($id_lang).')
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)($id_lang).')
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
'.Shop::addSqlAssociation('product_attribute', 'pa').'
WHERE pac.`id_product_attribute` = '.(int)($products[$i]['id_product_attribute']));
$products[$i]['attributes_small'] = '';
if ($result)
foreach ($result AS $k => $row)
$products[$i]['attributes_small'] .= $row['attribute_name'].', ';
$products[$i]['attributes_small'] = rtrim($products[$i]['attributes_small'], ', ');
if (isset($result[0]))
$products[$i]['attribute_quantity'] = $result[0]['attribute_quantity'];
}
else
$products[$i]['attribute_quantity'] = $products[$i]['product_quantity'];
}
return ($products);
}
/**
* Get Wishlists number products by Customer ID
*
* @return array Results
*/
public static function getInfosByIdCustomer($id_customer)
{
if (Shop::getContextShopID())
$shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID();
elseif (Shop::getContextShopGroupID())
$shop_restriction = 'AND id_shop_group = '.(int)Shop::getContextShopGroupID();
else
$shop_restriction = '';
if (!Validate::isUnsignedId($id_customer))
die (Tools::displayError());
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT SUM(wp.`quantity`) AS nbProducts, wp.`id_wishlist`
FROM `'._DB_PREFIX_.'wishlist_product` wp
INNER JOIN `'._DB_PREFIX_.'wishlist` w ON (w.`id_wishlist` = wp.`id_wishlist`)
WHERE w.`id_customer` = '.(int)($id_customer).'
'.$shop_restriction.'
GROUP BY w.`id_wishlist`
ORDER BY w.`name` ASC'));
}
/**
* Add product to ID wishlist
*
* @return boolean succeed
*/
public static function addProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute, $quantity)
{
if (!Validate::isUnsignedId($id_wishlist) OR
!Validate::isUnsignedId($id_customer) OR
!Validate::isUnsignedId($id_product) OR
!Validate::isUnsignedId($quantity))
die (Tools::displayError());
$result = Db::getInstance()->getRow('
SELECT wp.`quantity`
FROM `'._DB_PREFIX_.'wishlist_product` wp
JOIN `'._DB_PREFIX_.'wishlist` w ON (w.`id_wishlist` = wp.`id_wishlist`)
WHERE wp.`id_wishlist` = '.(int)($id_wishlist).'
AND w.`id_customer` = '.(int)($id_customer).'
AND wp.`id_product` = '.(int)($id_product).'
AND wp.`id_product_attribute` = '.(int)($id_product_attribute));
if (empty($result) === false AND sizeof($result))
{
if (($result['quantity'] + $quantity) <= 0)
return (WishList::removeProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute));
else
return (Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'wishlist_product` SET
`quantity` = '.(int)($quantity + $result['quantity']).'
WHERE `id_wishlist` = '.(int)($id_wishlist).'
AND `id_product` = '.(int)($id_product).'
AND `id_product_attribute` = '.(int)($id_product_attribute)));
}
else
return (Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'wishlist_product` (`id_wishlist`, `id_product`, `id_product_attribute`, `quantity`, `priority`) VALUES(
'.(int)($id_wishlist).',
'.(int)($id_product).',
'.(int)($id_product_attribute).',
'.(int)($quantity).', 1)'));
}
/**
* Update product to wishlist
*
* @return boolean succeed
*/
public static function updateProduct($id_wishlist, $id_product, $id_product_attribute, $priority, $quantity)
{
if (!Validate::isUnsignedId($id_wishlist) OR
!Validate::isUnsignedId($id_product) OR
!Validate::isUnsignedId($quantity) OR
$priority < 0 OR $priority > 2)
die (Tools::displayError());
return (Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'wishlist_product` SET
`priority` = '.(int)($priority).',
`quantity` = '.(int)($quantity).'
WHERE `id_wishlist` = '.(int)($id_wishlist).'
AND `id_product` = '.(int)($id_product).'
AND `id_product_attribute` = '.(int)($id_product_attribute)));
}
/**
* Remove product from wishlist
*
* @return boolean succeed
*/
public static function removeProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute)
{
if (!Validate::isUnsignedId($id_wishlist) OR
!Validate::isUnsignedId($id_customer) OR
!Validate::isUnsignedId($id_product))
die (Tools::displayError());
$result = Db::getInstance()->getRow('
SELECT w.`id_wishlist`, wp.`id_wishlist_product`
FROM `'._DB_PREFIX_.'wishlist` w
LEFT JOIN `'._DB_PREFIX_.'wishlist_product` wp ON (wp.`id_wishlist` = w.`id_wishlist`)
WHERE `id_customer` = '.(int)($id_customer).'
AND w.`id_wishlist` = '.(int)($id_wishlist));
if (empty($result) === true OR
$result === false OR
!sizeof($result) OR
$result['id_wishlist'] != $id_wishlist)
return (false);
// Delete product in wishlist_product_cart
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'wishlist_product_cart`
WHERE `id_wishlist_product` = '.(int)($result['id_wishlist_product'])
);
return Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'wishlist_product`
WHERE `id_wishlist` = '.(int)($id_wishlist).'
AND `id_product` = '.(int)($id_product).'
AND `id_product_attribute` = '.(int)($id_product_attribute)
);
}
/**
* Return bought product by ID wishlist
*
* @return Array results
*/
public static function getBoughtProduct($id_wishlist)
{
if (!Validate::isUnsignedId($id_wishlist))
die (Tools::displayError());
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT wp.`id_product`, wp.`id_product_attribute`, wpc.`quantity`, wpc.`date_add`, cu.`lastname`, cu.`firstname`
FROM `'._DB_PREFIX_.'wishlist_product_cart` wpc
JOIN `'._DB_PREFIX_.'wishlist_product` wp ON (wp.id_wishlist_product = wpc.id_wishlist_product)
JOIN `'._DB_PREFIX_.'cart` ca ON (ca.id_cart = wpc.id_cart)
JOIN `'._DB_PREFIX_.'customer` cu ON (cu.`id_customer` = ca.`id_customer`)
WHERE wp.`id_wishlist` = '.(int)($id_wishlist)));
}
/**
* Add bought product
*
* @return boolean succeed
*/
public static function addBoughtProduct($id_wishlist, $id_product, $id_product_attribute, $id_cart, $quantity)
{
if (!Validate::isUnsignedId($id_wishlist) OR
!Validate::isUnsignedId($id_product) OR
!Validate::isUnsignedId($quantity))
die (Tools::displayError());
$result = Db::getInstance()->getRow('
SELECT `quantity`, `id_wishlist_product`
FROM `'._DB_PREFIX_.'wishlist_product` wp
WHERE `id_wishlist` = '.(int)($id_wishlist).'
AND `id_product` = '.(int)($id_product).'
AND `id_product_attribute` = '.(int)($id_product_attribute));
if (!sizeof($result) OR
($result['quantity'] - $quantity) < 0 OR
$quantity > $result['quantity'])
return (false);
Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'wishlist_product_cart`
WHERE `id_wishlist_product`='.(int)($result['id_wishlist_product']).' AND `id_cart`='.(int)($id_cart)
);
if (Db::getInstance()->NumRows() > 0)
$result2= Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'wishlist_product_cart`
SET `quantity`=`quantity` + '.(int)($quantity).'
WHERE `id_wishlist_product`='.(int)($result['id_wishlist_product']).' AND `id_cart`='.(int)($id_cart)
);
else
$result2 = Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'wishlist_product_cart`
(`id_wishlist_product`, `id_cart`, `quantity`, `date_add`) VALUES(
'.(int)($result['id_wishlist_product']).',
'.(int)($id_cart).',
'.(int)($quantity).',
\''.pSQL(date('Y-m-d H:i:s')).'\')');
if ($result2 === false)
return (false);
return (Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'wishlist_product` SET
`quantity` = '.(int)($result['quantity'] - $quantity).'
WHERE `id_wishlist` = '.(int)($id_wishlist).'
AND `id_product` = '.(int)($id_product).'
AND `id_product_attribute` = '.(int)($id_product_attribute)));
}
/**
* Add email to wishlist
*
* @return boolean succeed
*/
public static function addEmail($id_wishlist, $email)
{
if (!Validate::isUnsignedId($id_wishlist) OR empty($email) OR !Validate::isEmail($email))
return false;
return (Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'wishlist_email` (`id_wishlist`, `email`, `date_add`) VALUES(
'.(int)($id_wishlist).',
\''.pSQL($email).'\',
\''.pSQL(date('Y-m-d H:i:s')).'\')'));
}
/**
* Get email from wishlist
*
* @return Array results
*/
public static function getEmail($id_wishlist, $id_customer)
{
if (!Validate::isUnsignedId($id_wishlist) OR
!Validate::isUnsignedId($id_customer))
die (Tools::displayError());
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT we.`email`, we.`date_add`
FROM `'._DB_PREFIX_.'wishlist_email` we
INNER JOIN `'._DB_PREFIX_.'wishlist` w ON w.`id_wishlist` = we.`id_wishlist`
WHERE we.`id_wishlist` = '.(int)($id_wishlist).'
AND w.`id_customer` = '.(int)($id_customer)));
}
/**
* Return if there is a default already set
*
* @return boolean
*/
public static function isDefault($id_customer)
{
return (Bool)Db::getInstance()->getValue('SELECT * FROM `'._DB_PREFIX_.'wishlist` WHERE `id_customer` = '.$id_customer.' AND `default` = 1');
}
public static function getDefault($id_customer)
{
return Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'wishlist` WHERE `id_customer` = '.$id_customer.' AND `default` = 1');
}
/**
* Set current WishList as default
*
* @return boolean
*/
public function setDefault()
{
if ($default = $this->getDefault($this->id_customer))
Db::getInstance()->update('wishlist', array('default' => '0'), 'id_wishlist = '.$default[0]['id_wishlist']);
return Db::getInstance()->update('wishlist', array('default' => '1'), 'id_wishlist = '.$this->id);
}
};

View File

@@ -0,0 +1,75 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import blockwishlistModule from 'blockwishlistModule';
const tabButtons = document.querySelectorAll('.btn-group button');
const refreshButton = document.querySelector('.js-refresh');
let isLoading = false;
tabButtons.forEach((button) => {
button.addEventListener('click', () => {
if (!button.classList.contains('active')) {
tabButtons.forEach((elem) => {
elem.classList.remove('active');
});
button.classList.add('active');
const tabs = document.querySelectorAll('.wishlist-tab');
tabs.forEach((tab) => {
if (tab.classList.contains('active') && tab.dataset.tab !== button.dataset.tab) {
tab.classList.remove('active');
}
if (tab.dataset.tab === button.dataset.tab) {
tab.classList.add('active');
}
});
}
});
});
refreshButton.addEventListener('click', async () => {
if (!isLoading) {
isLoading = true;
const cacheButton = refreshButton.innerHTML;
refreshButton.innerHTML = '<i class="material-icons">hourglass_empty</i>';
const response = await fetch(`${blockwishlistModule.resetCacheUrl}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json, text/javascript, */*; q=0.01',
},
});
const {success} = await response.json();
if (success) {
location.reload();
} else {
isLoading = false;
refreshButton.innerHTML = cacheButton;
}
}
});

View File

@@ -0,0 +1,22 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import TranslatableInput from '../../../../../admin-dev/themes/new-theme/js/components/translatable-input';
new TranslatableInput();

View File

@@ -0,0 +1,76 @@
.wishlist-stats {
.card {
&-text {
width: 100%;
padding: 10px 30px;
}
}
& &-topbar {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
margin-bottom: 20px;
.btn-group {
border: 1px solid #b7ced3;
border-radius: 3px;
button {
color: #363a41;
font-size: 14px;
letter-spacing: 0;
line-height: 19px;
background: none;
font-weight: 500;
transition: 0.25s ease-out;
&:not(:last-child) {
border-right: 1px solid #b7ced3;
}
&:hover,
&.active {
background-color: #25b9d7;
color: #fff;
}
}
}
.refresh {
color: #6c868e;
font-size: 14px;
font-weight: bold;
letter-spacing: 0;
line-height: 19px;
border: 1px solid #6c868e;
border-radius: 4px;
transition: 0.25s ease-out;
background: none;
&:hover {
background: #6c868e;
color: white;
}
}
}
.wishlist-tab {
display: none;
&.active {
display: block;
}
.column-image {
img {
max-width: 50px;
}
}
.column-conversionRate {
font-weight: bold;
}
}
}

View File

@@ -0,0 +1 @@
.wishlist-stats .card-text{width:100%;padding:10px 30px}.wishlist-stats .wishlist-stats-topbar{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;margin-bottom:20px}.wishlist-stats .wishlist-stats-topbar .btn-group{border:1px solid #b7ced3;border-radius:3px}.wishlist-stats .wishlist-stats-topbar .btn-group button{color:#363a41;font-size:14px;letter-spacing:0;line-height:19px;background:none;font-weight:500;transition:.25s ease-out}.wishlist-stats .wishlist-stats-topbar .btn-group button:not(:last-child){border-right:1px solid #b7ced3}.wishlist-stats .wishlist-stats-topbar .btn-group button:hover,.wishlist-stats .wishlist-stats-topbar .btn-group button.active{background-color:#25b9d7;color:#fff}.wishlist-stats .wishlist-stats-topbar .refresh{color:#6c868e;font-size:14px;font-weight:bold;letter-spacing:0;line-height:19px;border:1px solid #6c868e;border-radius:4px;transition:.25s ease-out;background:none}.wishlist-stats .wishlist-stats-topbar .refresh:hover{background:#6c868e;color:#fff}.wishlist-stats .wishlist-tab{display:none}.wishlist-stats .wishlist-tab.active{display:block}.wishlist-stats .wishlist-tab .column-image img{max-width:50px}.wishlist-stats .wishlist-tab .column-conversionRate{font-weight:bold}/*# sourceMappingURL=backoffice.css.map */

View File

@@ -0,0 +1 @@
{"version":3,"sources":["_stats.scss"],"names":[],"mappings":"AAEI,2BACE,UAAA,CACA,iBAAA,CAIJ,uCACE,YAAA,CACA,6BAAA,CACA,kBAAA,CACA,cAAA,CACA,kBAAA,CAEA,kDACE,wBAAA,CACA,iBAAA,CAEA,yDACE,aAAA,CACA,cAAA,CACA,gBAAA,CACA,gBAAA,CACA,eAAA,CACA,eAAA,CACA,wBAAA,CAEA,0EACE,8BAAA,CAGF,+HAEE,wBAAA,CACA,UAAA,CAKN,gDACE,aAAA,CACA,cAAA,CACA,gBAAA,CACA,gBAAA,CACA,gBAAA,CACA,wBAAA,CACA,iBAAA,CACA,wBAAA,CACA,eAAA,CAEA,sDACE,kBAAA,CACA,UAAA,CAKN,8BACE,YAAA,CAEA,qCACE,aAAA,CAIA,gDACE,cAAA,CAIJ,qDACE,gBAAA","file":"backoffice.css"}

View File

@@ -0,0 +1 @@
@import '_stats';

View File

@@ -0,0 +1,132 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<script>
import EventBus from '@components/EventBus';
import ChooseList from '../ChooseList/ChooseList';
export default {
name: 'AddToWishlist',
components: {
ChooseList,
},
props: {
url: {
type: String,
required: true,
default: '#',
},
},
data() {
return {
value: '',
isHidden: true,
productAttributeId: 0,
productId: 0,
quantity: 0,
};
},
methods: {
/**
* Open and close the modal
*/
toggleModal(forceOpen) {
if (forceOpen === true) {
this.isHidden = false;
} else {
this.isHidden = !this.isHidden;
}
},
/**
* Dispatch an event to the Create component
*/
openNewWishlistModal() {
this.toggleModal();
EventBus.$emit('showCreateWishlist');
},
},
mounted() {
/**
* Register to the event showAddToWishList so others component can open the modal of the current component
*/
EventBus.$on('showAddToWishList', (event) => {
this.toggleModal(
event.detail.forceOpen ? event.detail.forceOpen : null,
);
if (event.detail.productId) {
this.productId = event.detail.productId;
}
if (event.detail.productAttributeId) {
this.productAttributeId = event.detail.productAttributeId;
}
if (event.detail.quantity) {
this.quantity = event.detail.quantity;
}
});
},
};
</script>
<style lang="scss" type="text/scss" scoped>
@import '@scss/_variables';
.wishlist {
&-add-to-new {
cursor: pointer;
transition: 0.2s ease-out;
height: 16px;
width: 79px;
font-size: 14px;
letter-spacing: 0;
line-height: 16px;
&:not([href]):not([tabindex]) {
color: $blue;
}
&:hover {
opacity: 0.7;
}
i {
margin-right: 5px;
vertical-align: middle;
color: $blue;
margin-top: -2px;
font-size: 20px;
}
}
&-add-to {
.modal {
&-body {
padding: 0;
}
&-footer {
text-align: left;
padding: 12px 20px;
}
}
}
}
</style>

View File

@@ -0,0 +1,29 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import initApp from '@components/init';
import AddToWishlist from './AddToWishlist';
const props = [
{
name: 'url',
type: String,
},
];
initApp(AddToWishlist, '.wishlist-add-to', props);

View File

@@ -0,0 +1,230 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<template>
<button
class="wishlist-button-add"
:class="{ 'wishlist-button-product': isProduct }"
@click="addToWishlist"
>
<i
class="material-icons"
v-if="isChecked"
>favorite</i>
<i
class="material-icons"
v-else
>favorite_border</i>
</button>
</template>
<script>
import removeFromList from '@graphqlFiles/mutations/removeFromList';
import prestashop from 'prestashop';
import EventBus from '@components/EventBus';
export default {
name: 'Button',
props: {
url: {
type: String,
required: true,
default: '#',
},
productId: {
type: Number,
required: true,
default: null,
},
productAttributeId: {
type: Number,
required: true,
default: null,
},
checked: {
type: Boolean,
required: false,
default: false,
},
isProduct: {
type: Boolean,
required: false,
default: false,
},
},
data() {
return {
isChecked: this.checked === 'true',
idList: this.listId,
};
},
methods: {
/**
* Toggle the heart on this component, basically if the heart is filled,
* then this product is inside a wishlist, else it's not in a wishlist
*/
toggleCheck() {
this.isChecked = !this.isChecked;
},
/**
* If the product isn't in a wishlist, then open the "AddToWishlist" component modal,
* if he's in a wishlist, then launch a removeFromList mutation to remote the product from a wishlist
*/
async addToWishlist(event) {
event.preventDefault();
const quantity = document.querySelector(
'.product-quantity input#quantity_wanted',
);
if (!prestashop.customer.is_logged) {
EventBus.$emit('showLogin');
return;
}
if (!this.isChecked) {
EventBus.$emit('showAddToWishList', {
detail: {
productId: this.productId,
productAttributeId: parseInt(this.productAttributeId, 10),
forceOpen: true,
quantity: quantity ? parseInt(quantity.value, 10) : 0,
},
});
} else {
const {data} = await this.$apollo.mutate({
mutation: removeFromList,
variables: {
productId: this.productId,
url: this.url,
productAttributeId: this.productAttributeId,
listId: this.idList ? this.idList : this.listId,
},
});
const {removeFromList: response} = data;
EventBus.$emit('showToast', {
detail: {
type: response.success ? 'success' : 'error',
message: response.message,
},
});
if (!response.error) {
this.toggleCheck();
}
}
},
},
mounted() {
/**
* Register to event addedToWishlist to toggle the heart if the product has been added correctly
*/
EventBus.$on('addedToWishlist', (event) => {
if (event.detail.productId === this.productId) {
this.isChecked = true;
this.idList = event.detail.listId;
}
});
// eslint-disable-next-line
const items = productsAlreadyTagged.filter(
(e) => e.id_product === this.productId.toString()
&& e.id_product_attribute === this.productAttributeId.toString(),
);
if (items.length > 0) {
this.isChecked = true;
this.idList = parseInt(items[0].id_wishlist, 10);
}
if (this.isProduct) {
prestashop.on('updateProduct', ({eventType}) => {
if (eventType === 'updatedProductQuantity') {
this.isChecked = false;
}
});
prestashop.on('updatedProduct', (args) => {
const quantity = document.querySelector(
'.product-quantity input#quantity_wanted',
);
this.productAttributeId = args.id_product_attribute;
// eslint-disable-next-line
const itemsFiltered = productsAlreadyTagged.filter(
(e) => e.id_product === this.productId.toString()
&& e.quantity === quantity.value
&& e.id_product_attribute === this.productAttributeId.toString(),
);
if (itemsFiltered.length > 0) {
this.isChecked = true;
this.idList = parseInt(items[0].id_wishlist, 10);
} else {
this.isChecked = false;
}
});
}
},
};
</script>
<style lang="scss" type="text/scss">
.wishlist {
&-button {
&-product {
margin-left: 20px;
}
&-add {
display: flex;
align-items: center;
justify-content: center;
height: 40px;
width: 40px;
min-width: 40px;
padding-top: 3px;
background-color: #ffffff;
box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.2);
border-radius: 50%;
cursor: pointer;
transition: 0.2s ease-out;
border: none;
&:hover {
opacity: 0.7;
}
&:focus {
outline: 0;
}
&:active {
transform: scale(1.2);
}
i {
color: #7a7a7a;
}
}
}
}
</style>

View File

@@ -0,0 +1,51 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import initApp from '@components/init';
import Button from './Button';
const initButtons = () => {
const props = [
{
name: 'url',
type: String,
},
{
name: 'checked',
type: Boolean,
},
{
name: 'productId',
type: Number,
},
{
name: 'productAttributeId',
type: Number,
},
{
name: 'isProduct',
type: Boolean,
},
];
initApp(Button, '.wishlist-button', props);
};
initButtons();
export default initButtons;

View File

@@ -0,0 +1,234 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<template>
<div class="wishlist-chooselist">
<ul class="wishlist-list">
<li
class="wishlist-list-item"
v-for="list of lists"
:key="list.id_wishlist"
@click="select(list.id_wishlist)"
>
<p>
{{ list.name }}
</p>
</li>
</ul>
<ContentLoader
v-if="$apollo.queries.lists.loading"
class="wishlist-list-loader"
height="105"
>
<rect
x="0"
y="12"
rx="3"
ry="0"
width="100%"
height="11"
/>
<rect
x="0"
y="36"
rx="3"
ry="0"
width="100%"
height="11"
/>
<rect
x="0"
y="60"
rx="3"
ry="0"
width="100%"
height="11"
/>
<rect
x="0"
y="84"
rx="3"
ry="0"
width="100%"
height="11"
/>
</ContentLoader>
<p
class="wishlist-list-empty"
v-if="lists && lists.length <= 0 && !$apollo.queries.lists.loading"
>
{{ emptyText }}
</p>
</div>
</template>
<script>
import getLists from '@graphqlFiles/queries/getlists';
import addtolist from '@graphqlFiles/mutations/addtolist';
import EventBus from '@components/EventBus';
import {ContentLoader} from 'vue-content-loader';
/**
* The role of this component is to render a list
* and make the possibility to choose one for the selected product
*/
export default {
name: 'ChooseList',
components: {
ContentLoader,
},
apollo: {
lists: {
query: getLists,
variables() {
return {
url: this.url,
};
},
},
},
props: {
productId: {
type: Number,
required: true,
default: 0,
},
quantity: {
type: Number,
required: true,
default: 0,
},
productAttributeId: {
type: Number,
required: true,
default: 0,
},
url: {
type: String,
required: true,
default: '',
},
emptyText: {
type: String,
required: true,
default: 'No list found',
},
addUrl: {
type: String,
required: true,
default: '',
},
},
methods: {
/**
* Select a list and add the product to it
*
* @param {Int} listId The id of the list selected
* @param {Int} userId The id of the user
* @param {Int} productId The id of the product
*/
async select(listId) {
const {data} = await this.$apollo.mutate({
mutation: addtolist,
variables: {
listId,
url: this.addUrl,
productId: this.productId,
quantity: this.quantity,
productAttributeId: this.productAttributeId,
},
});
const {addToList: response} = data;
/**
* Hide the modal inside the parent
*/
this.$emit('hide');
EventBus.$emit('showToast', {
detail: {
type: response.success ? 'success' : 'error',
message: response.message,
},
});
/**
* Send an event to the Heart the user previously clicked on
*/
EventBus.$emit('addedToWishlist', {
detail: {productId: this.productId, listId},
});
},
},
mounted() {
/**
* Register to the event refetchList so if an other component update it, this one can update his list
*
* @param {String} 'refetchList' The event I decided to create to communicate between VueJS Apps
*/
EventBus.$on('refetchList', () => {
this.$apollo.queries.lists.refetch();
});
},
};
</script>
<style lang="scss" type="text/scss">
@import '@scss/_variables';
.wishlist {
&-list {
max-height: 55vh;
overflow-y: scroll;
border-top: 1px solid #e5e5e5;
border-bottom: 1px solid #e5e5e5;
margin: 0;
&-empty {
font-size: 30;
text-align: center;
padding: 30px;
padding-bottom: 20px;
font-weight: bold;
color: #000;
}
&-item {
padding: 14px 0;
transition: 0.25s ease-out;
cursor: pointer;
&:hover {
background: lighten($blue, 45%);
}
p {
font-size: 14px;
letter-spacing: 0;
color: #232323;
margin-bottom: 0;
line-height: 16px;
padding: 0 40px;
}
}
}
}
</style>

View File

@@ -0,0 +1,160 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<script>
import createList from '@graphqlFiles/mutations/createlist';
import EventBus from '@components/EventBus';
/**
* This component display a modal where you can create a wishlist
*/
export default {
name: 'Create',
props: {
url: {
type: String,
required: true,
default: '#',
},
title: {
type: String,
required: true,
default: 'New wishlist',
},
label: {
type: String,
required: true,
default: 'Wishlist name',
},
placeholder: {
type: String,
required: true,
default: 'Add name',
},
cancelText: {
type: String,
required: true,
default: 'Cancel',
},
lengthText: {
type: String,
required: true,
default: 'List title is too short',
},
createText: {
type: String,
required: true,
default: 'Create',
},
},
data() {
return {
value: '',
isHidden: true,
};
},
methods: {
/**
* Toggle the modal
*/
toggleModal() {
this.isHidden = !this.isHidden;
},
/**
* Launch a createList mutation to create a Wishlist
*/
async createWishlist() {
const titleWithoutSpaces = this.value.replace(/ /g, '');
if (titleWithoutSpaces < 1) {
EventBus.$emit('showToast', {
detail: {
type: 'error',
message: this.lengthText,
},
});
return false;
}
const {data: response} = await this.$apollo.mutate({
mutation: createList,
variables: {
name: this.value,
url: this.url,
},
});
EventBus.$emit('showToast', {
detail: {
type: response.createList.success ? 'success' : 'error',
message: response.createList.message,
},
});
/**
* As this is not a real SPA, we need to inform others VueJS apps that they need to refetch the list
*/
EventBus.$emit('refetchList');
/**
* Finally hide the modal after creating the list
* and reopen the wishlist modal
*/
this.toggleModal();
EventBus.$emit('showAddToWishList', {
detail: {
forceOpen: true,
},
});
return true;
},
},
mounted() {
/**
* Register to the event showCreateWishlist so others components can toggle this modal
*
* @param {String} 'showCreateWishlist'
*/
EventBus.$on('showCreateWishlist', () => {
this.value = '';
this.toggleModal();
});
},
};
</script>
<style lang="scss" type="text/scss" scoped>
.wishlist {
&-create {
.wishlist-modal {
display: block;
opacity: 0;
pointer-events: none;
z-index: 0;
&.show {
opacity: 1;
pointer-events: all;
z-index: 1053;
}
}
}
}
</style>

View File

@@ -0,0 +1,57 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import initApp from '@components/init';
import Create from './Create';
const props = [
{
name: 'url',
type: String,
},
{
name: 'title',
type: String,
},
{
name: 'label',
type: String,
},
{
name: 'productId',
type: Number,
},
{
name: 'placeholder',
type: String,
},
{
name: 'cancelText',
type: String,
},
{
name: 'lengthText',
type: String,
},
{
name: 'createText',
type: String,
},
];
initApp(Create, '.wishlist-create', props);

View File

@@ -0,0 +1,177 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<script>
import deleteList from '@graphqlFiles/mutations/deletelist';
import removeFromList from '@graphqlFiles/mutations/removeFromList';
import EventBus from '@components/EventBus';
/**
* This component display a modal where you can delete a wishlist
*/
export default {
name: 'Delete',
props: {
deleteProductUrl: {
type: String,
required: false,
default: '#',
},
deleteListUrl: {
type: String,
required: false,
default: '#',
},
title: {
type: String,
required: true,
default: 'Delete',
},
titleList: {
type: String,
required: true,
default: 'Delete',
},
placeholder: {
type: String,
required: true,
default: 'This action is irreversible',
},
cancelText: {
type: String,
required: true,
default: 'Cancel',
},
deleteText: {
type: String,
required: true,
default: 'Delete',
},
deleteTextList: {
type: String,
required: true,
default: 'Delete',
},
},
data() {
return {
value: '',
isHidden: true,
listId: null,
listName: '',
productId: null,
productAttributeId: null,
};
},
computed: {
confirmMessage() {
return this.placeholder.replace('%nameofthewishlist%', this.listName);
},
modalTitle() {
return this.productId ? this.title : this.titleList;
},
modalDeleteText() {
return this.productId ? this.deleteText : this.deleteTextList;
},
},
methods: {
/**
* Toggle the modal
*/
toggleModal() {
this.isHidden = !this.isHidden;
},
/**
* Launch a deleteList mutation to delete a Wishlist
*/
async deleteWishlist() {
const {data} = await this.$apollo.mutate({
mutation: this.productId ? removeFromList : deleteList,
variables: {
listId: this.listId,
productId: parseInt(this.productId, 10),
productAttributeId: parseInt(this.productAttributeId, 10),
url: this.productId ? this.deleteProductUrl : this.deleteListUrl,
},
});
const response = data.deleteList
? data.deleteList
: data.removeFromList;
/**
* As this is not a real SPA, we need to inform others VueJS apps that they need to refetch the list
*/
EventBus.$emit('refetchList');
EventBus.$emit('showToast', {
detail: {
type: response.success ? 'success' : 'error',
message: response.message,
},
});
/**
* Finally hide the modal after deleting the list
* and reopen the wishlist modal
*/
this.toggleModal();
},
},
mounted() {
/**
* Register to the event showCreateWishlist so others components can toggle this modal
*
* @param {String} 'showDeleteWishlist'
*/
EventBus.$on('showDeleteWishlist', (event) => {
this.value = '';
this.listId = event.detail.listId;
this.listName = event.detail.listName;
this.productId = null;
this.productAttributeId = null;
if (event.detail.productId) {
this.productId = event.detail.productId;
this.productAttributeId = event.detail.productAttributeId;
}
this.toggleModal();
});
},
};
</script>
<style lang="scss" type="text/scss" scoped>
.wishlist {
&-delete {
.wishlist-modal {
display: block;
opacity: 0;
pointer-events: none;
z-index: 0;
&.show {
opacity: 1;
pointer-events: all;
z-index: 1053;
}
}
}
}
</style>

View File

@@ -0,0 +1,57 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import initApp from '@components/init';
import Delete from './Delete';
const props = [
{
name: 'deleteProductUrl',
type: String,
},
{
name: 'deleteListUrl',
type: String,
},
{
name: 'title',
type: String,
},
{
name: 'titleList',
type: String,
},
{
name: 'placeholder',
type: String,
},
{
name: 'cancelText',
type: String,
},
{
name: 'deleteText',
type: String,
},
{
name: 'deleteTextList',
type: String,
},
];
initApp(Delete, '.wishlist-delete', props);

View File

@@ -0,0 +1,28 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import Vue from 'vue';
import prestashop from 'prestashop';
const EventBus = new Vue();
window.WishlistEventBus = EventBus;
prestashop.emit('wishlistEventBusInit');
export default EventBus;

View File

@@ -0,0 +1,351 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<template>
<div class="wishlist-list-container">
<ul
class="wishlist-list"
v-if="items.length > 0 && items"
v-click-outside="emptyPopups"
>
<li
class="wishlist-list-item"
:key="list.id_wishlist"
v-for="list of items"
:class="{ 'wishlist-list-item-default': list.default }"
>
<a
class="wishlist-list-item-link"
@click="redirectToList(list.listUrl)"
>
<p class="wishlist-list-item-title">
{{ list.name }}
<span v-if="list.nbProducts">({{ list.nbProducts }})</span>
<span v-else>(0)</span>
</p>
<div class="wishlist-list-item-right">
<button
class="wishlist-list-item-actions"
@click.stop="togglePopup(list.id_wishlist)"
v-if="!list.default"
>
<i class="material-icons">more_vert</i>
</button>
<button
@click.stop="toggleShare(list.id_wishlist, list.shareUrl)"
v-if="list.default"
>
<i class="material-icons">share</i>
</button>
<div
class="dropdown-menu show"
v-if="activeDropdowns.includes(list.id_wishlist)"
>
<button @click.stop="toggleRename(list.id_wishlist, list.name)">
{{ renameText }}
</button>
<button
@click.stop="toggleShare(list.id_wishlist, list.shareUrl)"
>
{{ shareText }}
</button>
</div>
<button
@click.stop="toggleDelete(list.id_wishlist, list.name)"
v-if="!list.default"
>
<i class="material-icons">delete</i>
</button>
</div>
</a>
</li>
</ul>
<ContentLoader
v-if="loading"
class="wishlist-list-loader"
height="105"
>
<rect
x="0"
y="12"
rx="3"
ry="0"
width="100%"
height="11"
/>
<rect
x="0"
y="36"
rx="3"
ry="0"
width="100%"
height="11"
/>
<rect
x="0"
y="60"
rx="3"
ry="0"
width="100%"
height="11"
/>
<rect
x="0"
y="84"
rx="3"
ry="0"
width="100%"
height="11"
/>
</ContentLoader>
<p
class="wishlist-list-empty"
v-if="items.length <= 0 && !loading"
>
{{ emptyText }}
</p>
</div>
</template>
<script>
import {ContentLoader} from 'vue-content-loader';
import EventBus from '@components/EventBus';
import wishlistUrl from 'wishlistUrl';
import vClickOutside from 'v-click-outside';
/**
* Dumb component to display the list of Wishlist on a page
*/
export default {
name: 'List',
components: {
ContentLoader,
},
data() {
return {
activeDropdowns: [],
listUrl: wishlistUrl,
};
},
props: {
items: {
type: Array,
default: () => [],
},
renameText: {
type: String,
default: 'Rename',
},
emptyText: {
type: String,
default: '',
},
shareText: {
type: String,
default: 'Share',
},
loading: {
type: Boolean,
default: true,
},
},
methods: {
/**
* Toggle a dropdown with some actions
*
* @param {Int} id The ID of the list which contain this dropdown
*/
togglePopup(id) {
if (this.activeDropdowns.includes(id)) {
this.activeDropdowns = this.activeDropdowns.filter((e) => e !== id);
} else {
this.activeDropdowns = [];
this.activeDropdowns.push(id);
}
},
emptyPopups() {
this.activeDropdowns = [];
},
/**
* Toggle the popup to rename a list
*
* @param {Int} id The list ID so the rename popup know which list to rename
* @param {String} The base title so the rename popup can autofill it
*/
toggleRename(id, title) {
EventBus.$emit('showRenameWishlist', {
detail: {listId: id, title},
});
},
/**
* Toggle the popup to rename a list
*
* @param {Int} id The list ID so the rename popup know which list to rename
* @param {String} The base title so the rename popup can autofill it
*/
toggleShare(id, shareUrl) {
EventBus.$emit('showShareWishlist', {
detail: {listId: id, shareUrl},
});
},
/**
* Toggle the popup to rename a list
*
* @param {Int} id The list ID so the rename popup know which list to rename
* @param {String} The base title so the rename popup can autofill it
*/
toggleDelete(id) {
EventBus.$emit('showDeleteWishlist', {
detail: {listId: id, userId: 1},
});
},
/**
* Redirect to the list URI
*
* @param {String} listUrl The list url
*/
redirectToList(listUrl) {
window.location.href = listUrl;
},
},
directives: {
clickOutside: vClickOutside.directive,
},
};
</script>
<style lang="scss" type="text/scss">
@import '@scss/_variables';
.wishlist {
&-list {
margin-bottom: 0;
&-empty {
font-size: 30;
text-align: center;
padding: 30px;
padding-bottom: 20px;
font-weight: bold;
color: #000;
}
&-loader {
padding: 0 20px;
width: 100%;
}
&-item {
&-default {
border-bottom: 1px solid #0000002e;
}
&:hover {
cursor: pointer;
.wishlist-list-item-title {
color: $blue;
}
}
&-link {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24px 20px;
}
.dropdown-menu {
right: 20px;
left: inherit;
display: flex;
flex-direction: column;
}
&-right {
position: relative;
> button {
transition: 0.25s ease-out;
&:hover {
opacity: 0.6;
}
i {
color: #7a7a7a;
}
}
.dropdown-menu {
box-sizing: border-box;
border: 1px solid #e5e5e5;
border-radius: 4px;
background-color: #ffffff;
box-shadow: 2px 2px 10px 0 rgba(0, 0, 0, 0.2);
padding: 0;
overflow: hidden;
> button {
padding: 10px 20px;
transition: 0.2s ease-out;
text-align: left;
&:hover {
background-color: #f1f1f1;
}
}
}
}
&-title {
color: #232323;
font-size: 16px;
font-weight: bold;
letter-spacing: 0;
line-height: 22px;
margin-bottom: 0;
span {
color: #7a7a7a;
font-size: 16px;
letter-spacing: 0;
line-height: 22px;
font-weight: normal;
margin-left: 5px;
}
}
button {
cursor: pointer;
border: none;
background: none;
&:focus {
outline: 0;
}
}
}
}
}
</style>

View File

@@ -0,0 +1,86 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<script>
import EventBus from '@components/EventBus';
import prestashop from 'prestashop';
/**
* This component display a modal where you can redirect to login page
*/
export default {
name: 'Login',
props: {
cancelText: {
type: String,
required: true,
default: 'Cancel',
},
loginText: {
type: String,
required: true,
default: 'Login',
},
},
data() {
return {
value: '',
isHidden: true,
listId: null,
prestashop,
};
},
methods: {
/**
* Toggle the modal
*/
toggleModal() {
this.isHidden = !this.isHidden;
},
},
mounted() {
/**
* Register to the event showCreateWishlist so others components can toggle this modal
*
* @param {String} 'showDeleteWishlist'
*/
EventBus.$on('showLogin', () => {
this.toggleModal();
});
},
};
</script>
<style lang="scss" type="text/scss" scoped>
.wishlist {
&-login {
.wishlist-modal {
display: block;
opacity: 0;
pointer-events: none;
z-index: 0;
&.show {
opacity: 1;
pointer-events: all;
z-index: 1053;
}
}
}
}
</style>

View File

@@ -0,0 +1,33 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import initApp from '@components/init';
import Login from './Login';
const props = [
{
name: 'loginText',
type: String,
},
{
name: 'cancelText',
type: String,
},
];
initApp(Login, '.wishlist-login', props);

View File

@@ -0,0 +1,87 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<script>
import EventBus from '@components/EventBus';
/**
* Dumb component to display the list of Wishlist on a page
*/
export default {
name: 'Pagination',
data() {
return {
total: null,
minShown: null,
maxShown: null,
pageNumber: 0,
pages: [],
currentPage: null,
display: false,
};
},
methods: {
paginate(page) {
EventBus.$emit('updatePagination', {
page,
});
this.currentPage = page;
},
},
mounted() {
EventBus.$on('paginate', (payload) => {
this.total = payload.detail.total;
this.minShown = payload.detail.minShown;
this.maxShown = payload.detail.maxShown;
this.pageNumber = payload.detail.pageNumber;
this.currentPage = payload.detail.currentPage;
this.pages = payload.detail.pages;
this.display = payload.detail.display;
});
},
};
</script>
<style lang="scss" type="text/scss">
@import '@scss/_variables';
.wishlist {
&-pagination {
.previous {
margin-right: 30px;
}
.js-search-link {
cursor: pointer;
&:not([href]):not([tabindex]):hover {
color: $blue;
}
&.disabled {
cursor: inherit;
&:hover {
color: $blue;
}
}
}
}
}
</style>

View File

@@ -0,0 +1,24 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import initApp from '@components/init';
import Pagination from './Pagination';
const props = [];
initApp(Pagination, '.wishlist-pagination', props);

View File

@@ -0,0 +1,578 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<template>
<div class="wishlist-product">
<a
class="wishlist-product-link"
:href="product.canonical_url"
>
<div class="wishlist-product-image">
<img
v-if="product.default_image"
:src="product.default_image.large.url"
:alt="product.default_image.legend"
:title="product.default_image.legend"
:class="{
'wishlist-product-unavailable': !product.add_to_cart_url
}"
>
<img
v-else-if="product.cover"
:src="product.cover.large.url"
:alt="product.cover.legend"
:title="product.cover.legend"
:class="{
'wishlist-product-unavailable': !product.add_to_cart_url
}"
>
<img
v-else
:src="prestashop.urls.no_picture_image.bySize.home_default.url"
>
<p
class="wishlist-product-availability"
v-if="product.show_availability"
>
<i
class="material-icons"
v-if="product.availability === 'unavailable'"
>
block
</i>
<i
class="material-icons"
v-if="product.availability === 'last_remaining_items'"
>
warning
</i>
{{ product.availability_message }}
</p>
</div>
<div class="wishlist-product-right">
<p class="wishlist-product-title">{{ product.name }}</p>
<p class="wishlist-product-price">
<span
class="wishlist-product-price-promo"
v-if="product.has_discount"
>
{{ product.regular_price }}
</span>
{{ product.price }}
</p>
<div class="wishlist-product-combinations">
<p class="wishlist-product-combinations-text">
<template v-for="(attribute, key, index) of product.attributes">
{{ attribute.group }} : {{ attribute.name }}
<span
:key="key"
v-if="index <= Object.keys(product.attributes).length - 1"
>
-
</span>
<span
:key="key + 'end'"
v-if="index == Object.keys(product.attributes).length - 1"
>
{{ quantityText }} : {{ product.wishlist_quantity }}
</span>
</template>
<span v-if="Object.keys(product.attributes).length === 0">
{{ quantityText }} : {{ product.wishlist_quantity }}
</span>
</p>
<a
:href="product.canonical_url"
v-if="!isShare"
>
<i class="material-icons">create</i>
</a>
</div>
</div>
</a>
<div class="wishlist-product-bottom">
<button
class="btn wishlist-product-addtocart"
:class="{
'btn-secondary': product.customizable === '1',
'btn-primary': product.customizable === '0'
}"
:disabled="isDisabled"
@click="
product.add_to_cart_url || product.customizable === '1'
? addToCartAction()
: null
"
>
<i
class="material-icons shopping-cart"
v-if="product.customizable === '0'"
>
shopping_cart
</i>
{{ product.customizable === '1' ? customizeText : addToCart }}
</button>
<button
class="wishlist-button-add"
v-if="!isShare"
@click="removeFromWishlist"
>
<i class="material-icons">delete</i>
</button>
</div>
<p
class="wishlist-product-availability wishlist-product-availability-responsive"
v-if="product.show_availability"
>
<i
class="material-icons"
v-if="product.availability === 'unavailable'"
>
block
</i>
<i
class="material-icons"
v-if="product.availability === 'last_remaining_items'"
>
warning
</i>
{{ product.availability_message }}
</p>
</div>
</template>
<script>
import EventBus from '@components/EventBus';
import headers from '@constants/headers';
import prestashop from 'prestashop';
import wishlistAddProductToCartUrl from 'wishlistAddProductToCartUrl';
export default {
name: 'Product',
props: {
product: {
type: Object,
required: true,
default: null,
},
listId: {
type: Number,
required: true,
default: null,
},
listName: {
type: String,
required: true,
default: '',
},
isShare: {
type: Boolean,
required: false,
default: false,
},
customizeText: {
type: String,
required: true,
default: 'Customize',
},
quantityText: {
type: String,
required: true,
default: 'Quantity',
},
addToCart: {
type: String,
required: true,
},
status: {
type: Number,
required: false,
default: 0,
},
hasControls: {
type: Boolean,
required: false,
default: true,
},
},
data() {
return {
prestashop,
};
},
computed: {
isDisabled() {
if (this.product.customizable === '1') {
return false;
}
return !this.product.add_to_cart_url;
},
},
methods: {
/**
* Remove the product from the wishlist
*/
async removeFromWishlist() {
EventBus.$emit('showDeleteWishlist', {
detail: {
listId: this.listId,
listName: this.listName,
productId: this.product.id,
productAttributeId: this.product.id_product_attribute,
},
});
},
async addToCartAction() {
if (this.product.add_to_cart_url && this.product.customizable !== '1') {
try {
const datas = new FormData();
datas.append('qty', this.product.wishlist_quantity);
datas.append('id_product', this.product.id_product);
datas.append('id_customization', this.product.id_customization);
const response = await fetch(
`${this.product.add_to_cart_url}&action=update`,
{
method: 'POST',
headers: headers.addToCart,
body: datas,
},
);
const resp = await response.json();
prestashop.emit('updateCart', {
reason: {
idProduct: this.product.id_product,
idProductAttribute: this.product.id_product_attribute,
idCustomization: this.product.id_customization,
linkAction: 'add-to-cart',
},
resp,
});
/* eslint-disable */
const statResponse = await fetch(
`${wishlistAddProductToCartUrl}&params[idWishlist]=${this.listId}&params[id_product]=${this.product.id_product}&params[id_product_attribute]=${this.product.id_product_attribute}&params[quantity]=${this.product.wishlist_quantity}`,
{
headers: {
'Content-Type':
'application/x-www-form-urlencoded; charset=UTF-8',
Accept: 'application/json, text/javascript, */*; q=0.01'
}
}
);
/* eslint-enable */
await statResponse.json();
} catch (error) {
prestashop.emit('handleError', {
eventType: 'addProductToCart',
resp: error,
});
}
} else {
window.location.href = this.product.canonical_url;
}
},
},
};
</script>
<style lang="scss" type="text/scss">
@import '@scss/_variables';
.wishlist {
&-products-item {
margin: 25px;
}
&-product {
max-width: 250px;
width: 100%;
position: relative;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
&-unavailable {
opacity: 0.5;
}
&-availability {
display: flex;
align-items: flex-start;
margin-bottom: 0;
color: #232323;
font-size: 12px;
font-weight: bold;
letter-spacing: 0;
line-height: 17px;
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 17px;
z-index: 5;
min-width: 80%;
justify-content: center;
i {
color: #ff4c4c;
margin-right: 5px;
font-size: 18px;
}
&-responsive {
display: none;
position: inherit;
transform: inherit;
bottom: inherit;
margin-top: 10px;
left: inherit;
}
}
&-link {
&:focus {
text-decoration: none;
}
&:hover {
img {
transform: translate(-50%, -50%) scale(1.1);
}
}
}
&-title {
margin-top: 10px;
margin-bottom: 5px;
color: #737373;
font-size: 14px;
letter-spacing: 0;
line-height: 19px;
}
&-image {
width: 250px;
height: 250px;
position: relative;
overflow: hidden;
img {
position: absolute;
max-width: 100%;
max-height: 100%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
transition: 0.25s ease-out;
}
}
&-price {
color: #232323;
font-size: 16px;
font-weight: bold;
letter-spacing: 0;
line-height: 22px;
&-promo {
text-decoration: line-through;
color: #737373;
font-size: 14px;
font-weight: bold;
letter-spacing: 0;
line-height: 19px;
margin-right: 5px;
vertical-align: middle;
display: inline-block;
margin-top: -3px;
}
}
&-combinations {
display: flex;
align-items: flex-start;
justify-content: space-between;
a {
display: block;
color: #7a7a7a;
&:hover {
color: $blue;
}
}
&-text {
color: #7a7a7a;
font-size: 13px;
letter-spacing: 0;
line-height: 20px;
min-height: 50px;
margin: 0;
}
}
&-addtocart {
width: 100%;
text-transform: inherit;
padding-left: 10px;
&.btn-secondary {
background-color: #dddddd;
&:hover {
background-color: #dddddd;
opacity: 0.7;
}
}
i {
margin-top: -3px;
}
}
}
&-button {
&-add {
position: absolute;
top: 10px;
right: 10px;
display: flex;
align-items: center;
justify-content: center;
height: 40px;
width: 40px;
min-width: 40px;
padding-top: 3px;
background-color: #ffffff;
box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.2);
border-radius: 50%;
cursor: pointer;
transition: 0.2s ease-out;
border: none;
&:hover {
opacity: 0.7;
}
&:focus {
outline: 0;
}
&:active {
transform: scale(1.2);
}
i {
color: #7a7a7a;
margin-top: -2px;
}
}
}
}
@media screen and (max-width: 768px) {
.wishlist {
&-button-add {
position: inherit;
margin-left: 10px;
}
&-products-item {
width: 100%;
margin: 0;
margin-bottom: 30px;
&:not(:last-child) {
margin-bottom: 30px;
}
}
&-product {
margin: 0;
width: 100%;
max-width: 100%;
&-link {
&:hover {
img {
transform: inherit;
}
}
}
&-bottom {
display: flex;
align-items: center;
justify-content: space-between;
}
&-right {
flex: 1;
}
&-availability {
display: none;
&-responsive {
display: block;
min-width: 100%;
justify-content: flex-start;
}
}
&-image {
width: 100px;
height: 100px;
margin-right: 20px;
position: inherit;
img {
position: inherit;
left: inherit;
top: inherit;
transform: inherit;
}
}
&-link {
display: flex;
align-items: flex-start;
}
&-title {
margin-top: 0;
}
}
}
}
</style>

View File

@@ -0,0 +1,133 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<script>
import renameList from '@graphqlFiles/mutations/renamelist';
import EventBus from '@components/EventBus';
/**
* A modal used to rename a list
*/
export default {
name: 'Rename',
props: {
url: {
type: String,
required: true,
default: '#',
},
title: {
type: String,
required: true,
default: 'Rename wishlist',
},
label: {
type: String,
required: true,
default: 'Wishlist name',
},
placeholder: {
type: String,
required: true,
default: 'Rename text',
},
cancelText: {
type: String,
required: true,
default: 'Cancel',
},
renameText: {
type: String,
required: true,
default: 'Rename',
},
},
data() {
return {
value: '',
isHidden: true,
listId: 0,
};
},
methods: {
/**
* Toggle the modal
*/
toggleModal() {
this.isHidden = !this.isHidden;
},
/**
* Launch a renameList mutation, then dispatch an event to everycomponent to refetch the list after renaming it
*
* @param {Int} listId Id of the list to be renamed
*/
async renameWishlist() {
const {data} = await this.$apollo.mutate({
mutation: renameList,
variables: {
name: this.value,
url: this.url,
listId: this.listId,
},
});
const {renameList: response} = data;
EventBus.$emit('refetchList');
EventBus.$emit('showToast', {
detail: {
type: response.success ? 'success' : 'error',
message: response.message,
},
});
this.toggleModal();
},
},
mounted() {
/**
* Register to the showRenameWishlist event so everycomponents can display this modal
*/
EventBus.$on('showRenameWishlist', (event) => {
this.value = event.detail.title;
this.listId = event.detail.listId;
this.toggleModal();
});
},
};
</script>
<style lang="scss" type="text/scss" scoped>
.wishlist {
&-rename {
.wishlist-modal {
display: block;
opacity: 0;
pointer-events: none;
z-index: 0;
&.show {
opacity: 1;
pointer-events: all;
z-index: 1051;
}
}
}
}
</style>

View File

@@ -0,0 +1,49 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import initApp from '@components/init';
import Rename from './Rename';
const props = [
{
name: 'url',
type: String,
},
{
name: 'title',
type: String,
},
{
name: 'label',
type: String,
},
{
name: 'placeholder',
type: String,
},
{
name: 'cancelText',
type: String,
},
{
name: 'renameText',
type: String,
},
];
initApp(Rename, '.wishlist-rename', props);

View File

@@ -0,0 +1,132 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<script>
import EventBus from '@components/EventBus';
/**
* This component display a modal where you can create a wishlist
*/
export default {
name: 'Share',
props: {
url: {
type: String,
required: true,
default: '#',
},
title: {
type: String,
required: true,
default: 'Share wishlist',
},
label: {
type: String,
required: true,
default: 'Share link',
},
cancelText: {
type: String,
required: true,
default: 'Cancel',
},
copyText: {
type: String,
required: true,
default: 'Copy text',
},
copiedText: {
type: String,
required: true,
default: 'Copied',
},
},
data() {
return {
value: '',
isHidden: true,
actionText: '',
};
},
methods: {
/**
* Toggle the modal
*/
toggleModal() {
this.isHidden = !this.isHidden;
},
/**
* Copy the link in the input value
*/
copyLink() {
const shareInput = document.querySelector(
'.wishlist-share .form-control',
);
shareInput.select();
shareInput.setSelectionRange(0, 99999);
document.execCommand('copy');
this.actionText = this.copiedText;
this.toggleModal();
EventBus.$emit('showToast', {
detail: {
type: 'success',
message: 'copyText',
},
});
},
},
mounted() {
this.actionText = this.copyText;
/**
* Register to the event showCreateWishlist so others components can toggle this modal
*
* @param {String} 'showCreateWishlist'
*/
EventBus.$on('showShareWishlist', async (event) => {
this.actionText = this.copyText;
this.value = event.detail.shareUrl;
this.toggleModal();
});
},
};
</script>
<style lang="scss" type="text/scss" scoped>
.wishlist {
&-create {
.wishlist-modal {
display: block;
opacity: 0;
pointer-events: none;
z-index: 0;
&.show {
opacity: 1;
pointer-events: all;
z-index: 1053;
}
}
}
}
</style>

View File

@@ -0,0 +1,49 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import initApp from '@components/init';
import Share from './Share';
const props = [
{
name: 'url',
type: String,
},
{
name: 'title',
type: String,
},
{
name: 'label',
type: String,
},
{
name: 'copyText',
type: String,
},
{
name: 'copiedText',
type: String,
},
{
name: 'cancelText',
type: String,
},
];
initApp(Share, '.wishlist-share', props);

View File

@@ -0,0 +1,150 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<template>
<div
class="wishlist-toast"
:class="[{ isActive: active }, type]"
>
<p class="wishlist-toast-text">
{{ text }}
</p>
</div>
</template>
<script>
import EventBus from '@components/EventBus';
export default {
name: 'Button',
props: {
renameWishlistText: {
type: String,
required: true,
},
addedWishlistText: {
type: String,
required: true,
},
deleteWishlistText: {
type: String,
required: true,
},
createWishlistText: {
type: String,
required: true,
},
deleteProductText: {
type: String,
required: true,
},
copyText: {
type: String,
required: true,
},
},
data() {
return {
text: '',
active: false,
timeout: null,
type: 'basic',
};
},
mounted() {
/**
* Register to an even so every components can show toast
*/
EventBus.$on('showToast', (event) => {
if (event.detail.message) {
if (this[event.detail.message]) {
this.text = this[event.detail.message];
} else {
this.text = event.detail.message;
}
}
this.active = true;
if (this.timeout) {
clearTimeout(this.timeout);
}
this.timeout = setTimeout(() => {
this.active = false;
this.timeout = null;
}, 2500);
this.type = event.detail.type ? event.detail.type : 'basic';
});
},
};
</script>
<style lang="scss" type="text/scss">
.wishlist {
&-toast {
padding: 14px 20px;
box-sizing: border-box;
border: 1px solid #e5e5e5;
border-radius: 4px;
background-color: #ffffff;
box-shadow: 2px 2px 10px 0 rgba(0, 0, 0, 0.2);
position: fixed;
right: 20px;
z-index: 9999;
top: 70px;
transition: 0.2s ease-out;
transform: translateY(-10px);
pointer-events: none;
opacity: 0;
&.success {
background-color: #69b92d;
border-color: #69b92d;
.wishlist-toast-text {
color: white;
}
}
&.error {
background-color: #b9312d;
border-color: #b9312d;
.wishlist-toast-text {
color: white;
}
}
&.isActive {
transform: translateY(0);
pointer-events: all;
opacity: 1;
}
&-text {
color: #232323;
font-size: 14px;
letter-spacing: 0;
line-height: 19px;
margin-bottom: 0;
}
}
}
</style>

View File

@@ -0,0 +1,53 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import initApp from '@components/init';
import Toast from './Toast';
const props = [
{
name: 'renameWishlistText',
type: String,
},
{
name: 'createWishlistText',
type: String,
},
{
name: 'addedWishlistText',
type: String,
},
{
name: 'shareText',
type: String,
},
{
name: 'deleteWishlistText',
type: String,
},
{
name: 'deleteProductText',
type: String,
},
{
name: 'copyText',
type: String,
},
];
initApp(Toast, '.wishlist-toast', props);

View File

@@ -0,0 +1,64 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import apolloClient from '@graphqlFiles/client';
/**
* Init a VueJS application to keep monolith features such as hooks or event the use of twig/smarty
*
* @param {Vue} component The component to be init
* @param {String} componentSelector A selector for querySelectorAll
* @param {Array[Object]} props An array containing Object{name, type} to parse int
*/
export default function initApp(component, componentSelector, props) {
Vue.use(VueApollo);
const apolloProvider = new VueApollo({
defaultClient: apolloClient,
});
const componentElements = document.querySelectorAll(componentSelector);
const ComponentRoot = Vue.extend(component);
const propsData = {};
componentElements.forEach((e) => {
/* eslint-disable */
for (const prop of props) {
if (e.dataset[prop.name]) {
if (prop.type === Number) {
propsData[prop.name] = parseInt(e.dataset[prop.name], 10);
} else if (prop.type === Boolean) {
propsData[prop.name] = e.dataset[prop.name] === 'true';
} else {
propsData[prop.name] = e.dataset[prop.name];
}
}
}
/* eslint-enable */
new ComponentRoot({
el: e,
delimiters: ['((', '))'],
apolloProvider,
propsData,
});
});
}

View File

@@ -0,0 +1,11 @@
const headers = {
addToCart: {
Accept: 'application/json, text/javascript',
},
products: {
'Content-Type': 'application/json',
Accept: 'application/json, text/javascript, */*; q=0.01',
},
};
export default headers;

View File

@@ -0,0 +1,368 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<template>
<div class="wishlist-products-container">
<div class="wishlist-products-container-header">
<h1>
{{ title }}
<span
class="wishlist-products-count"
v-if="products.datas && products.datas.products"
>
({{ products.datas.pagination.total_items }})
</span>
</h1>
<div
class="sort-by-row"
v-if="products.datas"
>
<span class="col-sm-3 col-md-3 hidden-sm-down sort-by">Sort by:</span>
<div class="col-sm-9 col-xs-8 col-md-9 products-sort-order dropdown">
<button
class="btn-unstyle select-title"
rel="nofollow"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
>
{{ currentSort }}
<i class="material-icons float-xs-right">arrow_drop_down</i>
</button>
<div class="dropdown-menu">
<a
rel="nofollow"
@click="changeSelectedSort(sort)"
class="select-list js-search-link"
:key="key"
v-for="(sort, key) in productList"
>
{{ sort.label }}
</a>
</div>
</div>
</div>
</div>
<section
id="content"
class="page-content card card-block"
>
<ul
class="wishlist-products-list"
v-if="products.datas && products.datas.products.length > 0"
>
<li
class="wishlist-products-item"
v-for="(product, key) in products.datas.products"
:key="key"
>
<Product
:product="product"
:add-to-cart="addToCart"
:customize-text="customizeText"
:quantity-text="quantityText"
:list-name="title"
:list-id="
listId ? listId : parseInt(currentWishlist.id_wishlist, 10)
"
:is-share="share"
/>
</li>
</ul>
<ContentLoader
v-if="!products.datas"
class="wishlist-list-loader"
height="105"
>
<rect
x="0"
y="12"
rx="3"
ry="0"
width="100%"
height="11"
/>
<rect
x="0"
y="36"
rx="3"
ry="0"
width="100%"
height="11"
/>
<rect
x="0"
y="60"
rx="3"
ry="0"
width="100%"
height="11"
/>
<rect
x="0"
y="84"
rx="3"
ry="0"
width="100%"
height="11"
/>
</ContentLoader>
<p
class="wishlist-list-empty"
v-if="products.datas && products.datas.products.length <= 0"
>
{{ noProductsMessage }}
</p>
</section>
</div>
</template>
<script>
import Product from '@components/Product/Product';
import getProducts from '@graphqlFiles/queries/getproducts';
import {ContentLoader} from 'vue-content-loader';
import EventBus from '@components/EventBus';
/**
* This component act as a smart component wich will handle every actions of the list one
*/
export default {
name: 'ProductsListContainer',
components: {
Product,
ContentLoader,
},
apollo: {
products: {
query: getProducts,
variables() {
return {
listId: this.listId,
url: this.apiUrl,
};
},
skip() {
return true;
},
fetchPolicy: 'network-only',
},
},
props: {
url: {
type: String,
required: false,
default: '#',
},
title: {
type: String,
required: true,
},
noProductsMessage: {
type: String,
required: true,
},
listId: {
type: Number,
required: false,
default: 0,
},
addToCart: {
type: String,
required: true,
},
share: {
type: Boolean,
required: true,
},
customizeText: {
type: String,
required: true,
},
quantityText: {
type: String,
required: true,
},
},
data() {
return {
products: [],
currentWishlist: {},
apiUrl: window.location.href,
selectedSort: '',
};
},
methods: {
/**
* Sort by the select drop down
* @param {String} value The value selected
*/
async changeSelectedSort(value) {
this.selectedSort = value.label;
this.apiUrl = value.url;
},
},
computed: {
productList() {
const productList = this.products.datas.sort_orders.filter(
(sort) => sort.label !== this.products.datas.sort_selected,
);
return productList;
},
currentSort() {
return this.selectedSort !== ''
? this.selectedSort
: this.products.datas.sort_selected;
},
},
mounted() {
if (this.listId) {
this.$apollo.queries.products.skip = false;
}
/**
* Register to the event refetchProducts so if an other component update it, this one can update his list
*
* @param {String} 'refetchProduct' The event I decided to create to communicate between VueJS Apps
*/
EventBus.$on('refetchList', () => {
this.$apollo.queries.products.refetch();
});
EventBus.$on('updatePagination', (payload) => {
this.products = false;
this.apiUrl = payload.page.url;
});
},
};
</script>
<style lang="scss" type="text/scss">
@import '@scss/_variables';
.wishlist {
&-list-loader {
padding: 0 20px;
width: 100%;
}
&-list-empty {
font-size: 30;
text-align: center;
padding: 30px;
padding-bottom: 20px;
font-weight: bold;
color: #000;
}
&-products-container {
.sort-by-row {
min-width: 315px;
display: flex;
align-items: center;
a {
cursor: pointer;
}
.sort-by {
padding: 0;
}
.products-sort-order {
padding: 0;
}
}
&-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20px;
}
@at-root #main & .card.page-content {
padding: 0;
margin-bottom: 12px;
}
}
&-products {
&-list {
display: flex;
flex-wrap: wrap;
margin: -25px;
padding: 20px 45px;
margin-top: 0;
}
&-count {
color: #7a7a7a;
font-size: 22px;
font-weight: normal;
line-height: 30px;
}
}
}
#view {
#wrapper .container {
width: 975px;
}
}
@media screen and (max-width: 768px) {
.wishlist {
&-products-container {
&-header {
flex-wrap: wrap;
.products-sort-order {
flex: 1;
}
.filter-button {
width: auto;
padding-right: 0;
}
.sort-by-row {
width: 100%;
}
}
.page-content.card {
box-shadow: 2px 2px 8px 0 rgba(0, 0, 0, 0.2);
background-color: #fff;
margin-top: 20px;
}
.wishlist-products-list {
justify-content: center;
margin: 0;
padding: 15px;
}
}
}
}
</style>

View File

@@ -0,0 +1,69 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import initApp from '@components/init';
import ProductsListContainer from './ProductsListContainer.vue';
const props = [
{
name: 'url',
type: String,
},
{
name: 'title',
type: String,
},
{
name: 'noProductsMessage',
type: String,
},
{
name: 'addToCart',
type: String,
},
{
name: 'customizeText',
type: String,
},
{
name: 'wishlistProducts',
type: String,
},
{
name: 'wishlist',
type: String,
},
{
name: 'share',
type: Boolean,
},
{
name: 'quantityText',
type: String,
},
{
name: 'filter',
type: String,
},
{
name: 'listId',
type: Number,
},
];
initApp(ProductsListContainer, '.wishlist-products-container', props);

View File

@@ -0,0 +1,177 @@
<!--**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*-->
<template>
<div class="wishlist-container">
<div class="wishlist-container-header">
<h1>{{ title }}</h1>
<a
@click="openNewWishlistModal"
class="wishlist-add-to-new"
>
<i class="material-icons">add_circle_outline</i>
{{ addText }}
</a>
</div>
<section
id="content"
class="page-content card card-block"
>
<list
:items="lists"
:rename-text="renameText"
:share-text="shareText"
:empty-text="emptyText"
:loading="$apollo.queries.lists.loading"
/>
</section>
</div>
</template>
<script>
import List from '@components/List/List';
import getLists from '@graphqlFiles/queries/getlists';
import EventBus from '@components/EventBus';
/**
* This component act as a smart component wich will handle every actions of the list one
*/
export default {
name: 'WishlistContainer',
components: {
List,
},
apollo: {
lists: {
query: getLists,
variables() {
return {
url: this.url,
};
},
},
},
props: {
url: {
type: String,
required: true,
},
title: {
type: String,
required: true,
},
addText: {
type: String,
required: true,
},
renameText: {
type: String,
required: true,
},
emptyText: {
type: String,
required: true,
},
shareText: {
type: String,
required: true,
},
},
data() {
return {
lists: [],
};
},
methods: {
/**
* Send an event to opoen the Create Wishlist Modal
*/
openNewWishlistModal() {
EventBus.$emit('showCreateWishlist');
},
},
mounted() {
/**
* Register to the event refetchList so if an other component update it, this one can update his list
*
* @param {String} 'refetchList' The event I decided to create to communicate between VueJS Apps
*/
EventBus.$on('refetchList', () => {
this.$apollo.queries.lists.refetch();
});
},
};
</script>
<style lang="scss" type="text/scss" scoped>
@import '@scss/_variables';
.wishlist {
&-container {
&-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20px;
}
@at-root #main & .card.page-content {
padding: 0;
margin-bottom: 12px;
}
}
&-add-to-new {
cursor: pointer;
transition: 0.2s ease-out;
font-size: 14px;
letter-spacing: 0;
line-height: 16px;
&:not([href]):not([tabindex]) {
color: $blue;
}
&:hover {
opacity: 0.7;
}
i {
margin-right: 5px;
vertical-align: middle;
color: $blue;
margin-top: -2px;
font-size: 20px;
}
}
}
@media screen and (max-width: 768px) {
.wishlist {
&-container {
.page-content.card {
box-shadow: 2px 2px 8px 0 rgba(0, 0, 0, 0.2);
background-color: #fff;
margin-top: 20px;
}
}
}
}
</style>

View File

@@ -0,0 +1,53 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import initApp from '@components/init';
import WishlistContainer from './WishlistContainer';
const props = [
{
name: 'url',
type: String,
},
{
name: 'title',
type: String,
},
{
name: 'addText',
type: String,
},
{
name: 'renameText',
type: String,
},
{
name: 'emptyText',
type: String,
},
{
name: 'homeLink',
type: String,
},
{
name: 'shareText',
type: String,
},
];
initApp(WishlistContainer, '.wishlist-container', props);

View File

@@ -0,0 +1,36 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import {ApolloClient} from 'apollo-client';
import {SchemaLink} from 'apollo-link-schema';
import {InMemoryCache} from 'apollo-cache-inmemory';
import link from './link';
/**
* Enabling client side cache
*/
const cache = new InMemoryCache();
/**
* Creating the ApolloClient managing cache and schemas
*/
export default new ApolloClient({
link: new SchemaLink({schema: link}),
cache,
});

View File

@@ -0,0 +1,31 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import {makeExecutableSchema} from 'graphql-tools';
import resolvers from './resolvers';
import typeDefs from './types';
/**
* Generate SchemaLink that ApolloClient needs to understand schemas
* and link resolvers to schemas
*/
export default makeExecutableSchema({
typeDefs,
resolvers,
});

View File

@@ -0,0 +1,35 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import gql from 'graphql-tag';
export default gql`
mutation addToList($listId: Int!, $productId: Int!, $quantity: Int!, $productAttributeId: Int!, $url: String!) {
addToList(
listId: $listId
productId: $productId
quantity: $quantity
productAttributeId: $productAttributeId
url: $url
) {
success
message
}
}
`;

View File

@@ -0,0 +1,33 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import gql from 'graphql-tag';
export default gql`
mutation createList($name: String!, $url: String!) {
createList(name: $name, url: $url) {
message
datas {
name
id_wishlist
}
success
}
}
`;

View File

@@ -0,0 +1,29 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import gql from 'graphql-tag';
export default gql`
mutation deleteList($listId: Int!, $url: String!) {
deleteList(listId: $listId, url: $url) {
success
message
}
}
`;

View File

@@ -0,0 +1,29 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import gql from 'graphql-tag';
export default gql`
mutation removeFromList($listId: Int!, $productId: Int!, $productAttributeId: Int!, $url: String!) {
removeFromList(listId: $listId, productId: $productId, productAttributeId: $productAttributeId, url: $url) {
success
message
}
}
`;

View File

@@ -0,0 +1,29 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import gql from 'graphql-tag';
export default gql`
mutation renameList($name: String!, $url: String!, $listId: Int!) {
renameList(name: $name, url: $url, listId: $listId) {
message
success
}
}
`;

View File

@@ -0,0 +1,28 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import gql from 'graphql-tag';
export default gql`
mutation shareList($listId: Int!, $userId: Int!) {
shareList(listId: $listId, userId: $userId) {
url
}
}
`;

View File

@@ -0,0 +1,33 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import gql from 'graphql-tag';
export default gql`
query lists($url: String!) {
lists(url: $url) {
id_wishlist
name
listUrl
shareUrl
nbProducts
default
}
}
`;

View File

@@ -0,0 +1,28 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import gql from 'graphql-tag';
export default gql`
query getProducts($listId: Int!, $url: String!) {
products(listId: $listId, url: $url) {
datas
}
}
`;

View File

@@ -0,0 +1,197 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import EventBus from '@components/EventBus';
import headers from '@constants/headers';
import GraphQLJSON, {GraphQLJSONObject} from 'graphql-type-json';
/**
* Resolvers linked to schemas definitions
*/
export default {
JSON: GraphQLJSON,
JSONObject: GraphQLJSONObject,
Query: {
/**
* Get product from a list
*/
products: async (root, {url}) => {
const response = await fetch(`${url}&from-xhr`, {
headers: headers.products,
});
const datas = await response.json();
EventBus.$emit('paginate', {
detail: {
total: datas.pagination.total_items,
minShown: datas.pagination.items_shown_from,
maxShown: datas.pagination.items_shown_to,
pageNumber: datas.pagination.pages_count,
pages: datas.pagination.pages,
display: datas.pagination.should_be_displayed,
currentPage: datas.pagination.current_page,
},
});
window.history.pushState(datas, document.title, datas.current_url);
window.scrollTo(0, 0);
return {
datas: {
products: datas.products,
pagination: datas.pagination,
current_url: datas.current_url,
sort_orders: datas.sort_orders,
sort_selected: datas.sort_selected,
},
};
},
/**
* Get every lists from User
*/
lists: async (root, {url}) => {
const response = await fetch(url);
const datas = await response.json();
return datas.wishlists;
},
},
Mutation: {
/**
* Create a list based on a name and an userId
*
* @param {String} name The name of the list
* @param {Int} userId The ID of the user you want to create a list on
*/
createList: async (root, {name, url}) => {
const nameEncoded = encodeURIComponent(name);
const response = await fetch(`${url}&params[name]=${nameEncoded}`, {
method: 'POST',
});
const datas = await response.json();
return datas;
},
/**
* Rename a list
*
* @param {String} {name New name of the list
* @param {Int} userId Id of the user
* @param {Int} listId} ID of the list to be renamed
*/
renameList: async (root, {name, listId, url}) => {
const response = await fetch(`${url}&params[name]=${name}&params[idWishList]=${listId}`, {
method: 'POST',
});
const datas = await response.json();
return datas;
},
/**
* Add a product to a list
*
* @param {Int} listId The list id
* @param {Int} userId The user id
* @param {Int} productId The product id to be added to the list id
*
* @returns {JSON} A success or failed response
*/
addToList: async (root, {
listId, url, productId, quantity, productAttributeId,
}) => {
/* eslint-disable */
const response = await fetch(
`${url}&params[id_product]=${productId}&params[idWishList]=${listId}&params[quantity]=${quantity}&params[id_product_attribute]=${productAttributeId}`,
{
method: 'POST'
}
);
/* eslint-enable */
const datas = await response.json();
if (datas.success) {
// eslint-disable-next-line
productsAlreadyTagged.push({
id_product: productId.toString(),
id_wishlist: listId.toString(),
quantity: quantity.toString(),
id_product_attribute: productAttributeId.toString(),
});
}
return datas;
},
/**
* Remove a product from a list
*
* @param {Int} listId The list id
* @param {Int} userId The user id
* @param {Int} productId The product id to be removed from the list id
*
* @returns {JSON} A success or failed response
*/
removeFromList: async (root, {
listId, productId, url, productAttributeId,
}) => {
/* eslint-disable */
const response = await fetch(
`${url}&params[id_product]=${productId}&params[idWishList]=${listId}&params[id_product_attribute]=${productAttributeId}`,
{
method: 'POST'
}
);
/* eslint-enable */
const datas = await response.json();
if (datas.success) {
// eslint-disable-next-line
productsAlreadyTagged = productsAlreadyTagged.filter(
(e) => e.id_product !== productId.toString()
|| (e.id_product_attribute !== productAttributeId.toString() && e.id_product === productId.toString())
|| e.id_wishlist !== listId.toString(),
);
}
return datas;
},
/**
* Remove a list
*
* @param {Int} {listId} The list id
*
* @returns {JSON} a JSON success or failed response
*/
deleteList: async (root, {listId, url}) => {
const response = await fetch(`${url}&params[idWishList]=${listId}`, {
method: 'POST',
});
const datas = await response.json();
return datas;
},
},
};

View File

@@ -0,0 +1,64 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
export default `
scalar JSON
scalar JSONObject
type List {
id_wishlist: Int
name: String
listUrl: String
shareUrl: String
default: Int
nbProducts: Int
}
type ShareUrl {
url: String
}
type CreateResponse {
datas: List
success: Boolean!
message: String!
}
type ProductListResponse {
datas: JSONObject
}
type Response {
success: Boolean!
message: String!
}
type Query {
products(listId: Int!, url: String!): ProductListResponse
lists(url: String!): [List]
}
type Mutation {
createList(name: String!, url: String!): CreateResponse
shareList(listId: String!, userId: Int!): ShareUrl
renameList(name: String!, url: String!, listId: Int!): Response
addToList(listId: Int!, productId: Int!, quantity: Int!, productAttributeId: Int!, url: String!): Response
removeFromList(listId: Int!, productId: Int!, productAttributeId: Int!, url: String!): Response
deleteList(listId: Int!, url: String!): Response
}
`;

View File

@@ -0,0 +1,54 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import initVueButtons from '@components/Button';
import removeFromWishlistUrl from 'removeFromWishlistUrl';
const initButtons = () => {
const products = document.querySelectorAll('.js-product-miniature');
products.forEach((product) => {
const wishlistButton = document.createElement('div');
wishlistButton.classList.add('wishlist-button');
wishlistButton.dataset.productId = product.dataset.idProduct;
wishlistButton.dataset.url = removeFromWishlistUrl;
wishlistButton.dataset.productAttributeId = product.dataset.idProductAttribute;
wishlistButton.dataset.checked = false;
product.querySelector('.thumbnail-container').append(wishlistButton);
});
};
initButtons();
initVueButtons();
const productList = document.querySelectorAll('#products, .featured-products');
const config = {attributes: false, childList: true};
productList.forEach((e) => {
const callback = function () {
initButtons();
initVueButtons();
};
const observer = new MutationObserver(callback);
observer.observe(e, config);
});

View File

@@ -0,0 +1,24 @@
.wishlist {
&-footer {
&-links {
margin-bottom: 50px;
> a {
color: $blue;
font-size: 14px;
letter-spacing: 0;
line-height: 19px;
&:not(:first-child) {
margin-left: 20px;
}
i {
font-size: 20px;
margin-right: 4px;
vertical-align: middle;
}
}
}
}
}

View File

@@ -0,0 +1,114 @@
.wishlist-modal {
display: block;
opacity: 0;
pointer-events: none;
z-index: 0;
&.show {
opacity: 1;
pointer-events: all;
z-index: 1051;
+ .modal-backdrop {
pointer-events: all;
}
}
&.fade .modal-dialog {
max-width: 550px;
transform: translateY(0);
}
.close {
font-weight: 400;
color: #7a7a7a;
opacity: 1;
font-size: 2.25rem;
&:hover {
opacity: 0.6;
}
}
.modal {
&-header {
padding: 0.625rem 1.875rem;
display: flex;
align-items: center;
justify-content: space-between;
border: none;
h5 {
color: #232323;
font-size: 22px;
font-weight: bold;
letter-spacing: 0;
line-height: 30px;
}
&::after {
content: none;
}
}
&-text {
color: #232323;
font-size: 14px;
letter-spacing: 0;
line-height: 19px;
}
&-body {
padding: 15px 30px;
.form-group {
margin-bottom: 0;
.form-control {
border-radius: 0;
background: none;
color: black;
}
}
}
&-content {
width: 100%;
}
&-cancel {
background: #dddddd;
margin-right: 10px;
&:hover {
opacity: 0.7;
}
}
&-footer {
padding: 12px 30px;
border: none;
padding-bottom: 30px;
.btn {
text-transform: none;
}
}
&-backdrop {
pointer-events: none;
&.in {
pointer-events: all;
}
}
}
+ .modal-backdrop {
pointer-events: none;
&.in {
pointer-events: all;
}
}
}

View File

@@ -0,0 +1,12 @@
.products {
article {
.wishlist {
&-button-add {
position: absolute;
top: 10px;
right: 10px;
z-index: 10;
}
}
}
}

View File

@@ -0,0 +1 @@
$blue: #2fb5d2;

View File

@@ -0,0 +1 @@
.wishlist-modal{display:block;opacity:0;pointer-events:none;z-index:0}.wishlist-modal.show{opacity:1;pointer-events:all;z-index:1051}.wishlist-modal.show+.modal-backdrop{pointer-events:all}.wishlist-modal.fade .modal-dialog{max-width:550px;transform:translateY(0)}.wishlist-modal .close{font-weight:400;color:#7a7a7a;opacity:1;font-size:2.25rem}.wishlist-modal .close:hover{opacity:.6}.wishlist-modal .modal-header{padding:.625rem 1.875rem;display:flex;align-items:center;justify-content:space-between;border:none}.wishlist-modal .modal-header h5{color:#232323;font-size:22px;font-weight:bold;letter-spacing:0;line-height:30px}.wishlist-modal .modal-header::after{content:none}.wishlist-modal .modal-text{color:#232323;font-size:14px;letter-spacing:0;line-height:19px}.wishlist-modal .modal-body{padding:15px 30px}.wishlist-modal .modal-body .form-group{margin-bottom:0}.wishlist-modal .modal-body .form-group .form-control{border-radius:0;background:none;color:#000}.wishlist-modal .modal-content{width:100%}.wishlist-modal .modal-cancel{background:#ddd;margin-right:10px}.wishlist-modal .modal-cancel:hover{opacity:.7}.wishlist-modal .modal-footer{padding:12px 30px;border:none;padding-bottom:30px}.wishlist-modal .modal-footer .btn{text-transform:none}.wishlist-modal .modal-backdrop{pointer-events:none}.wishlist-modal .modal-backdrop.in{pointer-events:all}.wishlist-modal+.modal-backdrop{pointer-events:none}.wishlist-modal+.modal-backdrop.in{pointer-events:all}.products article .wishlist-button-add{position:absolute;top:10px;right:10px;z-index:10}.wishlist-footer-links{margin-bottom:50px}.wishlist-footer-links>a{color:#2fb5d2;font-size:14px;letter-spacing:0;line-height:19px}.wishlist-footer-links>a:not(:first-child){margin-left:20px}.wishlist-footer-links>a i{font-size:20px;margin-right:4px;vertical-align:middle}/*# sourceMappingURL=common.css.map */

View File

@@ -0,0 +1 @@
{"version":3,"sources":["_modal.scss","_product.scss","_footer-links.scss","_variables.scss"],"names":[],"mappings":"AAAA,gBACE,aAAA,CACA,SAAA,CACA,mBAAA,CACA,SAAA,CAEA,qBACE,SAAA,CACA,kBAAA,CACA,YAAA,CAEA,qCACE,kBAAA,CAIJ,mCACE,eAAA,CACA,uBAAA,CAGF,uBACE,eAAA,CACA,aAAA,CACA,SAAA,CACA,iBAAA,CAEA,6BACE,UAAA,CAKF,8BACE,wBAAA,CACA,YAAA,CACA,kBAAA,CACA,6BAAA,CACA,WAAA,CAEA,iCACE,aAAA,CACA,cAAA,CACA,gBAAA,CACA,gBAAA,CACA,gBAAA,CAGF,qCACE,YAAA,CAIJ,4BACE,aAAA,CACA,cAAA,CACA,gBAAA,CACA,gBAAA,CAGF,4BACE,iBAAA,CAEA,wCACE,eAAA,CAEA,sDACE,eAAA,CACA,eAAA,CACA,UAAA,CAKN,+BACE,UAAA,CAGF,8BACE,eAAA,CACA,iBAAA,CAEA,oCACE,UAAA,CAIJ,8BACE,iBAAA,CACA,WAAA,CACA,mBAAA,CAEA,mCACE,mBAAA,CAIJ,gCACE,mBAAA,CAEA,mCACE,kBAAA,CAKN,gCACE,mBAAA,CAEA,mCACE,kBAAA,CC3GA,uCACE,iBAAA,CACA,QAAA,CACA,UAAA,CACA,UAAA,CCLJ,uBACE,kBAAA,CAEA,yBACE,aCND,CDOC,cAAA,CACA,gBAAA,CACA,gBAAA,CAEA,2CACE,gBAAA,CAGF,2BACE,cAAA,CACA,gBAAA,CACA,qBAAA","file":"common.css"}

View File

@@ -0,0 +1,4 @@
@import '_variables';
@import '_modal';
@import '_product';
@import '_footer-links';

View File

@@ -0,0 +1,49 @@
{*
* 2007-2016 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-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{if $products}
<dl class="products" style="{if $products}border-bottom:1px solid #fff;{/if}">
{foreach from=$products item=product name=i}
<dt class="{if $smarty.foreach.i.first}first_item{elseif $smarty.foreach.i.last}last_item{else}item{/if}">
<span class="quantity-formated"><span class="quantity">{if isset($product.wishlist_quantity) && $product.wishlist_quantity}{$product.wishlist_quantity|intval}{else}0{/if}</span>x</span>
<a class="cart_block_product_name" href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category_rewrite)|escape:'html'}" title="{$product.name|escape:'html':'UTF-8'}" style="font-weight:bold;">{$product.name|truncate:13:'...'|escape:'html':'UTF-8'}</a>
<a class="ajax_cart_block_remove_link" href="javascript:;" onclick="javascript:WishlistCart('wishlist_block_list', 'delete', '{$product.id_product|escape:'html':'UTF-8'}', {$product.id_product_attribute|escape:'html':'UTF-8'}, '0');" title="{l s='remove this product from my wishlist' mod='blockwishlist'}" rel="nofollow"><img src="{$img_dir|escape:'html':'UTF-8'}icon/delete.gif" width="12" height="12" alt="{l s='Delete' mod='blockwishlist'}" class="icon" /></a>
</dt>
{if isset($product.attributes_small)}
<dd class="{if $smarty.foreach.i.first}first_item{elseif $smarty.foreach.i.last}last_item{else}item{/if}" style="font-style:italic;margin:0 0 0 10px;">
<a href="{$link->getProductLink($product.id_product, $product.link_rewrite)|escape:'html'}" title="{l s='Product detail' mod='blockwishlist'}">{$product.attributes_small|escape:'html':'UTF-8'}</a>
</dd>
{/if}
{/foreach}
</dl>
{else}
<dl class="products" style="font-size:10px;border-bottom:1px solid #fff;">
{if isset($error) && $error}
<dt>{l s='You must create a wishlist before adding products' mod='blockwishlist'}</dt>
{else}
<dt>{l s='No products' mod='blockwishlist'}</dt>
{/if}
</dl>
{/if}

View File

@@ -0,0 +1,49 @@
{*
* 2007-2016 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-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{if isset($wishlists) && count($wishlists) > 1}
<div class="line clearfix"></div>
<div class="buttons_bottom_block no-print panel-product-w-custom">
<div id="wishlist_button">
<span class="control-label">{l s='Wishlist' mod='blockwishlist'}</span>
<button class="wishlist_button_extra" onclick="WishlistCart('wishlist_block_list', 'add', '{$id_product|intval}', $('#idCombination').val(), document.getElementById('quantity_wanted').value, $('#idWishlist').val()); return false;" title="{l s='Add to wishlist' mod='blockwishlist'}">
<i class="fa fa-heart-o"></i>{l s='Add to my wishlist' mod='blockwishlist'}
</button>
<select id="idWishlist">
{foreach $wishlists as $wishlist}
<option value="{$wishlist.id_wishlist|escape:'html':'UTF-8'}">{$wishlist.name|escape:'html':'UTF-8'}</option>
{/foreach}
</select>
</div>
</div>
{else}
<div class="line clearfix line_wishlist"></div>
<div class="panel-product-w-custom">
<span class="control-label">{l s='Wishlist' mod='blockwishlist'}</span>
<a id="wishlist_button" href="#" onclick="WishlistCart('wishlist_block_list', 'add', '{$id_product|intval}', $('#idCombination').val(), document.getElementById('quantity_wanted').value); return false;" rel="nofollow" title="{l s='Add to my wishlist' mod='blockwishlist'}">
<i class="fa fa-heart-o"></i>{l s='Add to wishlist' mod='blockwishlist'}
</a>
</div>
{/if}

View File

@@ -0,0 +1,251 @@
/* module blockwishlist */
/* bt add */
.add_wishlist_button a {padding:5px 7px 5px 18px}
.add_wishlist_button a span {
z-index:10;
display:block;
position:absolute;
top:-1px;
left:-12px;
height:26px;
width:26px;
background:url(img/icon/pict_add_wishlist.png) no-repeat 0 0 transparent
}
/* bloc */
#wishlist_block #wishlist_block_list {
margin:5px 0 10px 0;
padding-bottom:10px;
border-bottom:1px dotted #ccc
}
#wishlist_block_list dt {
position:relative;
margin-top:5px;
padding-right:20px
}
#wishlist_block_list .quantity-formated {
display:inline-block;
margin-right:5px;
width:15px
}
#wishlist_block_list .cart_block_product_name {font-weight:bold}
#wishlist_block_list .ajax_cart_block_remove_link {
display:inline-block;
position:absolute;
right:0;
top:0;
margin:1px 0 0 5px;
height:12px;
width:12px
}
#wishlist_block_list dd {margin:0 0 0 24px}
#wishlist_block_list .ajax_cart_block_remove_link a {
display:inline-block;
height:12px;
width:12px;
background: url(img/icon/delete.gif) no-repeat 0 0
}
#wishlist_block_list .price {
float:right
}
#wishlist_block select#wishlists {
margin-bottom:10px;
width:99%;
border:1px solid #ccc;
}
#wishlist_block .lnk {padding:0}
#wishlist_block .lnk a {
display:block;
font-weight:bold;
text-align:right
}
/* page in my account ************************************************************************* */
#module-blockwishlist-mywishlist #left_column {display:none}
#module-blockwishlist-mywishlist #center_column{width:757px}
#module-blockwishlist-mywishlist #mywishlist fieldset {
padding: 15px 0 10px;
}
#form_wishlist .page-subheading {
margin-bottom: 15px;
margin-top: 10px;
text-transform: uppercase;
}
#module-blockwishlist-mywishlist #mywishlist p.text label {
display:inline-block;
padding-right:10px;
width:174px;
font-weight:bold;
font-size:12px;
text-align:right
}
#module-blockwishlist-mywishlist #mywishlist p.text input {
padding:0 5px;
height:20px;
width:288px;
border:1px solid #ccc;
}
#module-blockwishlist-mywishlist #mywishlist p.submit {
padding-bottom: 5px;
}
#mywishlist td.wishlist_delete {
text-align:center;
}
#mywishlist td.wishlist_delete a {
display:inline-block;
font-size:8px;
padding:1px 2px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
color:#666;
text-shadow:0 1px 0 #fff;
text-transform:uppercase;
background: none repeat scroll 0 0 #ccc;
}
/* form add ****************************************** */
#form_wishlist {}
#form_wishlist fieldset { padding: 20px }
#form_wishlist label {
display: inline-block;
float: left;
padding: 6px 15px 6px 0;
text-align: left;
width: 100%;
}
.footer_links.wishlist_footer {
margin-top: 30px;
}
#block-history {
margin-top: 30px;
}
#form_wishlist input.inputTxt {
background-color: #FFFFFF;
border: 1px solid #e7e7e7;
color: #666666;
font-size: 14px;
height: 35px;
padding: 0 5px;
width: 260px;
}
/* block-order-detail ********************************** */
#module-blockwishlist-mywishlist #block-order-detail {margin-top:20px}
/* wishlistLinkTop */
#module-blockwishlist-mywishlist #block-order-detail #hideSendWishlist {
display:inline-block;
height:12px;
width:12px;
background: url(img/icon/delete.gif) no-repeat 0 0
}
#module-blockwishlist-mywishlist .wishlistLinkTop {}
#module-blockwishlist-mywishlist .wishlistLinkTop ul {
list-style-type:none;
border-bottom:1px dotted #ccc
}
#module-blockwishlist-mywishlist .wishlistLinkTop ul.wlp_bought_list {border:none;}
#module-blockwishlist-mywishlist .wishlistLinkTop li {float:left}
#module-blockwishlist-mywishlist .wishlistLinkTop .display_list li a {
display:inline-block;
padding:7px 11px 5px 22px;
color: #333;
background:url(img/arrow_right_2.png) no-repeat 10px 14px transparent
}
.wl_send.box.unvisible {
margin-bottom: 20px;
}
#module-blockwishlist-mywishlist .wishlistLinkTop #hideSendWishlist {
float:right;
display:block;
height:12px;
width:12px;
text-indent:-5000px;
background: url(img/icon/delete.gif) no-repeat 0 0
}
#module-blockwishlist-mywishlist .wishlistLinkTop #showBoughtProducts,
#module-blockwishlist-mywishlist .wishlistLinkTop #hideBoughtProductsInfos {display:none}
/* wishlisturl */
#module-blockwishlist-mywishlist .wishlisturl {
margin:20px 0;
padding:10px;
background:#eee
}
#module-blockwishlist-mywishlist .wishlisturl input {
padding:2px 5px;
border:1px solid #ccc
}
/* wlp_bought ****************************************** */
/* wlp_bought_list */
ul.wlp_bought_list {
list-style-type:none;
margin-bottom:20px
}
ul.wlp_bought_list li {
float: left;
padding: 0 15px;
position: relative;
}
ul.wlp_bought_list li .product_infos {
float: left;
margin: 15px 0;
width: 100%;
}
.wlp_bought_container .product-name {
text-transform: uppercase;
}
ul.wlp_bought_list li .product_infos .s_title_block.product_name {
padding:5px 0;
font-size:12px;
color:#222
}
ul.wlp_bought_list li .product_infos .wishlist_product_detail input,
ul.wlp_bought_list li .product_infos .wishlist_product_detail select {
border:1px solid #d1d1d1
}
.wlp_bought_container {
border: 1px solid #e7e7e7;
float: left;
width: 100%;
}
ul.wlp_bought_list li .btn_action {
clear:both;
margin-top:10px
}
ul.wlp_bought_list li .btn_action .lnksave {float:right}
ul.wlp_bought_list li .lnkdel {
position:absolute;
top:5px;
right:5px;
display:block;
height:12px;
width:12px;
text-indent:-5000px;
background: url(img/icon/delete.gif) no-repeat 0 0
}
ul.product_list.grid > li .product-container .functional-buttons .wishlist .popover {
padding: 0;
min-width: 160px; }
ul.product_list.grid > li .product-container .functional-buttons .wishlist .popover .popover-content {
padding: 0;
min-width: 158px; }
ul.product_list.grid > li .product-container .functional-buttons .wishlist .popover table {
margin-bottom: 2px; }
ul.product_list.grid > li .product-container .functional-buttons .wishlist .popover table td:hover {
background-color: #cccccc;
cursor: pointer; }

View File

@@ -0,0 +1,382 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PrestaShop\Module\BlockWishList\Database\Install;
use PrestaShop\Module\BlockWishList\Database\Uninstall;
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
if (!defined('_PS_VERSION_')) {
exit;
}
$autoloadPath = __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/classes/WishList.php';
require_once __DIR__ . '/src/Database/Install.php';
if (file_exists($autoloadPath)) {
require_once $autoloadPath;
}
class BlockWishList extends Module
{
const HOOKS = [
'actionAdminControllerSetMedia',
'actionFrontControllerSetMedia',
'displayProductActions',
'displayCustomerAccount',
'displayHeader',
'displayTop',
'displayAdminCustomers',
'displayProductAdditionalInfo',
'displayProductListFunctionalButtons',
'displayMyAccountBlock',
'displayNav2',
];
const MODULE_ADMIN_CONTROLLERS = [
[
'class_name' => 'WishlistConfigurationAdminParentController',
'visible' => false,
'parent_class_name' => 'AdminParentModulesSf',
'name' => 'Wishlist Module',
],
[
'class_name' => 'WishlistConfigurationAdminController',
'visible' => true,
'parent_class_name' => 'WishlistConfigurationAdminParentController',
'name' => 'Configuration',
],
[
'class_name' => 'WishlistStatisticsAdminController',
'visible' => true,
'parent_class_name' => 'WishlistConfigurationAdminParentController',
'name' => 'Statistics',
],
];
public function __construct()
{
$this->name = 'blockwishlist';
$this->tab = 'front_office_features';
$this->version = '2.0.1';
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->trans('Wishlist', [], 'Modules.Blockwishlist.Admin');
$this->default_wishlist_name = $this->l('My wishlist');
$this->description = $this->trans('Adds a block containing the customer\'s wishlists.', [], 'Modules.Blockwishlist.Admin');
$this->ps_versions_compliancy = [
'min' => '1.7.6.0',
'max' => _PS_VERSION_,
];
}
/**
* @return bool
*/
public function install()
{
if (false === (new Install($this->getTranslator()))->run()) {
return false;
}
return parent::install()
&& $this->registerHook(static::HOOKS);
}
/**
* @return bool
*/
public function uninstall()
{
return (new Uninstall())->run()
&& parent::uninstall();
}
public function getContent()
{
Tools::redirectAdmin(
SymfonyContainer::getInstance()->get('router')->generate('blockwishlist_configuration')
);
}
/**
* Add asset for Administration
*
* @param array $params
*/
public function hookActionAdminControllerSetMedia(array $params)
{
$this->context->controller->addCss($this->getPathUri() . 'public/backoffice.css');
}
/**
* Add asset for Shop Front Office
*
* @see https://devdocs.prestashop.com/1.7/themes/getting-started/asset-management/#without-a-front-controller-module
*
* @param array $params
*/
public function getAllProductByCustomer($id_customer, $idShop)
{
$result = Db::getInstance()->executeS('
SELECT `id_product`, `id_product_attribute`, w.`id_wishlist`, wp.`quantity`
FROM `' . _DB_PREFIX_ . 'wishlist_product` wp
LEFT JOIN `' . _DB_PREFIX_ . 'wishlist` w ON (w.`id_wishlist` = wp.`id_wishlist`)
WHERE w.`id_customer` = ' . (int) $id_customer . '
AND w.id_shop = ' . (int) $idShop . '
AND wp.`quantity` > 0 ');
if (empty($result)) {
return false;
}
return $result;
}
public function hookActionFrontControllerSetMedia(array $params)
{
if (!method_exists('WishList','getAllProductByCustomer')) {
$productsTagged = true === $this->context->customer->isLogged() ? $this->getAllProductByCustomer($this->context->customer->id, $this->context->shop->id) : false;
}else {
$productsTagged = true === $this->context->customer->isLogged() ? WishList::getAllProductByCustomer($this->context->customer->id, $this->context->shop->id) : false;
}
Media::addJsDef([
'blockwishlistController' => $this->context->link->getModuleLink(
$this->name,
'action'
),
'removeFromWishlistUrl' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'deleteProductFromWishlist']),
'wishlistUrl' => $this->context->link->getModuleLink('blockwishlist', 'view'),
'wishlistAddProductToCartUrl' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'addProductToCart']),
'productsAlreadyTagged' => $productsTagged ?: [],
]);
$this->context->controller->registerStylesheet(
'blockwishlistController',
'modules/' . $this->name . '/public/wishlist.css',
[
'media' => 'all',
'priority' => 100,
]
);
$this->context->controller->registerJavascript(
'blockwishlistController',
'modules/' . $this->name . '/public/product.bundle.js',
[
'priority' => 100,
]
);
}
/**
* This hook allow additional action button, near the add to cart button on the product page
*
* @param array $params
*
* @return string
*/
public function hookDisplayProductActions(array $params)
{
$this->smarty->assign([
'blockwishlist' => $this->displayName,
'url' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'deleteProductFromWishlist']),
]);
return $this->fetch('module:blockwishlist/views/templates/hook/product/add-button.tpl');
}
/**
* This hook displays new elements on the customer account page
*
* @param array $params
*
* @return string
*/
public function hookDisplayCustomerAccount(array $params)
{
$this->smarty->assign([
'url' => $this->context->link->getModuleLink('blockwishlist', 'lists'),
'wishlistsTitlePage' => Configuration::get('blockwishlist_WishlistPageName', $this->context->language->id),
]);
return $this->fetch('module:blockwishlist/views/templates/hook/displayCustomerAccount.tpl');
}
/**
* This hook displays a new block on the admin customer page
*
* @param array $params
*
* @return string
*/
public function hookDisplayAdminCustomers(array $params)
{
$this->smarty->assign([
'blockwishlist' => $this->displayName,
]);
return $this->fetch('module:blockwishlist/views/templates/hook/displayAdminCustomers.tpl');
}
/**
* Display additional information inside the "my account" block
*
* @param array $params
*
* @return string
*/
public function hookDisplayMyAccountBlock(array $params)
{
$this->smarty->assign([
'blockwishlist' => $this->displayName,
'url' => $this->context->link->getModuleLink('blockwishlist', 'lists'),
'wishlistsTitlePage' => Configuration::get('blockwishlist_WishlistPageName', $this->context->language->id),
]);
return $this->fetch('module:blockwishlist/views/templates/hook/account/myaccount-block.tpl');
}
/**
* This hook adds additional elements in the head section of your pages (head section of html)
*
* @param array $params
*
* @return string
*/
public function hookDisplayHeader(array $params)
{
$this->context->controller->addJS(($this->_path).'js/ajax-wishlist.js');
$this->context->controller->addCSS(($this->_path).'blockwishlist.css', 'all');
$this->smarty->assign([
'context' => $this->context->controller->php_self,
'url' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'getAllWishlist']),
'createUrl' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'createNewWishlist']),
'deleteProductUrl' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'deleteProductFromWishlist']),
'addUrl' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'addProductToWishlist']),
'newWishlistCTA' => Configuration::get('blockwishlist_CreateButtonLabel', $this->context->language->id),
]);
return $this->fetch('module:blockwishlist/views/templates/hook/displayHeader.tpl');
}
public function hookDisplayTop($params)
{
$useSSL = ((isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED')) || Tools::usingSecureMode()) ? true : false;
$protocol_content = ($useSSL) ? 'https://' : 'http://';
if ($this->context->customer->isLogged())
{
$wishlists = Wishlist::getByIdCustomer($this->context->customer->id);
if (empty($this->context->cookie->id_wishlist) === true ||
WishList::exists($this->context->cookie->id_wishlist, $this->context->customer->id) === false)
{
if (!count($wishlists))
$id_wishlist = false;
else
{
$id_wishlist = (int)$wishlists[0]['id_wishlist'];
$this->context->cookie->id_wishlist = (int)$id_wishlist;
}
}
else
$id_wishlist = $this->context->cookie->id_wishlist;
$this->smarty->assign(
array(
'id_wishlist' => $id_wishlist,
'isLogged' => true,
'wishlist_products' => ($id_wishlist == false ? false : WishList::getProductByIdCustomer($id_wishlist,
$this->context->customer->id, $this->context->language->id, null, true)),
'wishlists' => $wishlists,
'ptoken' => Tools::getToken(false)
)
);
}
else
$this->smarty->assign(array('wishlist_products' => false, 'wishlists' => false));
$this->context->smarty->assign(
array(
'content_dir' => $protocol_content.Tools::getHttpHost().__PS_BASE_URI__,
'isLogged' => $this->context->customer->logged,
'count_product' => (int)Db::getInstance()->getValue('SELECT count(id_wishlist_product) FROM '._DB_PREFIX_.'wishlist w, '._DB_PREFIX_.'wishlist_product wp where w.id_wishlist = wp.id_wishlist and w.id_customer='.(int)$this->context->customer->id)
)
);
return $this->display(__FILE__, 'blockwishlist_top.tpl');
}
public function hookDisplayNav2($params)
{
$useSSL = ((isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED')) || Tools::usingSecureMode()) ? true : false;
$protocol_content = ($useSSL) ? 'https://' : 'http://';
if ($this->context->customer->isLogged())
{
$wishlists = Wishlist::getByIdCustomer($this->context->customer->id);
if (empty($this->context->cookie->id_wishlist) === true ||
WishList::exists($this->context->cookie->id_wishlist, $this->context->customer->id) === false)
{
if (!count($wishlists))
$id_wishlist = false;
else
{
$id_wishlist = (int)$wishlists[0]['id_wishlist'];
$this->context->cookie->id_wishlist = (int)$id_wishlist;
}
}
else
$id_wishlist = $this->context->cookie->id_wishlist;
$this->smarty->assign(
array(
'id_wishlist' => $id_wishlist,
'isLogged' => true,
'wishlist_products' => ($id_wishlist == false ? false : WishList::getProductByIdCustomer($id_wishlist,
$this->context->customer->id, $this->context->language->id, null, true)),
'wishlists' => $wishlists,
'ptoken' => Tools::getToken(false)
)
);
}
else
$this->smarty->assign(array('wishlist_products' => false, 'wishlists' => false));
$this->context->smarty->assign(
array(
'content_dir' => $protocol_content.Tools::getHttpHost().__PS_BASE_URI__,
'isLogged' => $this->context->customer->logged,
'count_product' => (int)Db::getInstance()->getValue('SELECT count(id_wishlist_product) FROM '._DB_PREFIX_.'wishlist w, '._DB_PREFIX_.'wishlist_product wp where w.id_wishlist = wp.id_wishlist and w.id_customer='.(int)$this->context->customer->id)
)
);
return $this->display(__FILE__, 'blockwishlist_top.tpl');
}
public function hookDisplayProductListFunctionalButtons($params)
{
//TODO : Add cache
if ($this->context->customer->isLogged())
$this->smarty->assign('wishlists', Wishlist::getByIdCustomer($this->context->customer->id));
$this->smarty->assign('product', $params['product']);
return $this->display(__FILE__, 'blockwishlist_button.tpl');
}
}

View File

@@ -0,0 +1,65 @@
{*
* 2007-2016 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-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div id="wishlist_block" class="block account">
<h4 class="title_block">
<a href="{$link->getModuleLink('blockwishlist', 'mywishlist', array(), true)|addslashes}" title="{l s='My wishlists' mod='blockwishlist'}" rel="nofollow">{l s='Wishlist' mod='blockwishlist'}</a>
</h4>
<div class="block_content">
<div id="wishlist_block_list" class="expanded">
{if $wishlist_products}
<dl class="products">
{foreach from=$wishlist_products item=product name=i}
<dt class="{if $smarty.foreach.i.first}first_item{elseif $smarty.foreach.i.last}last_item{else}item{/if}">
<span class="quantity-formated"><span class="quantity">{$product.quantity|intval}</span>x</span>
<a class="cart_block_product_name"
href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category_rewrite)|escape:'html'}" title="{$product.name|escape:'html':'UTF-8'}">{$product.name|truncate:30:'...'|escape:'html':'UTF-8'}</a>
<a class="ajax_cart_block_remove_link" href="javascript:;" onclick="javascript:WishlistCart('wishlist_block_list', 'delete', '{$product.id_product|escape:'html':'UTF-8'}', {$product.id_product_attribute|escape:'html':'UTF-8'}, '0', '{if isset($token)}{$token|escape:'html':'UTF-8'}{/if}');" title="{l s='remove this product from my wishlist' mod='blockwishlist'}" rel="nofollow"><img src="{$img_dir|escape:'html':'UTF-8'}icon/delete.gif" width="12" height="12" alt="{l s='Delete'}" class="icon" /></a>
</dt>
{if isset($product.attributes_small)}
<dd class="{if $smarty.foreach.i.first}first_item{elseif $smarty.foreach.i.last}last_item{else}item{/if}">
<a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category_rewrite)|escape:'html'}" title="{l s='Product detail'}">{$product.attributes_small|escape:'html':'UTF-8'}</a>
</dd>
{/if}
{/foreach}
</dl>
{else}
<dl class="products">
<dt>{l s='No products' mod='blockwishlist'}</dt>
</dl>
{/if}
</div>
<p class="lnk">
{if $wishlists}
<select name="wishlists" id="wishlists" onchange="WishlistChangeDefault('wishlist_block_list', $('#wishlists').val());">
{foreach from=$wishlists item=wishlist name=i}
<option value="{$wishlist.id_wishlist|escape:'html':'UTF-8'}"{if $id_wishlist eq $wishlist.id_wishlist or ($id_wishlist == false and $smarty.foreach.i.first)} selected="selected"{/if}>{$wishlist.name|truncate:22:'...'|escape:'html':'UTF-8'}</option>
{/foreach}
</select>
{/if}
<a href="{$link->getModuleLink('blockwishlist', 'mywishlist', array(), true)|addslashes}" title="{l s='My wishlists' mod='blockwishlist'}" rel="nofollow">&raquo; {l s='My wishlists' mod='blockwishlist'}</a>
</p>
</div>
</div>

View File

@@ -0,0 +1,59 @@
{*
* 2007-2016 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-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{if isset($wishlists) && is_array($wishlists) && count($wishlists) > 1}
<div class="wishlist">
{foreach name=wl from=$wishlists item=wishlist}
{if $smarty.foreach.wl.first}
<a class="wishlist_button_list" tabindex="0" data-toggle="popover" data-trigger="focus" title="{l s='Wishlist' mod='blockwishlist'}" data-placement="bottom">
<i class="fa fa-heart-o" aria-hidden="true"></i>
</a>
<div hidden class="popover-content">
<table class="table" border="1">
<tbody>
{/if}
<tr title="{$wishlist.name|escape:'html':'UTF-8'}" value="{$wishlist.id_wishlist|escape:'html':'UTF-8'}" onclick="WishlistCart('wishlist_block_list', 'add', '{$product.id_product|intval}', '{$product.id_product_attribute|intval}', 1, '{$wishlist.id_wishlist|escape:'html':'UTF-8'}');">
<td>
{l s='Add to %s' sprintf=[$wishlist.name] mod='blockwishlist'}
</td>
</tr>
{if $smarty.foreach.wl.last}
</tbody>
</table>
</div>
{/if}
{foreachelse}
<a href="#" id="wishlist_button_nopop" onclick="WishlistCart('wishlist_block_list', 'add', '{$id_product|intval}', $('#idCombination').val(), document.getElementById('quantity_wanted').value); return false;" rel="nofollow" title="{l s='Add to my wishlist' mod='blockwishlist'}">
<i class="fa fa-heart-o" aria-hidden="true"></i>
</a>
{/foreach}
</div>
{else}
<div class="wishlist">
<a class="addToWishlist wishlistProd_{$product.id_product|intval}" href="#" data-rel="{$product.id_product|intval}" onclick="WishlistCart('wishlist_block_list', 'add', '{$product.id_product|intval}', '{$product.id_product_attribute|intval}', 1); return false;">
<i class="fa fa-heart-o" aria-hidden="true"></i>
</a>
</div>
{/if}

View File

@@ -0,0 +1,3 @@
<a class="wishtlist_top" href="{$link->getModuleLink('blockwishlist', 'mywishlist', array(), true)|escape:'html':'UTF-8'}">
<i class="icon_heart_alt"></i>{l s='Wishlist' d='Shop.Theme'}
</a>

View File

@@ -0,0 +1,45 @@
{*
* 2007-2016 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-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<script type="text/javascript">
var wishlistProductsIds=[];
var baseDir ='{$content_dir|escape:'html':'UTF-8'}';
var static_token='{$static_token|escape:'html':'UTF-8'}';
var isLogged ='{$isLogged|escape:'html':'UTF-8'}';
var loggin_required='{l s='You must be logged in to manage your wishlist.' mod='blockwishlist' js=1}';
var added_to_wishlist ='{l s='The product was successfully added to your wishlist.' mod='blockwishlist' js=1}';
var mywishlist_url='{$link->getModuleLink('blockwishlist', 'lists', array(), true)|escape:'quotes':'UTF-8'}';
{if isset($isLogged)&&$isLogged}
var isLoggedWishlist=true;
{else}
var isLoggedWishlist=false;
{/if}
</script>
<a class="wishtlist_top" href="{$link->getModuleLink('blockwishlist', 'lists', array(), true)|escape:'html':'UTF-8'}">
<i class="fa fa-heart-o"></i>
</a>

View File

@@ -0,0 +1,56 @@
<?php
/*
* 2007-2016 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-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
require_once(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
require_once(dirname(__FILE__).'/WishList.php');
require_once(dirname(__FILE__).'/blockwishlist.php');
$error = '';
// Instance of module class for translations
$module = new BlockWishList();
$token = Tools::getValue('token');
$id_product = (int)Tools::getValue('id_product');
$id_product_attribute = (int)Tools::getValue('id_product_attribute');
if (Configuration::get('PS_TOKEN_ENABLE') == 1 && strcmp(Tools::getToken(false), Tools::getValue('static_token')))
$error = $module->l('Invalid token', 'buywishlistproduct');
if (!Tools::strlen($error) &&
empty($token) === false &&
empty($id_product) === false)
{
$wishlist = WishList::getByToken($token);
if ($wishlist !== false)
WishList::addBoughtProduct($wishlist['id_wishlist'], $id_product, $id_product_attribute, $cart->id, 1);
}
else
$error = $module->l('You must log in', 'buywishlistproduct');
if (empty($error) === false)
echo $error;

View File

@@ -0,0 +1,96 @@
<?php
/*
* 2007-2016 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-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once('../../config/config.inc.php');
require_once(dirname(__FILE__).'/classes/WishList.php');
require_once(dirname(__FILE__).'/blockwishlist.php');
$context = Context::getContext();
$action = Tools::getValue('action');
$add = (!strcmp($action, 'add') ? 1 : 0);
$delete = (!strcmp($action, 'delete') ? 1 : 0);
$id_wishlist = (int)Tools::getValue('id_wishlist');
$id_product = (int)Tools::getValue('id_product');
$quantity = (int)Tools::getValue('quantity');
if (Tools::getIsset('group')) {
$id_product_attribute = (int)Product::getIdProductAttributesByIdAttributes($id_product, Tools::getValue('group'));
}
else
$id_product_attribute=0;
$id_product_attribute = (int)Tools::getValue('id_product_attribute');
// Instance of module class for translations
$module = new BlockWishList();
if (Configuration::get('PS_TOKEN_ENABLE') == 1 &&
strcmp(Tools::getToken(false), Tools::getValue('token')) &&
$context->customer->isLogged() === true
)
echo $module->l('Invalid token', 'cart');
if ($context->customer->isLogged())
{
if ($id_wishlist && WishList::exists($id_wishlist, $context->customer->id) === true)
$context->cookie->id_wishlist = (int)$id_wishlist;
if ((int)$context->cookie->id_wishlist > 0 && !WishList::exists($context->cookie->id_wishlist, $context->customer->id))
$context->cookie->id_wishlist = '';
if (empty($context->cookie->id_wishlist) === true || $context->cookie->id_wishlist == false)
$context->smarty->assign('error', true);
if (($add || $delete) && empty($id_product) === false)
{
if (!isset($context->cookie->id_wishlist) || $context->cookie->id_wishlist == '')
{
$wishlist = new WishList();
$wishlist->id_shop = $context->shop->id;
$wishlist->id_shop_group = $context->shop->id_shop_group;
$wishlist->default = 1;
$mod_wishlist = new BlockWishList();
$wishlist->name = $mod_wishlist->default_wishlist_name;
$wishlist->id_customer = (int)$context->customer->id;
list($us, $s) = explode(' ', microtime());
srand($s * $us);
$wishlist->token =Tools::strtoupper(Tools::substr(sha1(uniqid(rand(), true)._COOKIE_KEY_.$context->customer->id), 0, 16));
$wishlist->add();
$context->cookie->id_wishlist = (int)$wishlist->id;
$context->cookie->write();
}
if ($add && $quantity)
WishList::addProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute, $quantity);
else if ($delete)
WishList::removeProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute);
}
$context->smarty->assign('products', WishList::getProductByIdCustomer($context->cookie->id_wishlist, $context->customer->id, $context->language->id, null, true));
$context->smarty->assign('link',$context->link);
$context->smarty->assign('img_dir',dirname(__FILE__).'/img/');
if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/blockwishlist/blockwishlist-ajax.tpl'))
$context->smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/blockwishlist-ajax.tpl');
elseif (Tools::file_exists_cache(dirname(__FILE__).'/blockwishlist-ajax.tpl'))
$context->smarty->display(dirname(__FILE__).'/blockwishlist-ajax.tpl');
else
echo $module->l('No template found', 'cart');
} else
echo $module->l('You must be logged in to manage your wishlist.', 'cart');

View File

@@ -0,0 +1,54 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class Statistics extends ObjectModel
{
/** @var int ID */
public $id_statistics;
/** @var int id_product */
public $id_product;
/** @var int id_product_attribute */
public $id_product_attribute;
/** @var string date_add */
public $date_add;
/** @var int|null date_add */
public $id_cart;
/** @var int ID */
public $id_shop;
/**
* @see ObjectModel::$definition
*/
public static $definition = [
'table' => 'blockwishlist_statistics',
'primary' => 'id_statistics',
'fields' => [
'id_cart' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => false],
'id_product' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_product_attribute' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'date_add' => ['type' => self::TYPE_DATE, 'required' => true],
'id_shop' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
],
];
}

View File

@@ -0,0 +1,640 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class WishList extends ObjectModel
{
/** @var int Wishlist ID */
public $id;
/** @var int Customer ID */
public $id_customer;
/** @var int Token */
public $token;
/** @var string Name */
public $name;
/** @var string Object creation date */
public $date_add;
/** @var string Object last modification date */
public $date_upd;
/** @var int Object last modification date */
public $id_shop;
/** @var int Object last modification date */
public $id_shop_group;
/** @var int default */
public $default;
/**
* @see ObjectModel::$definition
*/
public static $definition = [
'table' => 'wishlist',
'primary' => 'id_wishlist',
'fields' => [
'id_customer' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'token' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true],
'name' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
'date_upd' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
'id_shop' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
'id_shop_group' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
'default' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
],
];
/**
* Get Customers having a wishlist
*
* @return array Results
*/
public static function getCustomers()
{
$cache_id = 'WishList::getCustomers';
if (false === Cache::isStored($cache_id)) {
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.`id_customer`, c.`firstname`, c.`lastname`
FROM `' . _DB_PREFIX_ . 'wishlist` w
INNER JOIN `' . _DB_PREFIX_ . 'customer` c ON c.`id_customer` = w.`id_customer`
ORDER BY c.`firstname` ASC'
);
Cache::store($cache_id, $result);
}
return Cache::retrieve($cache_id);
}
/**
* Return true if wishlist exists else false
*
* @param int $id_wishlist
* @param int $id_customer
*
* @return bool exists
*/
public static function exists($id_wishlist, $id_customer)
{
$result = Db::getInstance()->getRow('
SELECT 1
FROM `' . _DB_PREFIX_ . 'wishlist`
WHERE `id_wishlist` = ' . (int) $id_wishlist . '
AND `id_customer` = ' . (int) $id_customer . '
AND `id_shop` = ' . (int) Context::getContext()->shop->id
);
return (bool) $result;
}
/**
* Set current WishList as default
*
* @return bool
*/
public function setDefault()
{
if ($default = $this->getDefault($this->id_customer)) {
Db::getInstance()->update('wishlist', ['default' => '0'], 'id_wishlist = ' . (int) $default);
}
return Db::getInstance()->update('wishlist', ['default' => '1'], 'id_wishlist = ' . (int) $this->id);
}
/**
* Return if there is a default already set
*
* @param int $id_customer
*
* @return bool
*/
public static function isDefault($id_customer)
{
return (bool) Db::getInstance()->getValue('SELECT 1 FROM `' . _DB_PREFIX_ . 'wishlist` WHERE `id_customer` = ' . (int) $id_customer . ' AND `default` = 1');
}
/**
* @param int $id_customer
*
* @return int
*/
public static function getDefault($id_customer)
{
return (int) Db::getInstance()->getValue('SELECT `id_wishlist` FROM `' . _DB_PREFIX_ . 'wishlist` WHERE `id_customer` = ' . (int) $id_customer . ' AND `default` = 1');
}
/**
* Add product to ID wishlist
*
* @param int $id_wishlist
* @param int $id_customer
* @param int $id_product
* @param int $id_product_attribute
* @param int $quantity
*
* @return bool succeed
*/
public static function addProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute, $quantity)
{
$result = Db::getInstance()->getRow('
SELECT wp.`quantity`
FROM `' . _DB_PREFIX_ . 'wishlist_product` wp
JOIN `' . _DB_PREFIX_ . 'wishlist` w ON (w.`id_wishlist` = wp.`id_wishlist`)
WHERE wp.`id_wishlist` = ' . (int) $id_wishlist . '
AND w.`id_customer` = ' . (int) $id_customer . '
AND wp.`id_product` = ' . (int) $id_product . '
AND wp.`id_product_attribute` = ' . (int) ($id_product_attribute)
);
if (!empty($result)) {
if ((int) $result['quantity'] + (int) $quantity <= 0) {
return WishList::removeProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute);
}
// TODO: use a method for this like updateProduct ?
return Db::getInstance()->update(
'wishlist_product',
[
'quantity' => (int) $quantity + (int) $result['quantity'],
],
'`id_wishlist` = ' . (int) $id_wishlist . ' AND `id_product` = ' . (int) $id_product . ' AND `id_product_attribute` = ' . (int) $id_product_attribute
);
}
return Db::getInstance()->insert(
'wishlist_product',
[
'id_wishlist' => (int) $id_wishlist,
'id_product' => (int) $id_product,
'id_product_attribute' => (int) $id_product_attribute,
'quantity' => (int) $quantity,
'priority' => 1,
]
);
}
/**
* Remove product from wishlist
*
* @param int $id_wishlist
* @param int $id_customer
* @param int $id_product
* @param int $id_product_attribute
*
* @return bool
*/
public static function removeProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute)
{
$result = Db::getInstance()->getRow('
SELECT w.`id_wishlist`, wp.`id_wishlist_product`
FROM `' . _DB_PREFIX_ . 'wishlist` w
LEFT JOIN `' . _DB_PREFIX_ . 'wishlist_product` wp ON (wp.`id_wishlist` = w.`id_wishlist`)
WHERE `id_customer` = ' . (int) $id_customer . '
AND w.`id_wishlist` = ' . (int) $id_wishlist
);
// die(dump($result));
if (empty($result)) {
return false;
}
// Delete product in wishlist_product_cart
Db::getInstance()->delete(
'wishlist_product_cart',
'id_wishlist_product = ' . (int) $result['id_wishlist_product']
);
return Db::getInstance()->delete(
'wishlist_product',
'id_wishlist = ' . (int) $id_wishlist . ' AND id_product = ' . (int) $id_product . ' AND id_product_attribute = ' . (int) $id_product_attribute
);
}
/**
* Update product to wishlist
*
* @param int $id_wishlist
* @param int $id_product
* @param int $id_product_attribute
* @param int $priority
* @param int $quantity
*
* @return bool succeed
*/
public static function updateProduct($id_wishlist, $id_product, $id_product_attribute, $priority, $quantity)
{
if ($priority < 0 || $priority > 2) {
return false;
}
return Db::getInstance()->update(
'wishlist_product',
[
'priority' => (int) $priority,
'quantity' => (int) $quantity,
],
'id_wishlist = ' . (int) $id_wishlist . 'id_product` = ' . (int) $id_product . 'id_product_attribute` = ' . (int) $id_product_attribute
);
}
/**
* Get all Wishlists by Customer ID
*
* @param int $id_customer
*
* @return array Results
*/
public static function getAllWishlistsByIdCustomer($id_customer)
{
$shop_restriction = '';
if (Shop::getContextShopID()) {
$shop_restriction = 'AND id_shop = ' . (int) Shop::getContextShopID();
} elseif (Shop::getContextShopGroupID()) {
$shop_restriction = 'AND id_shop_group = ' . (int) Shop::getContextShopGroupID();
}
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT w.`id_wishlist`, COUNT(wp.`id_product`) AS nbProducts, w.`name`, w.`default`, w.`token`
FROM `' . _DB_PREFIX_ . 'wishlist_product` wp
RIGHT JOIN `' . _DB_PREFIX_ . 'wishlist` w ON (w.`id_wishlist` = wp.`id_wishlist`)
WHERE w.`id_customer` = ' . (int) $id_customer . '
' . $shop_restriction . '
GROUP BY w.`id_wishlist`
ORDER BY w.`default` DESC, w.`name` ASC'
);
}
/**
* Get products by Wishlist
*
* @param int $id_wishlist
*
* @return array|false Results
*/
public static function getProductsByWishlist($id_wishlist)
{
$wishlistProducts = Db::getInstance()->executeS('
SELECT `id_product`, `id_product_attribute`, `quantity`
FROM `' . _DB_PREFIX_ . 'wishlist_product`
WHERE `id_wishlist` = ' . (int) $id_wishlist . '
And quantity > 0'
);
if (!empty($wishlistProducts)) {
return $wishlistProducts;
}
return false;
}
/**
* Get Wishlist products by Customer ID
*
* @param int $id_wishlist
* @param int $id_customer
* @param int $id_lang
* @param int|null $id_product
* @param bool $quantity
*
* @return array Results
*/
public static function getProductByIdCustomer($id_wishlist, $id_customer, $id_lang, $id_product = null, $quantity = false)
{
$products = Db::getInstance()->executeS('
SELECT wp.`id_product`, wp.`quantity` as wishlist_quantity, p.`quantity` AS product_quantity, pl.`name`, wp.`id_product_attribute`, wp.`priority`, pl.link_rewrite, cl.link_rewrite AS category_rewrite
FROM `' . _DB_PREFIX_ . 'wishlist_product` wp
LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON p.`id_product` = wp.`id_product`
' . Shop::addSqlAssociation('product', 'p') . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON pl.`id_product` = wp.`id_product`' . Shop::addSqlRestrictionOnLang('pl') . '
LEFT JOIN `' . _DB_PREFIX_ . 'wishlist` w ON w.`id_wishlist` = wp.`id_wishlist`
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON cl.`id_category` = product_shop.`id_category_default` AND cl.id_lang=' . (int) $id_lang . Shop::addSqlRestrictionOnLang('cl') . '
WHERE w.`id_customer` = ' . (int) $id_customer . '
AND pl.`id_lang` = ' . (int) $id_lang . '
AND wp.`id_wishlist` = ' . (int) $id_wishlist .
(empty($id_product) === false ? ' AND wp.`id_product` = ' . (int) $id_product : '') .
($quantity == true ? ' AND wp.`quantity` != 0' : '') . '
GROUP BY p.id_product, wp.id_product_attribute'
);
if (empty($products)) {
return [];
}
for ($i = 0; $i < sizeof($products); ++$i) {
if (isset($products[$i]['id_product_attribute']) &&
Validate::isUnsignedInt($products[$i]['id_product_attribute'])) {
$result = Db::getInstance()->executeS('
SELECT al.`name` AS attribute_name, pa.`quantity` AS "attribute_quantity"
FROM `' . _DB_PREFIX_ . 'product_attribute_combination` pac
LEFT JOIN `' . _DB_PREFIX_ . 'attribute` a ON (a.`id_attribute` = pac.`id_attribute`)
LEFT JOIN `' . _DB_PREFIX_ . 'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`)
LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = ' . (int) $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = ' . (int) $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
' . Shop::addSqlAssociation('product_attribute', 'pa') . '
WHERE pac.`id_product_attribute` = ' . (int) ($products[$i]['id_product_attribute']));
$products[$i]['attributes_small'] = '';
if ($result) {
foreach ($result as $k => $row) {
$products[$i]['attributes_small'] .= $row['attribute_name'] . ', ';
}
}
$products[$i]['attributes_small'] = rtrim($products[$i]['attributes_small'], ', ');
if (isset($result[0])) {
$products[$i]['attribute_quantity'] = $result[0]['attribute_quantity'];
}
} else {
$products[$i]['attribute_quantity'] = $products[$i]['product_quantity'];
}
}
return $products;
}
/**
* Add bought product
*
* @param int $id_wishlist
* @param int $id_product
* @param int $id_product_attribute
* @param int $id_cart
* @param int $quantity
*
* @return bool succeed
*/
public static function addBoughtProduct($id_wishlist, $id_product, $id_product_attribute, $id_cart, $quantity)
{
$result = Db::getInstance()->getRow('
SELECT `quantity`, `id_wishlist_product`
FROM `' . _DB_PREFIX_ . 'wishlist_product` wp
WHERE `id_wishlist` = ' . (int) $id_wishlist . '
AND `id_product` = ' . (int) $id_product . '
AND `id_product_attribute` = ' . (int) $id_product_attribute
);
if (empty($result) ||
($result['quantity'] - $quantity) < 0 ||
$quantity > $result['quantity']) {
return false;
}
Db::getInstance()->executeS('
SELECT *
FROM `' . _DB_PREFIX_ . 'wishlist_product_cart`
WHERE `id_wishlist_product`=' . (int) $result['id_wishlist_product'] . ' AND `id_cart`=' . (int) $id_cart
);
if (Db::getInstance()->NumRows() > 0) {
$result2 = Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'wishlist_product_cart`
SET `quantity`=`quantity` + ' . (int) $quantity . '
WHERE `id_wishlist_product`=' . (int) $result['id_wishlist_product'] . ' AND `id_cart`=' . (int) $id_cart
);
} else {
$result2 = Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'wishlist_product_cart`
(`id_wishlist_product`, `id_cart`, `quantity`, `date_add`) VALUES(
' . (int) $result['id_wishlist_product'] . ',
' . (int) $id_cart . ',
' . (int) $quantity . ',
\'' . pSQL(date('Y-m-d H:i:s')) . '\')');
}
if ($result2 === false) {
return false;
}
$newQuantity = (int) $result['quantity'] - (int) $quantity;
$minimalQuantity = self::getMinimalProductQuantity($id_product, $id_product_attribute);
return Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'wishlist_product` SET
`quantity` = ' . (int) max($minimalQuantity, $newQuantity) . '
WHERE `id_wishlist` = ' . (int) $id_wishlist . '
AND `id_product` = ' . (int) $id_product . '
AND `id_product_attribute` = ' . (int) $id_product_attribute);
}
/**
* @param int $id_customer
* @param int $idShop
*
* @return array|false
*/
public static function getAllProductByCustomer($id_customer, $idShop)
{
$result = Db::getInstance()->executeS('
SELECT `id_product`, `id_product_attribute`, w.`id_wishlist`, wp.`quantity`
FROM `' . _DB_PREFIX_ . 'wishlist_product` wp
LEFT JOIN `' . _DB_PREFIX_ . 'wishlist` w ON (w.`id_wishlist` = wp.`id_wishlist`)
WHERE w.`id_customer` = ' . (int) $id_customer . '
AND w.id_shop = ' . (int) $idShop . '
AND wp.`quantity` > 0 ');
if (empty($result)) {
return false;
}
return $result;
}
/**
* Get ID wishlist by Token
*
* @param string $token
*
* @return array Results
*
* @throws PrestaShopException
*/
public static function getByToken($token)
{
if (empty($token) || false === Validate::isMessage($token)) {
throw new PrestaShopException('Invalid token');
}
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT w.`id_wishlist`, w.`name`, w.`id_customer`, c.`firstname`, c.`lastname`
FROM `' . _DB_PREFIX_ . 'wishlist` w
INNER JOIN `' . _DB_PREFIX_ . 'customer` c ON c.`id_customer` = w.`id_customer`
WHERE `token` = \'' . pSQL($token) . '\''
);
}
public static function refreshWishList($id_wishlist)
{
$old_carts = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT wp.id_product, wp.id_product_attribute, wpc.id_cart, UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(wpc.date_add) AS timecart
FROM `' . _DB_PREFIX_ . 'wishlist_product_cart` wpc
JOIN `' . _DB_PREFIX_ . 'wishlist_product` wp ON (wp.id_wishlist_product = wpc.id_wishlist_product)
JOIN `' . _DB_PREFIX_ . 'cart` c ON (c.id_cart = wpc.id_cart)
JOIN `' . _DB_PREFIX_ . 'cart_product` cp ON (wpc.id_cart = cp.id_cart)
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON (o.id_cart = c.id_cart)
WHERE (wp.id_wishlist=' . (int) $id_wishlist . ' AND o.id_cart IS NULL)
HAVING timecart >= 3600*6');
if (!empty($old_carts)) {
foreach ($old_carts as $old_cart) {
Db::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . 'cart_product`
WHERE id_cart=' . (int) $old_cart['id_cart'] . ' AND id_product=' . (int) $old_cart['id_product'] . ' AND id_product_attribute=' . (int) $old_cart['id_product_attribute']
);
}
}
$freshwish = Db::getInstance()->executeS('
SELECT wpc.id_cart, wpc.id_wishlist_product
FROM `' . _DB_PREFIX_ . 'wishlist_product_cart` wpc
JOIN `' . _DB_PREFIX_ . 'wishlist_product` wp ON (wpc.id_wishlist_product = wp.id_wishlist_product)
JOIN `' . _DB_PREFIX_ . 'cart` c ON (c.id_cart = wpc.id_cart)
LEFT JOIN `' . _DB_PREFIX_ . 'cart_product` cp ON (cp.id_cart = wpc.id_cart AND cp.id_product = wp.id_product AND cp.id_product_attribute = wp.id_product_attribute)
WHERE (wp.id_wishlist = ' . (int) $id_wishlist . ' AND ((cp.id_product IS NULL AND cp.id_product_attribute IS NULL)))
');
$res = Db::getInstance()->executeS('
SELECT wp.id_wishlist_product, cp.quantity AS cart_quantity, wpc.quantity AS wish_quantity, wpc.id_cart
FROM `' . _DB_PREFIX_ . 'wishlist_product_cart` wpc
JOIN `' . _DB_PREFIX_ . 'wishlist_product` wp ON (wp.id_wishlist_product = wpc.id_wishlist_product)
JOIN `' . _DB_PREFIX_ . 'cart` c ON (c.id_cart = wpc.id_cart)
JOIN `' . _DB_PREFIX_ . 'cart_product` cp ON (cp.id_cart = wpc.id_cart AND cp.id_product = wp.id_product AND cp.id_product_attribute = wp.id_product_attribute)
WHERE wp.id_wishlist=' . (int) $id_wishlist
);
if (!empty($res)) {
foreach ($res as $refresh) {
if ($refresh['wish_quantity'] > $refresh['cart_quantity']) {
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'wishlist_product`
SET `quantity`= `quantity` + ' . ((int) $refresh['wish_quantity'] - (int) $refresh['cart_quantity']) . '
WHERE id_wishlist_product=' . (int) $refresh['id_wishlist_product']
);
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'wishlist_product_cart`
SET `quantity`=' . (int) $refresh['cart_quantity'] . '
WHERE id_wishlist_product=' . (int) $refresh['id_wishlist_product'] . ' AND id_cart=' . (int) $refresh['id_cart']
);
}
}
}
if (!empty($freshwish)) {
foreach ($freshwish as $prodcustomer) {
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'wishlist_product` SET `quantity`=`quantity` +
(
SELECT `quantity` FROM `' . _DB_PREFIX_ . 'wishlist_product_cart`
WHERE `id_wishlist_product`=' . (int) $prodcustomer['id_wishlist_product'] . ' AND `id_cart`=' . (int) $prodcustomer['id_cart'] . '
)
WHERE `id_wishlist_product`=' . (int) $prodcustomer['id_wishlist_product'] . ' AND `id_wishlist`=' . (int) $id_wishlist
);
Db::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . 'wishlist_product_cart`
WHERE `id_wishlist_product`=' . (int) $prodcustomer['id_wishlist_product'] . ' AND `id_cart`=' . (int) $prodcustomer['id_cart']
);
}
}
}
/**
* Increment counter
*
* @param int $id_wishlist
*
* @return bool succeed
*/
public static function incCounter($id_wishlist)
{
$counter = WishList::getWishlistCounter((int) $id_wishlist);
++$counter;
return Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'wishlist` SET
`counter` = ' . $counter . '
WHERE `id_wishlist` = ' . (int) $id_wishlist
);
}
/**
* @param int $id_wishlist
*
* @return int
*/
public static function getWishlistCounter($id_wishlist)
{
return (int) Db::getInstance()->getValue('
SELECT `counter`
FROM `' . _DB_PREFIX_ . 'wishlist`
WHERE `id_wishlist` = ' . (int) $id_wishlist
);
}
/**
* Get Wishlists by Customer ID
*
* @param int $id_customer
*
* @return array Results
*/
public static function getByIdCustomer($id_customer)
{
$shop_restriction = '';
if (Shop::getContextShopID()) {
$shop_restriction = 'AND id_shop = ' . (int) Shop::getContextShopID();
} elseif (Shop::getContextShopGroupID()) {
$shop_restriction = 'AND id_shop_group = ' . (int) Shop::getContextShopGroupID();
}
$cache_id = 'WhishList::getByIdCustomer_' . (int) $id_customer . '-' . (int) Shop::getContextShopID() . '-' . (int) Shop::getContextShopGroupID();
if (!Cache::isStored($cache_id)) {
$result = Db::getInstance()->executeS('
SELECT w.`id_wishlist`, w.`name`, w.`token`, w.`date_add`, w.`date_upd`, w.`counter`, w.`default`
FROM `' . _DB_PREFIX_ . 'wishlist` w
WHERE `id_customer` = ' . (int) $id_customer . '
' . $shop_restriction . '
ORDER BY w.`name` ASC'
);
Cache::store($cache_id, $result);
}
return Cache::retrieve($cache_id);
}
/**
* @param int $idProduct
* @param int $idAttribute
*
* @return int
*/
private static function getMinimalProductQuantity($idProduct, $idAttribute)
{
if ($idAttribute) {
$minimalQuantity = Attribute::getAttributeMinimalQty($idAttribute);
if (false !== $minimalQuantity) {
return (int) $minimalQuantity;
}
}
return (int) (new Product($idProduct))->minimal_quantity;
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (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;

1351
modules/blockwishlist-tmp/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>blockwishlist</name>
<displayName><![CDATA[Wishlist]]></displayName>
<version><![CDATA[2.0.1]]></version>
<description><![CDATA[Adds a block containing the customer&#039;s wishlists.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,21 @@
blockwishlist_configuration:
path: blockwishlist/configuration
methods: [GET, POST]
defaults:
_controller: PrestaShop\Module\BlockWishList\Controller\WishlistConfigurationAdminController::configurationAction
_legacy_controller: 'WishlistConfigurationAdminController'
_legacy_link: 'WishlistConfigurationAdminController'
blockwishlist_statistics:
path: blockwishlist/statistics
methods: [GET]
defaults:
_controller: PrestaShop\Module\BlockWishList\Controller\WishlistConfigurationAdminController::statisticsAction
_legacy_controller: 'WishlistStatisticsAdminController'
_legacy_link: 'WishlistStatisticsAdminController'
blockwishlist_statistics_reset:
path: blockwishlist/statistics/reset
methods: [POST]
defaults:
_controller: PrestaShop\Module\BlockWishList\Controller\WishlistConfigurationAdminController::resetStatisticsCacheAction

View File

@@ -0,0 +1,99 @@
services:
# Controller
PrestaShop\Module\BlockWishList\Controller\WishlistConfigurationAdminController:
public: true
class: PrestaShop\Module\BlockWishList\Controller\WishlistConfigurationAdminController
arguments:
- '@doctrine.cache.provider'
- '@=service("prestashop.adapter.shop.context").getContextShopID()'
# Calculator
prestashop.module.blockwishlist.calculator.statistics_calculator:
public: true
class: PrestaShop\Module\BlockWishList\Calculator\StatisticsCalculator
arguments:
- '@prestashop.adapter.legacy.context' #used for product presenter
- '@=service("prestashop.core.localization.locale.repository").getLocale(service("prestashop.adapter.legacy.context").getContext().language.getLocale())' # From PS 1.7.7: "@prestashop.core.localization.locale.context_locale"
# Grid Definition
prestashop.module.blockwishlist.grid.all_time_statistics_grid_definition_factory:
public: true
class: 'PrestaShop\Module\BlockWishList\Grid\Definition\AllTimeStatisticsGridDefinitionFactory'
parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition'
prestashop.module.blockwishlist.grid.current_year_statistics_grid_definition_factory:
public: true
class: 'PrestaShop\Module\BlockWishList\Grid\Definition\CurrentYearStatisticsGridDefinitionFactory'
parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition'
prestashop.module.blockwishlist.grid.current_month_statistics_grid_definition_factory:
public: true
class: 'PrestaShop\Module\BlockWishList\Grid\Definition\CurrentMonthStatisticsGridDefinitionFactory'
parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition'
prestashop.module.blockwishlist.grid.current_day_statistics_grid_definition_factory:
public: true
class: 'PrestaShop\Module\BlockWishList\Grid\Definition\CurrentDayStatisticsGridDefinitionFactory'
parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition'
# Grid Data Factories
prestashop.module.blockwishlist.grid.all_time_statistics_data_factory:
class: 'PrestaShop\Module\BlockWishList\Grid\Data\AllTimeStatisticsGridDataFactory'
arguments:
- '@doctrine.cache.provider'
- '@prestashop.module.blockwishlist.calculator.statistics_calculator'
- '@=service("prestashop.adapter.shop.context").getContextShopID()'
prestashop.module.blockwishlist.grid.current_year_statistics_data_factory:
class: 'PrestaShop\Module\BlockWishList\Grid\Data\CurrentYearStatisticsGridDataFactory'
arguments:
- '@doctrine.cache.provider'
- '@prestashop.module.blockwishlist.calculator.statistics_calculator'
- '@=service("prestashop.adapter.shop.context").getContextShopID()'
prestashop.module.blockwishlist.grid.current_month_statistics_data_factory:
class: 'PrestaShop\Module\BlockWishList\Grid\Data\CurrentMonthStatisticsGridDataFactory'
arguments:
- '@doctrine.cache.provider'
- '@prestashop.module.blockwishlist.calculator.statistics_calculator'
- '@=service("prestashop.adapter.shop.context").getContextShopID()'
prestashop.module.blockwishlist.grid.current_day_statistics_data_factory:
class: 'PrestaShop\Module\BlockWishList\Grid\Data\CurrentDayStatisticsGridDataFactory'
arguments:
- '@doctrine.cache.provider'
- '@prestashop.module.blockwishlist.calculator.statistics_calculator'
- '@=service("prestashop.adapter.shop.context").getContextShopID()'
# Grid Factories
prestashop.module.blockwishlist.grid.all_time_stastistics_grid_factory:
class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory'
arguments:
- '@prestashop.module.blockwishlist.grid.all_time_statistics_grid_definition_factory'
- '@prestashop.module.blockwishlist.grid.all_time_statistics_data_factory'
- '@prestashop.core.grid.filter.form_factory'
- '@prestashop.core.hook.dispatcher'
prestashop.module.blockwishlist.grid.current_year_stastistics_grid_factory:
class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory'
arguments:
- '@prestashop.module.blockwishlist.grid.current_year_statistics_grid_definition_factory'
- '@prestashop.module.blockwishlist.grid.current_year_statistics_data_factory'
- '@prestashop.core.grid.filter.form_factory'
- '@prestashop.core.hook.dispatcher'
prestashop.module.blockwishlist.grid.current_month_stastistics_grid_factory:
class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory'
arguments:
- '@prestashop.module.blockwishlist.grid.current_month_statistics_grid_definition_factory'
- '@prestashop.module.blockwishlist.grid.current_month_statistics_data_factory'
- '@prestashop.core.grid.filter.form_factory'
- '@prestashop.core.hook.dispatcher'
prestashop.module.blockwishlist.grid.current_day_stastistics_grid_factory:
class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory'
arguments:
- '@prestashop.module.blockwishlist.grid.current_day_statistics_grid_definition_factory'
- '@prestashop.module.blockwishlist.grid.current_day_statistics_data_factory'
- '@prestashop.core.grid.filter.form_factory'
- '@prestashop.core.hook.dispatcher'

View File

@@ -0,0 +1,436 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PrestaShop\Module\BlockWishList\Access\CustomerAccess;
class BlockWishListActionModuleFrontController extends ModuleFrontController
{
public function postProcess()
{
if (false === $this->context->customer->isLogged()) {
$this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('You aren\'t logged in', [], 'Modules.Blockwishlist.Shop'),
])
);
exit;
}
$params = Tools::getValue('params');
// Here we call all methods dynamically given by the path
if (method_exists($this, Tools::getValue('action') . 'Action')) {
call_user_func([$this, Tools::getValue('action') . 'Action'], $params);
exit;
}
$this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('Unknown action', [], 'Modules.Blockwishlist.Shop'),
])
);
exit;
}
private function addProductToWishListAction($params)
{
$id_product = (int) $params['id_product'];
$product = new Product($id_product);
if (!Validate::isLoadedObject($product)) {
return $this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('There was an error adding the product', [], 'Modules.Blockwishlist.Shop'),
])
);
}
$idWishList = (int) $params['idWishList'];
$id_product_attribute = (int) $params['id_product_attribute'];
$quantity = (int) $params['quantity'];
if (0 === $quantity) {
$quantity = $product->minimal_quantity;
}
if (false === $this->assertProductAttributeExists($id_product, $id_product_attribute) && $id_product_attribute !== 0) {
return $this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('There was an error while adding the product attributes', [], 'Modules.Blockwishlist.Shop'),
])
);
}
$wishlist = new WishList($idWishList);
// Exit if not owner of the wishlist
$this->assertWriteAccess($wishlist);
$productIsAdded = $wishlist->addProduct(
$idWishList,
$this->context->customer->id,
$id_product,
$id_product_attribute,
$quantity
);
$newStat = new Statistics();
$newStat->id_product = $id_product;
$newStat->id_product_attribute = $id_product_attribute;
$newStat->id_shop = $this->context->shop->id;
$newStat->save();
if (false === $productIsAdded) {
return $this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('There was an error adding the product', [], 'Modules.Blockwishlist.Shop'),
])
);
}
Hook::exec('actionWishlistAddProduct', [
'idWishlist' => $idWishList,
'customerId' => $this->context->customer->id,
'idProduct' => $id_product,
'idProductAttribute' => $id_product_attribute,
]);
return $this->ajaxRender(
Tools::jsonEncode([
'success' => true,
'message' => $this->trans('Product added', [], 'Modules.Blockwishlist.Shop'),
])
);
}
private function createNewWishListAction($params)
{
if (isset($params['name'])) {
$wishlist = new WishList();
$wishlist->name = $params['name'];
$wishlist->id_shop_group = $this->context->shop->id_shop_group;
$wishlist->id_customer = $this->context->customer->id;
$wishlist->id_shop = $this->context->shop->id;
$wishlist->token = $this->generateWishListToken();
if (true === $wishlist->save()) {
return $this->ajaxRender(
Tools::jsonEncode([
'success' => true,
'message' => $this->trans('The list has been properly created', [], 'Modules.Blockwishlist.Shop'),
'datas' => [
'name' => $wishlist->name,
'id_wishlist' => $wishlist->id,
],
])
);
}
return $this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('Error saving the new list', [], 'Modules.Blockwishlist.Shop'),
])
);
} else {
return $this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('Missing name parameter', [], 'Modules.Blockwishlist.Shop'),
])
);
}
}
private function renameWishListAction($params)
{
if (isset($params['idWishList'], $params['name'])) {
$wishlist = new WishList($params['idWishList']);
// Exit if not owner of the wishlist
$this->assertWriteAccess($wishlist);
$wishlist->name = $params['name'];
if (true === $wishlist->save()) {
return $this->ajaxRender(
Tools::jsonEncode([
'success' => true,
'message' => $this->trans('List has been renamed', [], 'Modules.Blockwishlist.Shop'),
])
);
}
return $this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('List could not be renamed', [], 'Modules.Blockwishlist.Shop'),
])
);
}
return $this->ajaxRenderMissingParams();
}
private function deleteWishListAction($params)
{
if (isset($params['idWishList'])) {
$wishlist = new WishList($params['idWishList']);
// Exit if not owner of the wishlist
$this->assertWriteAccess($wishlist);
if (true === (bool) $wishlist->delete()) {
return $this->ajaxRender(
Tools::jsonEncode([
'success' => true,
'message' => $this->trans('List has been removed', [], 'Modules.Blockwishlist.Shop'),
])
);
}
return $this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('List deletion was unsuccessful', [], 'Modules.Blockwishlist.Shop'),
])
);
}
return $this->ajaxRenderMissingParams();
}
private function deleteProductFromWishListAction($params)
{
if (
isset($params['idWishList'])
&& isset($params['id_product'])
&& isset($params['id_product_attribute'])
) {
// Exit if not owner of the wishlist
$this->assertWriteAccess(
new WishList($params['idWishList'])
);
$isDeleted = WishList::removeProduct(
$params['idWishList'],
$this->context->customer->id,
$params['id_product'],
$params['id_product_attribute']
);
if (true === $isDeleted) {
return $this->ajaxRender(
Tools::jsonEncode([
'success' => true,
'message' => $this->trans('Product successfully removed', [], 'Modules.Blockwishlist.Shop'),
])
);
}
return $this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('Unable to remove product from list', [], 'Modules.Blockwishlist.Shop'),
])
);
}
return $this->ajaxRenderMissingParams();
}
private function updateProductFromWishListAction($params)
{
if (isset(
$params['idWishList'],
$params['id_product'],
$params['id_product_attribute'],
$params['priority'],
$params['quantity']
)) {
// Exit if not owner of the wishlist
$this->assertWriteAccess(
new WishList($params['idWishList'])
);
$isDeleted = WishList::updateProduct(
$params['idWishList'],
$params['id_product'],
$params['id_product_attribute'],
$params['priority'],
$params['quantity']
);
if (true === $isDeleted) {
return $this->ajaxRender(
Tools::jsonEncode([
'success' => true,
'message' => $this->trans('Product successfully updated', [], 'Modules.Blockwishlist.Shop'),
])
);
}
return $this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('Unable to update product from wishlist', [], 'Modules.Blockwishlist.Shop'),
])
);
}
return $this->ajaxRenderMissingParams();
}
private function getAllWishListAction()
{
$infos = WishList::getAllWishListsByIdCustomer($this->context->customer->id);
if (empty($infos)) {
$wishlist = new WishList();
$wishlist->id_shop = $this->context->shop->id;
$wishlist->id_shop_group = $this->context->shop->id_shop_group;
$wishlist->id_customer = $this->context->customer->id;
$wishlist->name = Configuration::get('blockwishlist_WishlistDefaultTitle', $this->context->language->id);
$wishlist->token = $this->generateWishListToken();
$wishlist->default = 1;
$wishlist->add();
$infos = WishList::getAllWishListsByIdCustomer($this->context->customer->id);
}
foreach ($infos as $key => $wishlist) {
$infos[$key]['shareUrl'] = $this->context->link->getModuleLink('blockwishlist', 'view', ['token' => $wishlist['token']]);
$infos[$key]['listUrl'] = $this->context->link->getModuleLink('blockwishlist', 'view', ['id_wishlist' => $wishlist['id_wishlist']]);
}
if (false === empty($infos)) {
return $this->ajaxRender(
Tools::jsonEncode([
'wishlists' => $infos,
])
);
}
return $this->ajaxRenderMissingParams();
}
private function generateWishListToken()
{
return Tools::strtoupper(substr(sha1(uniqid((string) rand(), true) . _COOKIE_KEY_ . $this->context->customer->id), 0, 16));
}
private function ajaxRenderMissingParams()
{
return $this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('Request is missing one or multiple parameters', [], 'Modules.Blockwishlist.Shop'),
])
);
}
private function addProductToCartAction($params)
{
$productAdd = WishList::addBoughtProduct(
$params['idWishlist'],
$params['id_product'],
$params['id_product_attribute'],
(int) $this->context->cart->id,
$params['quantity']
);
// Transform an add to favorite
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'blockwishlist_statistics`
SET `id_cart` = ' . (int) $this->context->cart->id . '
WHERE `id_cart` = 0
AND `id_product` = ' . (int) $params['id_product'] . '
AND `id_product_attribute` = ' . (int) $params['id_product_attribute'] . '
AND `id_shop`= ' . $this->context->shop->id
);
if (true === $productAdd) {
return $this->ajaxRender(
Tools::jsonEncode([
'success' => true,
'message' => $this->trans('Product added to cart', [], 'Modules.Blockwishlist.Shop'),
])
);
}
return $this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('Error when adding product to cart', [], 'Modules.Blockwishlist.Shop'),
])
);
}
private function getUrlByIdWishListAction($params)
{
$wishlist = new WishList($params['idWishList']);
return $this->ajaxRender(
Tools::jsonEncode([
'status' => 'true',
'url' => $this->context->link->getModuleLink('blockwishlist', 'view', ['token' => $wishlist->token]),
])
);
}
/**
* Stop the execution if the current customer isd not allowed to alter the wishlist
*
* @param WishList $wishlist
*/
private function assertWriteAccess(WishList $wishlist)
{
if ((new CustomerAccess($this->context->customer))->hasWriteAccessToWishlist($wishlist)) {
return;
}
$this->ajaxRender(
Tools::jsonEncode([
'success' => false,
'message' => $this->trans('You\'re not allowed to manage this list.', [], 'Modules.Blockwishlist.Shop'),
])
);
exit;
}
/**
* Check if product attribute id is related to the product
*
* @param int $id_product
* @param int $id_product_attribute
*
* @return bool
*/
private function assertProductAttributeExists($id_product, $id_product_attribute)
{
return Db::getInstance()->getValue(
'SELECT pas.`id_product_attribute` ' .
'FROM `' . _DB_PREFIX_ . 'product_attribute` pa ' .
'INNER JOIN `' . _DB_PREFIX_ . 'product_attribute_shop` pas ON (pas.id_product_attribute = pa.id_product_attribute) ' .
'WHERE pas.id_shop =' . (int) $this->context->shop->id . ' AND pa.`id_product` = ' . (int) $id_product . ' ' .
'AND pas.id_product_attribute = ' . (int) $id_product_attribute
);
}
}

View File

@@ -0,0 +1,110 @@
<?php
/*
* 2007-2016 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-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* @since 1.5.0
*/
class BlockWishListCartModuleFrontController extends ModuleFrontController
{
public $ssl = true;
public function __construct()
{
parent::__construct();
$this->context = Context::getContext();
include_once($this->module->getLocalPath().'WishList.php');
}
/**
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$context = Context::getContext();
$action = Tools::getValue('action');
$add = (!strcmp($action, 'add') ? 1 : 0);
$delete = (!strcmp($action, 'delete') ? 1 : 0);
$id_wishlist = (int)Tools::getValue('id_wishlist');
$id_product = (int)Tools::getValue('id_product');
$quantity = (int)Tools::getValue('quantity');
if (Tools::getIsset('group')) {
$id_product_attribute = (int)Product::getIdProductAttributesByIdAttributes($id_product, Tools::getValue('group'));
}
// Instance of module class for translations
$module = new BlockWishList();
if (Configuration::get('PS_TOKEN_ENABLE') == 1 &&
strcmp(Tools::getToken(false), Tools::getValue('token')) &&
$context->customer->isLogged() === true
)
echo $module->l('Invalid token', 'cart');
if ($context->customer->isLogged())
{
if ($id_wishlist && WishList::exists($id_wishlist, $context->customer->id) === true)
$context->cookie->id_wishlist = (int)$id_wishlist;
if ((int)$context->cookie->id_wishlist > 0 && !WishList::exists($context->cookie->id_wishlist, $context->customer->id))
$context->cookie->id_wishlist = '';
if (empty($context->cookie->id_wishlist) === true || $context->cookie->id_wishlist == false)
$context->smarty->assign('error', true);
if (($add || $delete) && empty($id_product) === false)
{
if (!isset($context->cookie->id_wishlist) || $context->cookie->id_wishlist == '')
{
$wishlist = new WishList();
$wishlist->id_shop = $context->shop->id;
$wishlist->id_shop_group = $context->shop->id_shop_group;
$wishlist->default = 1;
$mod_wishlist = new BlockWishList();
$wishlist->name = $mod_wishlist->default_wishlist_name;
$wishlist->id_customer = (int)$context->customer->id;
list($us, $s) = explode(' ', microtime());
srand($s * $us);
$wishlist->token = Tools::strtoupper(Tools::substr(sha1(uniqid(rand(), true)._COOKIE_KEY_.$context->customer->id), 0, 16));
$wishlist->add();
$context->cookie->id_wishlist = (int)$wishlist->id;
}
if ($add && $quantity)
WishList::addProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute, $quantity);
else if ($delete)
WishList::removeProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute);
}
$context->smarty->assign('products', WishList::getProductByIdCustomer($context->cookie->id_wishlist, $context->customer->id, $context->language->id, null, true));
if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/blockwishlist/blockwishlist-ajax.tpl'))
$context->smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/blockwishlist-ajax.tpl');
elseif (Tools::file_exists_cache(dirname(__FILE__).'/blockwishlist-ajax.tpl'))
$context->smarty->display(dirname(__FILE__).'/blockwishlist-ajax.tpl');
else
echo $module->l('No template found', 'cart');
} else
echo $module->l('You must be logged in to manage your wishlist.', 'cart');
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2016 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-2016 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;

View File

@@ -0,0 +1,69 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class BlockWishlistListsModuleFrontController extends ModuleFrontController
{
/**
* @var bool If set to true, will be redirected to authentication page
*/
public $auth = true;
public function initContent()
{
parent::initContent();
$this->context->smarty->assign(
[
'url' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'getAllWishlist']),
'createUrl' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'createNewWishlist']),
'deleteListUrl' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'deleteWishlist']),
'deleteProductUrl' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'deleteProductFromWishlist']),
'renameUrl' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'renameWishlist']),
'shareUrl' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'getUrlByIdWishlist']),
'addUrl' => $this->context->link->getModuleLink('blockwishlist', 'action', ['action' => 'addProductToWishlist']),
'accountLink' => '#',
'wishlistsTitlePage' => Configuration::get('blockwishlist_WishlistPageName', $this->context->language->id),
'newWishlistCTA' => Configuration::get('blockwishlist_CreateButtonLabel', $this->context->language->id),
]
);
$this->context->controller->registerJavascript(
'blockwishlistController',
'modules/blockwishlist/public/wishlistcontainer.bundle.js',
[
'priority' => 200,
]
);
$this->setTemplate('module:blockwishlist/views/templates/pages/lists.tpl');
}
public function getBreadcrumbLinks()
{
$breadcrumb = parent::getBreadcrumbLinks();
$breadcrumb['links'][] = $this->addMyAccountToBreadcrumb();
$breadcrumb['links'][] = [
'title' => Configuration::get('blockwishlist_WishlistPageName', $this->context->language->id),
'url' => $this->context->link->getModuleLink('blockwishlist', 'lists'),
];
return $breadcrumb;
}
}

View File

@@ -0,0 +1,247 @@
<?php
/*
* 2007-2016 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-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* @since 1.5.0
*/
class BlockWishListMyWishListModuleFrontController extends ModuleFrontController
{
public $ssl = true;
public function __construct()
{
parent::__construct();
$this->context = Context::getContext();
include_once($this->module->getLocalPath().'WishList.php');
}
/**
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$action = Tools::getValue('action');
if (!Tools::isSubmit('myajax'))
$this->assign();
elseif (!empty($action) && method_exists($this, 'ajaxProcess'.Tools::toCamelCase($action)))
$this->{'ajaxProcess'.Tools::toCamelCase($action)}();
else
die(Tools::jsonEncode(array('error' => 'method doesn\'t exist')));
}
/**
* Assign wishlist template
*/
public function assign()
{
$errors = array();
if ($this->context->customer->isLogged())
{
$add = Tools::getIsset('add');
$add = (empty($add) === false ? 1 : 0);
$delete = Tools::getIsset('deleted');
$delete = (empty($delete) === false ? 1 : 0);
$default = Tools::getIsset('default');
$default = (empty($default) === false ? 1 : 0);
$id_wishlist = Tools::getValue('id_wishlist');
if (Tools::isSubmit('submitWishlist'))
{
if (Configuration::get('PS_TOKEN_ACTIVATED') == 1 && strcmp(Tools::getToken(), Tools::getValue('token')))
$errors[] = $this->module->l('Invalid token', 'mywishlist');
if (!count($errors))
{
$name = Tools::getValue('name');
if (empty($name))
$errors[] = $this->module->l('You must specify a name.', 'mywishlist');
if (WishList::isExistsByNameForUser($name))
$errors[] = $this->module->l('This name is already used by another list.', 'mywishlist');
if (!count($errors))
{
$wishlist = new WishList();
$wishlist->id_shop = $this->context->shop->id;
$wishlist->id_shop_group = $this->context->shop->id_shop_group;
$wishlist->name = $name;
$wishlist->id_customer = (int)$this->context->customer->id;
!$wishlist->isDefault($wishlist->id_customer) ? $wishlist->default = 1 : '';
list($us, $s) = explode(' ', microtime());
srand($s * $us);
$wishlist->token = Tools::strtoupper(Tools::substr(sha1(uniqid(rand(), true)._COOKIE_KEY_.$this->context->customer->id), 0, 16));
$wishlist->add();
Mail::Send(
$this->context->language->id,
'wishlink',
Mail::l('Your wishlist\'s link', $this->context->language->id),
array(
'{wishlist}' => $wishlist->name,
'{message}' => $this->context->link->getModuleLink('blockwishlist', 'view', array('token' => $wishlist->token))
),
$this->context->customer->email,
$this->context->customer->firstname.' '.$this->context->customer->lastname,
null,
strval(Configuration::get('PS_SHOP_NAME')),
null,
null,
$this->module->getLocalPath().'mails/');
Tools::redirect($this->context->link->getModuleLink('blockwishlist', 'mywishlist'));
}
}
}
else if ($add)
WishList::addCardToWishlist($this->context->customer->id, Tools::getValue('id_wishlist'), $this->context->language->id);
elseif ($delete && empty($id_wishlist) === false)
{
$wishlist = new WishList((int)$id_wishlist);
if ($this->context->customer->isLogged() && $this->context->customer->id == $wishlist->id_customer && Validate::isLoadedObject($wishlist))
$wishlist->delete();
else
$errors[] = $this->module->l('Cannot delete this wishlist', 'mywishlist');
}
elseif ($default)
{
$wishlist = new WishList((int)$id_wishlist);
if ($this->context->customer->isLogged() && $this->context->customer->id == $wishlist->id_customer && Validate::isLoadedObject($wishlist))
$wishlist->setDefault();
else
$errors[] = $this->module->l('Cannot delete this wishlist', 'mywishlist');
}
$this->context->smarty->assign('wishlists', WishList::getByIdCustomer($this->context->customer->id));
$this->context->smarty->assign('nbProducts', WishList::getInfosByIdCustomer($this->context->customer->id));
}
else
Tools::redirect('index.php?controller=authentication&back='.urlencode($this->context->link->getModuleLink('blockwishlist', 'mywishlist')));
$this->context->smarty->assign(array(
'id_customer' => (int)$this->context->customer->id,
'errors' => $errors,
'form_link' => $errors,
'base_url' => $this->context->link->getBaseLink($this->context->shop->id),
));
$this->setTemplate('module:blockwishlist/views/templates/front/mywishlist.tpl');
}
public function ajaxProcessDeleteList()
{
if (!$this->context->customer->isLogged())
die(Tools::jsonEncode(array('success' => false,
'error' => $this->module->l('You aren\'t logged in', 'mywishlist'))));
$default = Tools::getIsset('default');
$default = (empty($default) === false ? 1 : 0);
$id_wishlist = Tools::getValue('id_wishlist');
$wishlist = new WishList((int)$id_wishlist);
if (Validate::isLoadedObject($wishlist) && $wishlist->id_customer == $this->context->customer->id)
{
$default_change = $wishlist->default ? true : false;
$id_customer = $wishlist->id_customer;
$wishlist->delete();
}
else
die(Tools::jsonEncode(array('success' => false,
'error' => $this->module->l('Cannot delete this wishlist', 'mywishlist'))));
if ($default_change)
{
$array = WishList::getDefault($id_customer);
if (count($array))
die(Tools::jsonEncode(array(
'success' => true,
'id_default' => $array[0]['id_wishlist']
)));
}
die(Tools::jsonEncode(array('success' => true)));
}
public function ajaxProcessSetDefault()
{
if (!$this->context->customer->isLogged())
die(Tools::jsonEncode(array('success' => false,
'error' => $this->module->l('You aren\'t logged in', 'mywishlist'))));
$default = Tools::getIsset('default');
$default = (empty($default) === false ? 1 : 0);
$id_wishlist = Tools::getValue('id_wishlist');
if ($default)
{
$wishlist = new WishList((int)$id_wishlist);
if (Validate::isLoadedObject($wishlist) && $wishlist->id_customer == $this->context->customer->id && $wishlist->setDefault())
die(Tools::jsonEncode(array('success' => true)));
}
die(Tools::jsonEncode(array('error' => true)));
}
public function ajaxProcessProductChangeWishlist()
{
if (!$this->context->customer->isLogged())
die(Tools::jsonEncode(array('success' => false,
'error' => $this->module->l('You aren\'t logged in', 'mywishlist'))));
$id_product = (int)Tools::getValue('id_product');
$id_product_attribute = (int)Tools::getValue('id_product_attribute');
$quantity = (int)Tools::getValue('quantity');
$priority = (int)Tools::getValue('priority');
$id_old_wishlist = (int)Tools::getValue('id_old_wishlist');
$id_new_wishlist = (int)Tools::getValue('id_new_wishlist');
$new_wishlist = new WishList((int)$id_new_wishlist);
$old_wishlist = new WishList((int)$id_old_wishlist);
//check the data is ok
if (!$id_product || !is_int($id_product_attribute) || !$quantity ||
!is_int($priority) || ($priority < 0 && $priority > 2) || !$id_old_wishlist || !$id_new_wishlist ||
(Validate::isLoadedObject($new_wishlist) && $new_wishlist->id_customer != $this->context->customer->id) ||
(Validate::isLoadedObject($old_wishlist) && $old_wishlist->id_customer != $this->context->customer->id))
die(Tools::jsonEncode(array('success' => false, 'error' => $this->module->l('Error while moving product to another list', 'mywishlist'))));
$res = true;
$check = (int)Db::getInstance()->getValue('SELECT quantity FROM '._DB_PREFIX_.'wishlist_product
WHERE `id_product` = '.$id_product.' AND `id_product_attribute` = '.$id_product_attribute.' AND `id_wishlist` = '.$id_new_wishlist);
if ($check)
{
$res &= $old_wishlist->removeProduct($id_old_wishlist, $this->context->customer->id, $id_product, $id_product_attribute);
$res &= $new_wishlist->updateProduct($id_new_wishlist, $id_product, $id_product_attribute, $priority, $quantity + $check);
}
else
{
$res &= $old_wishlist->removeProduct($id_old_wishlist, $this->context->customer->id, $id_product, $id_product_attribute);
$res &= $new_wishlist->addProduct($id_new_wishlist, $this->context->customer->id, $id_product, $id_product_attribute, $quantity);
}
if (!$res)
die(Tools::jsonEncode(array('success' => false, 'error' => $this->module->l('Error while moving product to another list', 'mywishlist'))));
die(Tools::jsonEncode(array('success' => true, 'msg' => $this->module->l('The product has been correctly moved', 'mywishlist'))));
}
}

View File

@@ -0,0 +1,317 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PrestaShop\Module\BlockWishList\Access\CustomerAccess;
use PrestaShop\Module\BlockWishList\Search\WishListProductSearchProvider;
use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery;
use PrestaShop\PrestaShop\Core\Product\Search\SortOrder;
use PrestaShop\PrestaShop\Core\Product\Search\SortOrderFactory;
/**
* View the content of a personal wishlist
*/
class BlockWishlistViewModuleFrontController extends ProductListingFrontController
{
/**
* Made public as the core considers this class as an ModuleFrontController
* and other modules expects to find the $module property.
*
* @var BlockWishList
*/
public $module;
/**
* @var WishList
*/
protected $wishlist;
/**
* @var CustomerAccess
*/
private $customerAccess;
public function __construct()
{
/** @var BlockWishList $module */
$module = Module::getInstanceByName('blockwishlist');
$this->module = $module;
if (empty($this->module->active)) {
Tools::redirect('index');
}
parent::__construct();
$this->controller_type = 'modulefront';
$this->customerAccess = new CustomerAccess($this->context->customer);
}
/**
* {@inheritdoc}
*/
public function init()
{
$id_wishlist = $this->getWishlistId();
$this->wishlist = new WishList($id_wishlist);
if (false === Validate::isLoadedObject($this->wishlist)) {
Tools::redirect('index.php?controller=404');
}
parent::init();
if (false === $this->customerAccess->hasReadAccessToWishlist($this->wishlist)) {
header('HTTP/1.1 403 Forbidden');
header('Status: 403 Forbidden');
$this->errors[] = $this->trans(
'You do not have access to this wishlist.',
[],
'Modules.Blockwishlist.Shop'
);
$this->setTemplate('errors/forbidden');
return;
}
$this->context->smarty->assign(
[
'id' => $id_wishlist,
'wishlistName' => $this->wishlist->name,
'isGuest' => !$this->customerAccess->hasWriteAccessToWishlist($this->wishlist),
'url' => Context::getContext()->link->getModuleLink('blockwishlist', 'view', $this->getAccessParams()),
'wishlistsLink' => Context::getContext()->link->getModuleLink('blockwishlist', 'lists'),
'deleteProductUrl' => Context::getContext()->link->getModuleLink('blockwishlist', 'action', ['action' => 'deleteProductFromWishlist']),
]
);
}
/**
* {@inheritdoc}
*/
public function initContent()
{
parent::initContent();
if (false === $this->customerAccess->hasReadAccessToWishlist($this->wishlist)) {
return;
}
$this->context->controller->registerJavascript(
'blockwishlistController',
'modules/blockwishlist/public/productslist.bundle.js',
[
'priority' => 200,
]
);
$this->doProductSearch(
'../../../modules/blockwishlist/views/templates/pages/products-list.tpl',
[
'entity' => 'wishlist_product',
'id_wishlist' => $this->wishlist->id,
]
);
}
/**
* {@inheritdoc}
*/
public function getListingLabel()
{
return $this->trans(
'WishList: %wishlist_name%',
['%wishlist_name%' => $this->wishlist->name],
'Modules.Blockwishlist.Shop'
);
}
/**
* {@inheritdoc}
*/
protected function getProductSearchQuery()
{
$query = new ProductSearchQuery();
$query->setSortOrder(
new SortOrder(
'product',
Tools::getProductsOrder('by'),
Tools::getProductsOrder('way')
)
);
return $query;
}
/**
* {@inheritdoc}
*/
protected function getDefaultProductSearchProvider()
{
return new WishListProductSearchProvider(
Db::getInstance(),
$this->wishlist,
new SortOrderFactory($this->getTranslator()),
$this->getTranslator()
);
}
/**
* {@inheritdoc}
*/
protected function getAjaxProductSearchVariables()
{
parent::getAjaxProductSearchVariables();
$context = parent::getProductSearchContext();
$query = $this->getProductSearchQuery();
$provider = $this->getDefaultProductSearchProvider();
$resultsPerPage = (int) Tools::getValue('resultsPerPage');
if ($resultsPerPage <= 0) {
$resultsPerPage = Configuration::get('PS_PRODUCTS_PER_PAGE');
}
// we need to set a few parameters from back-end preferences
$query
->setResultsPerPage($resultsPerPage)
->setPage(max((int) Tools::getValue('page'), 1))
;
// set the sort order if provided in the URL
if (($encodedSortOrder = Tools::getValue('order'))) {
$query->setSortOrder(SortOrder::newFromString($encodedSortOrder));
}
// get the parameters containing the encoded facets from the URL
$encodedFacets = Tools::getValue('q');
$query->setEncodedFacets($encodedFacets);
$result = $provider->runQuery($context, $query);
if (!$result->getCurrentSortOrder()) {
$result->setCurrentSortOrder($query->getSortOrder());
}
// prepare the products
$products = $this->prepareMultipleProductsForTemplate($result->getProducts());
// render the facets with the core
$rendered_facets = $this->renderFacets($result);
$rendered_active_filters = $this->renderActiveFilters($result);
$pagination = $this->getTemplateVarPagination($query, $result);
// prepare the sort orders
// note that, again, the product controller is sort-orders agnostic
// a module can easily add specific sort orders that it needs to support (e.g. sort by "energy efficiency")
$sort_orders = $this->getTemplateVarSortOrders(
$result->getAvailableSortOrders(),
$query->getSortOrder()->toString()
);
$sort_selected = false;
$labelDefaultSort = '';
if (!empty($sort_orders)) {
foreach ($sort_orders as $order) {
if ($order['field'] == 'id_wishlist_product') {
$labelDefaultSort = $order['label'];
}
if (isset($order['current']) && true === $order['current']) {
$sort_selected = $order['label'];
break;
}
}
}
$searchVariables = [
'result' => $result,
'label' => $this->getListingLabel(),
'products' => $products,
'sort_orders' => $sort_orders,
'sort_selected' => $sort_selected ? $sort_selected : $labelDefaultSort,
'pagination' => $pagination,
'rendered_facets' => $rendered_facets,
'rendered_active_filters' => $rendered_active_filters,
'js_enabled' => $this->ajax,
'current_url' => $this->updateQueryString([
'q' => $result->getEncodedFacets(),
]),
];
Hook::exec('filterProductSearch', ['searchVariables' => &$searchVariables]);
Hook::exec('actionProductSearchAfter', $searchVariables);
return $searchVariables;
}
/**
* Depending on the parameters sent, checks if the current visitor may reach the page
*
* @return int|false
*/
private function getWishlistId()
{
if (Tools::getIsset('id_wishlist')) {
return (int) Tools::getValue('id_wishlist');
}
if (Tools::getIsset('token')) {
$wishlistData = WishList::getByToken(
Tools::getValue('token')
);
if (!empty($wishlistData['id_wishlist'])) {
return $wishlistData['id_wishlist'];
}
}
return false;
}
/**
* @return array
*/
private function getAccessParams()
{
if (Tools::getIsset('token')) {
return ['token' => Tools::getValue('token')];
}
if (Tools::getIsset('id_wishlist')) {
return ['id_wishlist' => Tools::getValue('id_wishlist')];
}
return [];
}
public function getBreadcrumbLinks()
{
$breadcrumb = parent::getBreadcrumbLinks();
$breadcrumb['links'][] = $this->addMyAccountToBreadcrumb();
$breadcrumb['links'][] = [
'title' => Configuration::get('blockwishlist_WishlistPageName', $this->context->language->id),
'url' => $this->context->link->getModuleLink('blockwishlist', 'lists'),
];
$breadcrumb['links'][] = [
'title' => $this->wishlist->name,
'url' => Context::getContext()->link->getModuleLink('blockwishlist', 'view', $this->getAccessParams()),
];
return $breadcrumb;
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (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;

View File

@@ -0,0 +1,128 @@
[09-May-2017 22:10:32 America/Chicago] PHP Fatal error: Class 'ObjectModel' not found in /home3/ets/public_html/etssoft.net/demo/ebusiness/modules/blockwishlist/WishList.php on line 28
[09-May-2017 23:20:07 US/Eastern] PHP Fatal error: Call to a member function getProductLink() on null in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 51
[09-May-2017 23:21:09 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusiness/modules/blockwishlist/cart.php on line 77
[09-May-2017 23:21:09 US/Eastern] PHP Notice: Undefined index: link in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 51
[09-May-2017 23:21:09 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 51
[09-May-2017 23:21:09 US/Eastern] PHP Fatal error: Call to a member function getProductLink() on null in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 51
[09-May-2017 23:23:49 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusiness/modules/blockwishlist/cart.php on line 77
[09-May-2017 23:23:49 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[09-May-2017 23:23:49 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[09-May-2017 23:24:42 US/Eastern] PHP Fatal error: Call to a member function getModuleLink() on null in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 82
[09-May-2017 23:31:06 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusiness/modules/blockwishlist/cart.php on line 77
[09-May-2017 23:31:06 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[09-May-2017 23:31:06 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[11-May-2017 23:54:31 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusiness/modules/blockwishlist/cart.php on line 77
[11-May-2017 23:54:32 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[11-May-2017 23:54:32 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[11-May-2017 23:54:32 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[11-May-2017 23:54:32 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[11-May-2017 23:56:40 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusiness/modules/blockwishlist/cart.php on line 77
[11-May-2017 23:56:40 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[11-May-2017 23:56:40 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[11-May-2017 23:56:45 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusiness/modules/blockwishlist/cart.php on line 77
[11-May-2017 23:56:45 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[11-May-2017 23:56:45 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[11-May-2017 23:56:45 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[11-May-2017 23:56:45 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[12-May-2017 03:10:35 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusiness/modules/blockwishlist/cart.php on line 77
[12-May-2017 03:10:35 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[12-May-2017 03:10:35 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[12-May-2017 03:10:35 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[12-May-2017 03:10:35 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[19-May-2017 22:44:50 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusiness/modules/blockwishlist/cart.php on line 77
[19-May-2017 22:44:50 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[19-May-2017 22:44:50 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[19-May-2017 22:44:56 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusiness/modules/blockwishlist/cart.php on line 77
[19-May-2017 22:44:57 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[19-May-2017 22:44:57 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusiness/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 04:00:37 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 04:00:38 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 04:00:38 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 04:00:48 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 04:00:48 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 04:00:48 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 04:21:09 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 04:21:09 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 04:21:09 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 22:52:58 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 22:52:58 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 22:52:58 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 22:52:58 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 22:52:58 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 22:52:59 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 22:52:59 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 22:52:59 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:09:29 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 23:09:30 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:09:30 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:09:30 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:09:30 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:22 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 23:17:23 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:23 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:23 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:23 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:27 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 23:17:28 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:28 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:28 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:28 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:30 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 23:17:31 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 23:17:31 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:31 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:31 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:31 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:32 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:32 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:32 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:32 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:34 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 23:17:34 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:34 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:34 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:34 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:35 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 23:17:36 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:36 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:36 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:36 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:36 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 23:17:36 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 23:17:37 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:37 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:37 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:37 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:37 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:37 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:37 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:17:37 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:19:09 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 23:19:09 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:19:09 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:19:09 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:19:09 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:21:59 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[24-Jun-2017 23:22:00 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[24-Jun-2017 23:22:00 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:45:09 US/Eastern] PHP Notice: Undefined variable: id_product_attribute in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/modules/blockwishlist/cart.php on line 77
[25-Jun-2017 02:45:09 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:45:09 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:52:27 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:52:27 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:52:27 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:52:27 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:57:01 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:57:01 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:57:01 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:57:01 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:57:47 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:57:47 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:57:47 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:57:47 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:58:17 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:58:17 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:58:17 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:58:17 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:58:17 US/Eastern] PHP Notice: Undefined index: img_dir in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58
[25-Jun-2017 02:58:17 US/Eastern] PHP Notice: Trying to get property of non-object in /home3/ets/public_html/etssoft.net/demo/ebusinessdemo/vendor/prestashop/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 58

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2016 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-2016 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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 898 B

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2016 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-2016 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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 815 B

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (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;

View File

@@ -0,0 +1,36 @@
CREATE TABLE IF NOT EXISTS `PREFIX_wishlist` (
`id_wishlist` int(10) unsigned NOT NULL auto_increment,
`id_customer` int(10) unsigned NOT NULL,
`token` varchar(64) character set utf8 NOT NULL,
`name` varchar(64) character set utf8 NOT NULL,
`counter` int(10) unsigned NULL,
`id_shop` int(10) unsigned default 1,
`id_shop_group` int(10) unsigned default 1,
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
`default` int(10) unsigned default 0,
PRIMARY KEY (`id_wishlist`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `PREFIX_wishlist_email` (
`id_wishlist` int(10) unsigned NOT NULL,
`email` varchar(128) character set utf8 NOT NULL,
`date_add` datetime NOT NULL
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `PREFIX_wishlist_product` (
`id_wishlist_product` int(10) NOT NULL auto_increment,
`id_wishlist` int(10) unsigned NOT NULL,
`id_product` int(10) unsigned NOT NULL,
`id_product_attribute` int(10) unsigned NOT NULL,
`quantity` int(10) unsigned NOT NULL,
`priority` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_wishlist_product`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `PREFIX_wishlist_product_cart` (
`id_wishlist_product` int(10) unsigned NOT NULL,
`id_cart` int(10) unsigned NOT NULL,
`quantity` int(10) unsigned NOT NULL,
`date_add` datetime NOT NULL
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;

View File

@@ -0,0 +1,470 @@
/*
* 2007-2016 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-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* Update WishList Cart by adding, deleting, updating objects
*
* @return void
*/
//global variables
//var wishlistProductsIds = new Array(400);
$(document).ready(function(){
wishlistRefreshStatus();
$(document).on('change', 'select[name=wishlists]', function(){
WishlistChangeDefault('wishlist_block_list', $(this).val());
});
$('.wishlist').each(function() {
current = $(this);
$(this).children('.wishlist_button_list').popover({
html: true,
content: function () {
return current.children('.popover-content').html();
}
});
});
});
function WishlistCart(id, action, id_product, id_product_attribute, quantity, id_wishlist)
{
$.ajax({
type: 'GET',
url: baseDir + 'modules/blockwishlist/cart.php?rand=' + new Date().getTime(),
headers: { "cache-control": "no-cache" },
async: true,
cache: false,
data: 'action=' + action + '&id_product=' + id_product + '&quantity=' + quantity + '&token=' + static_token + '&id_product_attribute=' + id_product_attribute + '&id_wishlist=' + id_wishlist,
success: function(data)
{
if (action == 'add')
{
if (isLogged == true) {
wishlistProductsIdsAdd(id_product);
wishlistRefreshStatus();
if (!!$.prototype.fancybox)
$.fancybox.open([
{
type: 'inline',
autoScale: true,
minHeight: 30,
content: '<p class="fancybox-error">' + added_to_wishlist + '</p>'
}
], {
padding: 0
});
else
alert(added_to_wishlist);
}
else
{
if (!!$.prototype.fancybox)
$.fancybox.open([
{
type: 'inline',
autoScale: true,
minHeight: 30,
content: '<p class="fancybox-error">' + loggin_required + '</p>'
}
], {
padding: 0
});
else
alert(loggin_required);
}
}
if (action == 'delete') {
wishlistProductsIdsRemove(id_product);
wishlistRefreshStatus();
}
if($('#' + id).length != 0)
{
$('#' + id).slideUp('normal');
document.getElementById(id).innerHTML = data;
$('#' + id).slideDown('normal');
}
}
});
}
/**
* Change customer default wishlist
*
* @return void
*/
function WishlistChangeDefault(id, id_wishlist)
{
$.ajax({
type: 'GET',
url: baseDir + 'modules/blockwishlist/cart.php?rand=' + new Date().getTime(),
headers: { "cache-control": "no-cache" },
async: true,
data: 'id_wishlist=' + id_wishlist + '&token=' + static_token,
cache: false,
success: function(data)
{
$('#' + id).slideUp('normal');
document.getElementById(id).innerHTML = data;
$('#' + id).slideDown('normal');
}
});
}
/**
* Buy Product
*
* @return void
*/
function WishlistBuyProduct(token, id_product, id_product_attribute, id_quantity, button, ajax)
{
if(ajax)
ajaxCart.add(id_product, id_product_attribute, false, button, 1, [token, id_quantity]);
else
{
$('#' + id_quantity).val(0);
WishlistAddProductCart(token, id_product, id_product_attribute, id_quantity)
document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].method='POST';
document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].action=baseUri + '?controller=cart';
document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].elements['token'].value = static_token;
document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].submit();
}
return (true);
}
function WishlistAddProductCart(token, id_product, id_product_attribute, id_quantity)
{
if ($('#' + id_quantity).val() <= 0)
return (false);
$.ajax({
type: 'GET',
url: baseDir + 'modules/blockwishlist/buywishlistproduct.php?rand=' + new Date().getTime(),
headers: { "cache-control": "no-cache" },
data: 'token=' + token + '&static_token=' + static_token + '&id_product=' + id_product + '&id_product_attribute=' + id_product_attribute,
async: true,
cache: false,
success: function(data)
{
if (data)
{
if (!!$.prototype.fancybox)
$.fancybox.open([
{
type: 'inline',
autoScale: true,
minHeight: 30,
content: '<p class="fancybox-error">' + data + '</p>'
}
], {
padding: 0
});
else
alert(data);
}
else
$('#' + id_quantity).val($('#' + id_quantity).val() - 1);
}
});
return (true);
}
/**
* Show wishlist managment page
*
* @return void
*/
function WishlistManage(id, id_wishlist)
{
$.ajax({
type: 'GET',
async: true,
url: baseDir + 'modules/blockwishlist/managewishlist.php?rand=' + new Date().getTime(),
headers: { "cache-control": "no-cache" },
data: 'id_wishlist=' + id_wishlist + '&refresh=' + false,
cache: false,
success: function(data)
{
$('#' + id).hide();
document.getElementById(id).innerHTML = data;
$('#' + id).fadeIn('slow');
$('.wishlist_change_button').each(function(index) {
$(this).change(function () {
wishlistProductChange($('option:selected', this).attr('data-id-product'), $('option:selected', this).attr('data-id-product-attribute'), $('option:selected', this).attr('data-id-old-wishlist'), $('option:selected', this).attr('data-id-new-wishlist'));
});
});
}
});
}
/**
* Show wishlist product managment page
*
* @return void
*/
function WishlistProductManage(id, action, id_wishlist, id_product, id_product_attribute, quantity, priority)
{
$.ajax({
type: 'GET',
async: true,
url: baseDir + 'modules/blockwishlist/managewishlist.php?rand=' + new Date().getTime(),
headers: { "cache-control": "no-cache" },
data: 'action=' + action + '&id_wishlist=' + id_wishlist + '&id_product=' + id_product + '&id_product_attribute=' + id_product_attribute + '&quantity=' + quantity + '&priority=' + priority + '&refresh=' + true,
cache: false,
success: function(data)
{
if (action == 'delete')
$('#wlp_' + id_product + '_' + id_product_attribute).fadeOut('fast');
else if (action == 'update')
{
$('#wlp_' + id_product + '_' + id_product_attribute).fadeOut('fast');
$('#wlp_' + id_product + '_' + id_product_attribute).fadeIn('fast');
}
nb_products = 0;
$("[id^='quantity']").each(function(index, element){
nb_products += parseInt(element.value);
});
$("#wishlist_"+id_wishlist).children('td').eq(1).html(nb_products);
}
});
}
/**
* Delete wishlist
*
* @return boolean succeed
*/
function WishlistDelete(id, id_wishlist, msg)
{
var res = confirm(msg);
if (res == false)
return (false);
if (typeof mywishlist_url == 'undefined')
return (false);
$.ajax({
type: 'GET',
async: true,
dataType: "json",
url: mywishlist_url,
headers: { "cache-control": "no-cache" },
cache: false,
data: {
rand: new Date().getTime(),
deleted: 1,
myajax: 1,
id_wishlist: id_wishlist,
action: 'deletelist'
},
success: function(data)
{
var mywishlist_siblings_count = $('#' + id).siblings().length;
$('#' + id).fadeOut('slow').remove();
$("#block-order-detail").html('');
if (mywishlist_siblings_count == 0)
$("#block-history").remove();
if (data.id_default)
{
var td_default = $("#wishlist_"+data.id_default+" > .wishlist_default");
$("#wishlist_"+data.id_default+" > .wishlist_default > a").remove();
td_default.append('<p class="is_wish_list_default"><i class="icon icon-check-square"></i></p>');
}
}
});
}
function WishlistDefault(id, id_wishlist)
{
if (typeof mywishlist_url == 'undefined')
return (false);
$.ajax({
type: 'GET',
async: true,
url: mywishlist_url,
headers: { "cache-control": "no-cache" },
cache: false,
data: {
rand:new Date().getTime(),
'default': 1,
id_wishlist:id_wishlist,
myajax: 1,
action: 'setdefault'
},
success: function (data)
{
var old_default_id = $(".is_wish_list_default").parents("tr").attr("id");
var td_check = $(".is_wish_list_default").parent();
$(".is_wish_list_default").remove();
td_check.append('<a href="#" onclick="javascript:event.preventDefault();(WishlistDefault(\''+old_default_id+'\', \''+old_default_id.replace("wishlist_", "")+'\'));"><i class="icon icon-square"></i></a>');
var td_default = $("#"+id+" > .wishlist_default");
$("#"+id+" > .wishlist_default > a").remove();
td_default.append('<p class="is_wish_list_default"><i class="icon icon-check-square"></i></p>');
}
});
}
/**
* Hide/Show bought product
*
* @return void
*/
function WishlistVisibility(bought_class, id_button)
{
if ($('#hide' + id_button).is(':hidden'))
{
$('.' + bought_class).slideDown('fast');
$('#show' + id_button).hide();
$('#hide' + id_button).css('display', 'block');
}
else
{
$('.' + bought_class).slideUp('fast');
$('#hide' + id_button).hide();
$('#show' + id_button).css('display', 'block');
}
}
/**
* Send wishlist by email
*
* @return void
*/
function WishlistSend(id, id_wishlist, id_email)
{
$.post(
baseDir + 'modules/blockwishlist/sendwishlist.php',
{
token: static_token,
id_wishlist: id_wishlist,
email1: $('#' + id_email + '1').val(),
email2: $('#' + id_email + '2').val(),
email3: $('#' + id_email + '3').val(),
email4: $('#' + id_email + '4').val(),
email5: $('#' + id_email + '5').val(),
email6: $('#' + id_email + '6').val(),
email7: $('#' + id_email + '7').val(),
email8: $('#' + id_email + '8').val(),
email9: $('#' + id_email + '9').val(),
email10: $('#' + id_email + '10').val()
},
function(data)
{
if (data)
{
if (!!$.prototype.fancybox)
$.fancybox.open([
{
type: 'inline',
autoScale: true,
minHeight: 30,
content: '<p class="fancybox-error">' + data + '</p>'
}
], {
padding: 0
});
else
alert(data);
}
else
WishlistVisibility(id, 'hideSendWishlist');
}
);
}
function wishlistProductsIdsAdd(id)
{
if ($.inArray(parseInt(id),wishlistProductsIds) == -1)
wishlistProductsIds.push(id);
}
function wishlistProductsIdsRemove(id)
{
wishlistProductsIds.splice($.inArray(parseInt(id),wishlistProductsIds), 1)
}
function wishlistRefreshStatus()
{
$('.addToWishlist').each(function(){
if ($.inArray(parseInt($(this).prop('rel')),wishlistProductsIds)!= -1)
$(this).addClass('checked');
else
$(this).removeClass('checked');
});
}
function wishlistProductChange(id_product, id_product_attribute, id_old_wishlist, id_new_wishlist)
{
if (typeof mywishlist_url == 'undefined')
return (false);
var quantity = $('#quantity_' + id_product + '_' + id_product_attribute).val();
$.ajax({
type: 'GET',
url: mywishlist_url,
headers: { "cache-control": "no-cache" },
async: true,
cache: false,
dataType: "json",
data: {
id_product:id_product,
id_product_attribute:id_product_attribute,
quantity: quantity,
priority: $('#priority_' + id_product + '_' + id_product_attribute).val(),
id_old_wishlist:id_old_wishlist,
id_new_wishlist:id_new_wishlist,
myajax: 1,
action: 'productchangewishlist'
},
success: function (data)
{
if (data.success == true) {
$('#wlp_' + id_product + '_' + id_product_attribute).fadeOut('slow');
$('#wishlist_' + id_old_wishlist + ' td:nth-child(2)').text($('#wishlist_' + id_old_wishlist + ' td:nth-child(2)').text() - quantity);
$('#wishlist_' + id_new_wishlist + ' td:nth-child(2)').text(+$('#wishlist_' + id_new_wishlist + ' td:nth-child(2)').text() + +quantity);
}
else
{
if (!!$.prototype.fancybox)
$.fancybox.open([
{
type: 'inline',
autoScale: true,
minHeight: 30,
content: '<p class="fancybox-error">' + data.error + '</p>'
}
], {
padding: 0
});
}
}
});
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2016 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-2016 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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Some files were not shown because too many files have changed in this diff Show More