/**
  * @param SS_HTTPRequest $req
  * @return bool|SS_HTTPResponse
  */
 public function delete_list(SS_HTTPRequest $req)
 {
     if (!SecurityToken::inst()->checkRequest($req)) {
         $this->httpError(403);
     }
     $this->wishList->removeAllBuyables();
     $this->wishList->delete();
     WishList::set_current(null);
     $this->wishList = WishList::current();
     $this->extend('updateDeleteListResponse', $req, $response);
     return $response ? $response : $this->redirectBack();
 }
Ejemplo n.º 2
0
            $errors[] = Tools::displayError('invalid token');
        }
        if (!sizeof($errors)) {
            $name = Tools::getValue('name');
            $wishlist = new WishList();
            $wishlist->name = $name;
            $wishlist->id_customer = $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();
        }
    } else {
        if ($add) {
            WishList::addCardToWishlist(intval($cookie->id_customer), intval(Tools::getValue('id_wishlist')), intval($cookie->id_lang));
        } else {
            if ($delete and empty($id_wishlist) === false) {
                $wishlist = new WishList(intval($id_wishlist));
                $wishlist->delete();
            }
        }
    }
    $smarty->assign('wishlists', WishList::getByIdCustomer(intval($cookie->id_customer)));
    $smarty->assign('nbProducts', WishList::getInfosByIdCustomer(intval($cookie->id_customer)));
} else {
    $errors[] = Tools::displayError('You need to be logged to manage your wishlist');
}
$smarty->assign('id_customer', intval($cookie->id_customer));
$smarty->assign('errors', $errors);
$smarty->display(dirname(__FILE__) . '/mywishlist.tpl');
include dirname(__FILE__) . '/../../footer.php';