1

我在此页面上关注了文档:https ://docs.snipcart.com/v3/sdk/api#cart

我可以像这样更新购物车:

Snipcart.api.cart.update({
  email: 'john.doe@example.com'
}).then(response => {
 console.log("Snipcart.api.cart.update response", response);
}).catch(e => {
 console.log("Snipcart.api.cart.update error", e);
});

但是,当我尝试这个时:

Snipcart.api.cart.update({
  billingAddress:{
   name: 'John Doe'
 }
}).then(response => {
 console.log("Snipcart.api.cart.update response", response);
}).catch(e => {
 console.log("Snipcart.api.cart.update error", e);
});

我得到:

Snipcart.api.cart.update error Object { kind: Getter & Setter, form: Getter & Setter, fields: Getter & Setter, … }

而且我不知道为什么!?有什么提示吗?

4

1 回答 1

1

更新帐单地址时,您必须设置所有帐单地址属性,否则验证将失败。

您可以尝试:

Snipcart.api.cart.update({
  email: "johndoe@company.com",
  billingAddress:{
   ...address,
   name: 'John Doe'
 }
}).then(response => {
 console.log("Snipcart.api.cart.update response", response);
}).catch(e => {
 console.log("Snipcart.api.cart.update error", e);
});
于 2020-11-30T14:53:59.353 回答