ilclaudio Posted August 24, 2016 Share Posted August 24, 2016 Hi all, I'm reading on some posts that it is not possible to add a product to the Prestashop cart with a simple get request (a link containing the id of the product). Is it possible to add a product to a cart with a form using the POST method from a static page? thank you claudio Link to comment Share on other sites More sharing options...
bellini13 Posted August 24, 2016 Share Posted August 24, 2016 It is possible using a simple get request. You can turn that into a POST request if you like as well. http://localhost/index.php?controller=cart&add=1&ajax=false&id_product=1&ipa=1&token=sd09f8sa09df8a0sd980a9sd809a The problem you will likely have is the token parameter, which is required by default, and will be different for each customer. Link to comment Share on other sites More sharing options...
ilclaudio Posted August 24, 2016 Author Share Posted August 24, 2016 It is possible using a simple get request. You can turn that into a POST request if you like as well. http://localhost/index.php?controller=cart&add=1&ajax=false&id_product=1&ipa=1&token=sd09f8sa09df8a0sd980a9sd809a The problem you will likely have is the token parameter, which is required by default, and will be different for each customer. Where is the token of a user? If the token is different for each customer I suppose it doesn't works for anonymous users. Probably I should do a front controller and to leave the idea of using a static html block. cld Link to comment Share on other sites More sharing options...
ilclaudio Posted August 25, 2016 Author Share Posted August 25, 2016 Where is the token of a user? If the token is different for each customer I suppose it doesn't works for anonymous users. Probably I should do a front controller and to leave the idea of using a static html block. cld I've solved with a front controller done using this tutorial: https://www.packtpub.com/books/content/using-front-controllers-create-new-page The problem with get and post methods is that I don't know how to generate the token needed. cld Link to comment Share on other sites More sharing options...
bellini13 Posted August 25, 2016 Share Posted August 25, 2016 there is a function in the Tools class named "getToken". Review the FrontController class, which has a function "isTokenValid", which should give you an idea of whats going on 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