Why can I update the e-mail address, but not the billing address?

130 Views Asked by At

I followed the doc at this page: https://docs.snipcart.com/v3/sdk/api#cart

I can update the cart like so:

Snipcart.api.cart.update({
  email: '[email protected]'
}).then(response => {
 console.log("Snipcart.api.cart.update response", response);
}).catch(e => {
 console.log("Snipcart.api.cart.update error", e);
});

However, when I try this:

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);
});

I get:

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

And I can't figure out why !? Any hint?

1

There are 1 best solutions below

1
On BEST ANSWER

When updating billing address, you must set all billing address properties, otherwise the validation will fail.

You can try with:

Snipcart.api.cart.update({
  email: "[email protected]",
  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);
});