PsychoZzzorD Posted June 20, 2016 Share Posted June 20, 2016 Hi guys =)I'm doing a product page on which I need Add-to-cart buttons specific to each product. For the moment I use this stucture : "http://yourdomainname/panier?add=1&id_product=productID" It works well when you are not connected with any user account (it brings to your cart with the product inside, the redirection is not intentional, but it doesn't bother me)Unfortunately, when you are conenct with an account, it redirects you on the homepage without even putting the product in your cart. Do somebody knows how to do that ? =) Link to comment Share on other sites More sharing options...
rocky Posted June 20, 2016 Share Posted June 20, 2016 I think you need to include the customer's secure key at the end of URL like &token=<hash_code>. It can be found in $customer->secure_key. Link to comment Share on other sites More sharing options...
PsychoZzzorD Posted June 20, 2016 Author Share Posted June 20, 2016 Thank you for your answer Where can I find this customer variable ? Link to comment Share on other sites More sharing options...
rocky Posted June 20, 2016 Share Posted June 20, 2016 You can access it from a PHP file using $this->context->customer->secure_key and then pass the value into a TPL file if needed. Link to comment Share on other sites More sharing options...
PsychoZzzorD Posted June 20, 2016 Author Share Posted June 20, 2016 Can I for example put this in the controller of a page I create, to call it in my page ? =)If I do so, must I use this kind of syntax ? :" public static function getCategoryName($id){ $category = new Category ($id,Context::getContext()->language->id); return $category->name; } " Link to comment Share on other sites More sharing options...
rocky Posted June 21, 2016 Share Posted June 21, 2016 You can try, but I'm unsure whether it will work. I have gotten static functions in PrestaShop's core classes to work in Smarty, so hopefully your own class would work too. You'd use something like the following in your TPL file: {YourClass::getCategoryName($id)} Link to comment Share on other sites More sharing options...
PsychoZzzorD Posted June 21, 2016 Author Share Posted June 21, 2016 I finally done it.It was just needed to put "&token={$static_token}" at the end of the link I put in my first post =)The controller to get token already exist in Tools.php.This is the post from where I get the solution "https://www.prestashop.com/forums/topic/3048[spam-filter]get-static-token-in-module/" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now