useAddress
Category:
Cart & Checkout
Composable to manage customer addresses
With this composable you can:
- Fetch customer addresses
- Return customer addresses
- Create new customer address
- Update existing customer address
- Delete existing customer address
- Set default billing address
- Set default shipping address
- Format error message
Types
ts
export function useAddress(): UseAddressReturn
ts
export type UseAddressReturn = {
/**
* List of customer addresses
*/
customerAddresses: ComputedRef<Schemas["CustomerAddress"][]>;
/**
* Loads the addresses that are available under `customerAddresses` property
*/
loadCustomerAddresses(): Promise<Schemas["CustomerAddress"][]>;
/**
* Allows to create new address for a current customer
*/
createCustomerAddress(
customerAddress: Schemas["CustomerAddress"],
): Promise<Schemas["CustomerAddress"]>;
/**
* Allows to update existing address for a current customer
*/
updateCustomerAddress(
customerAddress: Schemas["CustomerAddress"],
): Promise<Schemas["CustomerAddress"]>;
/**
* Allows to delete existing address for a current customer
*/
deleteCustomerAddress(addressId: string): Promise<void>;
/**
* Sets the address for given ID as default billing address
*/
setDefaultCustomerBillingAddress(addressId: string): Promise<string>;
/**
* Sets the address for given ID as default shipping address
*/
setDefaultCustomerShippingAddress(addressId: string): Promise<string>;
/**
* Returns formatted error message
*
* @param {ShopwareError} error
*/
errorMessageBuilder(error: ApiError): string | null;
};