# useBilling
# Features
useBilling
composable can be used for:
- Loading billing address for the current cart.
- Saving billing address for the current cart.
# API
load
- function for fetching billing address. When invoked, it requests data from the API and populatesbilling
property.save
- function for saving billing address. This method accepts a singlesaveParams
object. ThesaveParams
has the following options:billingDetails: Address
type AgnosticAddress = {
firstName?: string;
lastName?: string;
streetName?: string;
apartment?: string;
city?: string;
state?: string;
postalCode?: string;
country?: string;
phone?: string;
};
billing: AgnosticAddress
- a main data object that contains a billing address.loading: boolean
- a reactive object containing information about loading state of yourload
orsave
method.error: UseBillingErrors
- a reactive object containing the error message, ifload
orsave
failed for any reason.
interface UseBillingErrors {
load?: Error;
save?: Error;
}
# Getters
We do not provide getters for checkout and its parts.
# Example
import { useBilling } from '@vue-storefront/sfcc';
import { onSSR } from '@vue-storefront/core';
export default {
setup () {
const { load, billing } = useBilling();
onSSR(async () => {
await load();
});
return {
billing
};
}
}