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:
Name | Type | Description |
---|---|---|
address | <Person> | Customer's billing address details |
successCallback | function | Success callback function |
errorCallback | function | Error callback function |
Person fields:
Name | Type | Description |
---|---|---|
name | string | Customer's name |
companyName | string | Customer's company name |
street | string | Customer's street address. Use \n to place text in Address Line 2 |
city | string | Customer's city |
countryName | string | Customer's country name. countryCode can be used instead |
countryCode | string | Customer's country code. countryName can be used instead |
postalCode | string | Customer's zip code |
stateOrProvinceCode | string | Customer's state or provice code |
phone | string | Customer's phone number |
Parameters in bold are mandatory
errorCallback
structure is: errorCallback(errCode, errMsg)
Name | Type | Description |
---|---|---|
errCode | number | Error code |
errMsg | string | Error message |
Errors
Error code | Error message |
---|---|
0 | Missing argument |