http - Shopify add items to cart using get request working on browser but not working with a golang script
I wanted to automate the process of adding items to cart on shopify stores. For example, athttp://www.oneness287.com
. If you wish to buy these (https://www.oneness287.com/collections/all/products/jeremy-scott-flames-adidas-slides) size 7.5 , going tohttp://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?
Answer
Solution:
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.
Source
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.