flambert Posted September 12, 2017 Share Posted September 12, 2017 Hey, I need to add tons of products to a shopping cart (not on my site), I've got the id's is there a easy way to do it? -possible with 1 post call? -possible to run a javascript to add all at ones? ps. the website got some issues, when I start adding products it starts getting slower, and I often get error 504, around 60 products.. The prudcts are with attributes. I am greatfull for any response Link to comment Share on other sites More sharing options...
Scully Posted September 13, 2017 Share Posted September 13, 2017 You have a add to cart links like this example: https://nextrade.ch/warenkorb?add=1&id_product=387&token=040f59f2d8c57005642e645d3dfbf416 First parameter is quantity, second is ID product. But if the site has technical issues, you might not overcome these. Link to comment Share on other sites More sharing options...
flambert Posted September 13, 2017 Author Share Posted September 13, 2017 You have a add to cart links like this example: https://nextrade.ch/warenkorb?add=1&id_product=387&token=040f59f2d8c57005642e645d3dfbf416 First parameter is quantity, second is ID product. But if the site has technical issues, you might not overcome these. Hey Thanks for the response, but can't get that code to work.. Currently I've tried with a post request. I got it to work with postman, but can't get it to work with RestSharp: var client = new RestClient("webshop/?rand=1505289633889"); var request = new RestRequest(Method.POST); request.AddHeader("postman-token", "token"); request.AddHeader("cookie", "PrestaShop-restofcookie"); request.AddHeader("accept-language", "en-US,en;q=0.8"); request.AddHeader("accept-encoding", "gzip, deflate, br"); request.AddHeader("referer", "website.html"); request.AddHeader("x-requested-with", "XMLHttpRequest"); request.AddHeader("x-devtools-emulate-network-conditions-client-id", "GUID"); request.AddHeader("cache-control", "no-cache"); request.AddHeader("accept", "application/json, text/javascript, */*; q=0.01"); request.AddHeader("content-type", "application/x-www-form-urlencoded"); request.AddHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"); request.AddHeader("origin", "HOST"); request.AddParameter("application/x-www-form-urlencoded", "add=1&ajax=true&controller=cart&id_product=1237&ipa=5157&qty=10&token= TOKEN", ParameterType.RequestBody); IRestResponse response = client.Execute(request); Link to comment Share on other sites More sharing options...
Scully Posted September 13, 2017 Share Posted September 13, 2017 (edited) I don't know RestSharp at all. Never heard actually. But I still don't see the problem. You only need the correct token. Once you have it, you can loop through a number of IDs and add them one by one. And you need cookies accepted or set of course. Edited September 13, 2017 by Scully (see edit history) Link to comment Share on other sites More sharing options...
flambert Posted September 13, 2017 Author Share Posted September 13, 2017 I don't know RestSharp at all. Never heard actually. But I still don't see the problem. You only need the correct token. Once you have it, you can loop through a number of IDs and add them one by one. And you need cookies accepted or set of course. for the url to work, you'll also need to use a cookie, and to be able to loop though it i need to be able to make the calls via scripts. Link to comment Share on other sites More sharing options...
Scully Posted September 13, 2017 Share Posted September 13, 2017 Of course you need cookies. You can first fetch the shop startpage, get the cookies and use them while looping through all the IDs. Link to comment Share on other sites More sharing options...
flambert Posted September 13, 2017 Author Share Posted September 13, 2017 Of course you need cookies. You can first fetch the shop startpage, get the cookies and use them while looping through all the IDs. what framework would you do it from? because if I have to enter each url, it also takes long time, I was more thinking of a program/script solution while I just provide a list of id's Link to comment Share on other sites More sharing options...
Scully Posted September 13, 2017 Share Posted September 13, 2017 I use curl. Link to comment Share on other sites More sharing options...
flambert Posted September 15, 2017 Author Share Posted September 15, 2017 I use curl. In my code I also use cookies and the token, but it won't work.. can you be so kind and provide a full example? 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