-1
我有一個應用程序需要收集各種產品選項,然後向外部網址(https://my-shop.myshopify.com/cart/add)發出發佈請求,然後重定向到該網站並添加了項目到購物車。如何使用Post方法在Rails中從外部域添加到購物車
不幸的是,我不能簡單地使用購物車固定鏈接,因爲我需要包含lineitems。到目前爲止,我已經在我的控制器中成功地創建了該帖子,但沒有重定向到shopify站點。
def add_to_cart
@urlstring_to_post = 'https://my-shop.myshopify.com/cart/add'
#submit and get a result
@result = HTTParty.post(@urlstring_to_post.to_str,
:body => {:id => '15158758855',
:add => 'Add to Cart'
}.to_json,
:headers => { 'Content-Type' => 'application/json' })
end