1

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: 'john.doe@example.com'
}).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?

Manube
  • 5,110
  • 3
  • 35
  • 59

1 Answers1

1

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: "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);
});
Manube
  • 5,110
  • 3
  • 35
  • 59
Charles Ouellet
  • 6,338
  • 3
  • 41
  • 57
  • thanks, it (almost) worked for me. For it to work, you need to also pass the email in the payload, like so: email: "johndoe@company.com", billingAddress: { "name": "John Doe", "address1": "226 rue St-Joseph E", "address2": "Suite 200", "city": "Quebec", "province": "QC", "country": "CA", "company": "Snipcart", "postalCode": "G1K3A9" } – Manube Nov 30 '20 at 15:41