Ad

Shopify Add Items To Cart Using Get Request Working On Browser But Not Working With A Golang Script

- 1 answer

I wanted to automate the process of adding items to cart on shopify stores. For example, at http://www.oneness287.com . If you wish to buy these size 7.5 , going to http://oneness287-2.myshopify.com/cart/29741797961:1 automatically adds the product to my cart and redirects me to the checkout page.

But when I do

http.Get("http://oneness287-2.myshopify.com/cart/29741797961:1")

from my golang code, and then check my cart. The cart is still empty. What is different in this case? In the first case I am making the request from the browser, in the second my script is making the request. How do I fix it?

Ad

Answer

When you make the request from go code the server creates a new session (basically new cookie) whereas the browser request have its own session, hence the request are not operating on the same cart. If you really want to do this then in the go code you will have to send all the cookies that you have in browser for this particular domain.

Ad
source: stackoverflow.com
Ad