使用Shopify使用特定于客户的商品/产品创建购物车

问题描述

Am使用Shopify开发用于购买和销售产品的本地应用程序。 要使用Ajax API并传递产品的变体ID来创建购物车,但我需要区分并为每个用户创建单独的购物车。

当前,如果我使用以下API调用将产品添加到购物车中,那么即使其他客户/用户也可以看到其他用户之前添加到购物车的产品。 谁能帮助我解决这个问题或提出建议吗?

用于创建购物车的方法

  addtoCart = () => {
    var that = this;   
    var variantId = this.state.artworkdescription.ID;(***product ID***)
    var data = 'id=' + variantId + '&quantity=1'
    console.log("data",data);
    //POST request 
    fetch('https://lonelywalls.myshopify.com/cart/add.js',{
        method: "POST",//Request Type 
        body: data,headers: {
            'Content-Type': 'application/x-www-form-urlencoded','x-shopify-access-token': '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',},})
        .then((response) => response.json())
        .then((responseJson) => {
            console.log("Cart Response",responseJson);
        })
        //If response is not in json then in error
        .catch((error) => {
            console.log(error);
        });
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)