Ecwid.Cart.setBillingAddress

Set billing address for customer in storefront

You can use it to specify some address from your custom form on your website. If you specify some fields only (name, for example), then Ecwid will apply the changed fields only, leaving preset ones as they were before.

When function is called, Ecwid will set the 'My shipping address is the same as the billing address' flag to false automatically. Full function call example:

Ecwid.Cart.setBillingAddress({
  "name": "John Carmichael",
  "companyName": "Cool Slippers",
  "street": "5th Ave",
  "city": "New York",
  "countryName": "United States",
  "postalCode": "10002",
  "stateOrProvinceCode": "NY",
  "phone": "+1 234 523 11 42"
  },
  function(){
   console.log('Address successfully set')
  },
  function(){
   console.log('Error setting the address');
  }
);

Subscribe to the Ecwid.OnAPILoaded JS API event to ensure availability of this function.

Fields:

NameTypeDescription
address<Person>Customer's billing address details
successCallbackfunctionSuccess callback function
errorCallbackfunctionError callback function

Person fields:

NameTypeDescription
namestringCustomer's name
companyNamestringCustomer's company name
streetstringCustomer's street address. Use \n to place text in Address Line 2
citystringCustomer's city
countryNamestringCustomer's country name. countryCode can be used instead
countryCodestringCustomer's country code. countryName can be used instead
postalCodestringCustomer's zip code
stateOrProvinceCodestringCustomer's state or provice code
phonestringCustomer's phone number

📘

Parameters in bold are mandatory

errorCallback structure is: errorCallback(errCode, errMsg)

NameTypeDescription
errCodenumberError code
errMsgstringError message

Errors

Error codeError message
0Missing argument