public function hookRightColumn($params) { global $errors; require_once dirname(__FILE__) . '/WishList.php'; 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 (!sizeof($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->smarty->assign(array('wishlist_link' => $this->context->link->getModuleLink('blockwishlist', 'mywishlist'))); return $this->display(__FILE__, 'blockwishlist.tpl'); }
public function hookRightColumn($params) { 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)); } return $this->display(__FILE__, 'blockwishlist.tpl'); }
$quantity = (int) Tools::getValue('quantity'); $id_product_attribute = (int) Tools::getValue('id_product_attribute'); if (Configuration::get('PS_TOKEN_ENABLE') == 1 and strcmp(Tools::getToken(false), Tools::getValue('token')) and $cookie->isLogged() === true) { echo Tools::displayError('Invalid token'); } if ($cookie->isLogged()) { if ($id_wishlist and WishList::exists($id_wishlist, $cookie->id_customer) === true) { $cookie->id_wishlist = (int) $id_wishlist; } if (empty($cookie->id_wishlist) === true or $cookie->id_wishlist == false) { $smarty->assign('error', true); } if (($add or $delete) and empty($id_product) === false) { if (!isset($cookie->id_wishlist) or $cookie->id_wishlist == '') { // Try to get an existing wishlist before creating a new one (useful if there is no wishlist block hooked left or right) $wishlists = Wishlist::getByIdCustomer($cookie->id_customer); if (!empty($wishlists)) { $id_wishlist = (int) $wishlists[0]['id_wishlist']; $cookie->id_wishlist = (int) $id_wishlist; } else { $wishlist = new WishList(); $modWishlist = new BlockWishList(); $wishlist->name = $modWishlist->default_wishlist_name; $wishlist->id_customer = (int) $cookie->id_customer; list($us, $s) = explode(' ', microtime()); srand($s * $us); $wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true) . _COOKIE_KEY_ . $cookie->id_customer), 0, 16)); $wishlist->add(); $cookie->id_wishlist = (int) $wishlist->id; } }
public function hookRightColumn($params) { global $smarty; global $errors; if (Configuration::get('PS_BLOCK_WISHLIST_ACTIVATED') == 0) { return null; } require_once dirname(__FILE__) . '/WishList.php'; if ($params['cookie']->isLogged()) { $wishlists = Wishlist::getByIdCustomer($params['cookie']->id_customer); if (empty($params['cookie']->id_wishlist) === true || WishList::exists($params['cookie']->id_wishlist, $params['cookie']->id_customer) === false) { if (!sizeof($wishlists)) { $id_wishlist = false; } else { $id_wishlist = intval($wishlists[0]['id_wishlist']); $params['cookie']->id_wishlist = intval($id_wishlist); } } else { $id_wishlist = $params['cookie']->id_wishlist; } $smarty->assign(array('id_wishlist' => $id_wishlist, 'isLogged' => true, 'products' => $id_wishlist == false ? false : WishList::getProductByIdCustomer($id_wishlist, $params['cookie']->id_customer, $params['cookie']->id_lang, null, true), 'wishlists' => $wishlists, 'ptoken' => Tools::getToken(false))); } else { $smarty->assign(array('products' => false, 'wishlists' => false)); } return $this->display(__FILE__, 'blockwishlist.tpl'); }
public function hookdisplayProductButtons($params) { $id_product = (int) Tools::getValue('id_product'); $this->smarty->assign(array('id_product' => $id_product)); if ($this->context->customer->isLogged()) { $this->smarty->assign('wishlists', Wishlist::getByIdCustomer($this->context->customer->id)); } $this->smarty->assign('in_wishlist', false); if (!empty($wishlists)) { foreach ($wishlists = Wishlist::getByIdCustomer($this->context->customer->id) as $value) { $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) $value['id_wishlist'] . ' AND w.`id_customer` = ' . (int) $this->context->customer->id . ' AND wp.`id_product` = ' . $id_product . ''); if (empty($result) === false) { $this->smarty->assign('in_wishlist', true); } } } return $this->display(__FILE__, 'blockwishlist-extra.tpl'); }