-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# `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 populates `billing` property. This method accepts a single optional `params` object. The `params` has the following option: | ||
|
||
* `customQuery?: CustomQuery` | ||
|
||
```ts | ||
type CustomQuery = { | ||
getBasicProfile: string | ||
} | ||
``` | ||
* `save` - function for saving billing address. This method accepts a single `saveParams` object. The `saveParams` has the following options: | ||
* `billingDetails: CreateAddressInput` | ||
<https://www.vendure.io/docs/graphql-api/admin/input-types/#createaddressinput> | ||
* `customQuery?: CustomQuery` | ||
```ts | ||
type CustomQuery = { | ||
updateCart: string | ||
} | ||
``` | ||
* `billing: OrderAddress` - a main data object that contains a billing address. | ||
<https://www.vendure.io/docs/graphql-api/admin/object-types/#orderaddress> | ||
* `loading: boolean` - a reactive object containing information about loading state of your `load` or `save` method. | ||
* `error: UseBillingErrors` - a reactive object containing the error message, if `load` or `save` failed for any reason. | ||
```ts | ||
interface UseBillingErrors { | ||
load?: Error; | ||
save?: Error; | ||
} | ||
``` | ||
|
||
## Getters | ||
|
||
We do not provide getters for checkout and its parts. | ||
|
||
## Example | ||
|
||
```js | ||
import { useBilling } from '@vue-storefront/vendure'; | ||
import { onSSR } from '@vue-storefront/core' | ||
|
||
export default { | ||
setup () { | ||
const { load, billing } = useBilling(); | ||
|
||
onSSR(async () => { | ||
await load(); | ||
}); | ||
|
||
return { | ||
billing | ||
}; | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# `useShipping` | ||
|
||
## Features | ||
|
||
`useShipping` composable can be used for: | ||
|
||
* Loading shipping address for the current cart. | ||
* Saving shipping address for the current cart. | ||
|
||
## API | ||
|
||
* `load` - function for fetching shipping address. When invoked, it requests data from the API and populates `shipping` property. This method accepts a single optional `params` object. The `params` has the following option: | ||
|
||
* `customQuery?: CustomQuery` | ||
|
||
```ts | ||
type CustomQuery = { | ||
getBasicProfile: string | ||
} | ||
``` | ||
* `save` - function for saving shipping address. This method accepts a single `saveParams` object. The `saveParams` has the following options: | ||
* `shippingDetails: CreateAddressInput` | ||
<https://www.vendure.io/docs/graphql-api/admin/input-types/#createaddressinput> | ||
* `customQuery?: CustomQuery` | ||
```ts | ||
type CustomQuery = { | ||
updateCart: string | ||
} | ||
``` | ||
* `shipping: OrderAddress` - a main data object that contains a shipping address. | ||
<https://www.vendure.io/docs/graphql-api/admin/object-types/#orderaddress> | ||
* `loading: boolean` - a reactive object containing information about loading state of your `load` or `save` method. | ||
* `error: UseShippingErrors` - a reactive object containing the error message, if `load` or `save` failed for any reason. | ||
```ts | ||
interface UseShippingErrors { | ||
load?: Error; | ||
save?: Error; | ||
} | ||
``` | ||
|
||
## Getters | ||
|
||
We do not provide getters for checkout and its parts. | ||
|
||
## Example | ||
|
||
```js | ||
import { useShipping } from '@vue-storefront/vendure'; | ||
import { onSSR } from '@vue-storefront/core'; | ||
|
||
export default { | ||
setup () { | ||
const { load, shipping } = useShipping(); | ||
|
||
onSSR(async () => { | ||
await load(); | ||
}); | ||
|
||
return { | ||
shipping | ||
}; | ||
} | ||
} | ||
``` |