-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
10 changed files
with
781 additions
and
31 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
82 changes: 82 additions & 0 deletions
82
packages/core/docs/commercetools/composables/use-billing.md
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,82 @@ | ||
# `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` | ||
|
||
- `save` - function for saving billing address. This method accepts a single `saveParams` object. The `saveParams` has the following options: | ||
|
||
- `billingDetails: Address` | ||
|
||
- `customQuery?: CustomQuery` | ||
|
||
```ts | ||
type Address = { | ||
__typename?: "Address"; | ||
id?: Maybe<Scalars["String"]>; | ||
title?: Maybe<Scalars["String"]>; | ||
salutation?: Maybe<Scalars["String"]>; | ||
firstName?: Maybe<Scalars["String"]>; | ||
lastName?: Maybe<Scalars["String"]>; | ||
streetName?: Maybe<Scalars["String"]>; | ||
streetNumber?: Maybe<Scalars["String"]>; | ||
additionalStreetInfo?: Maybe<Scalars["String"]>; | ||
postalCode?: Maybe<Scalars["String"]>; | ||
city?: Maybe<Scalars["String"]>; | ||
region?: Maybe<Scalars["String"]>; | ||
state?: Maybe<Scalars["String"]>; | ||
country: Scalars["Country"]; | ||
company?: Maybe<Scalars["String"]>; | ||
department?: Maybe<Scalars["String"]>; | ||
building?: Maybe<Scalars["String"]>; | ||
apartment?: Maybe<Scalars["String"]>; | ||
pOBox?: Maybe<Scalars["String"]>; | ||
contactInfo: AddressContactInfo; | ||
phone?: Maybe<Scalars["String"]>; | ||
email?: Maybe<Scalars["String"]>; | ||
additionalAddressInfo?: Maybe<Scalars["String"]>; | ||
externalId?: Maybe<Scalars["String"]>; | ||
key?: Maybe<Scalars["String"]>; | ||
}; | ||
type CustomQuery = Record<string, string> | ||
``` | ||
- `billing: Address` - a main data object that contains a billing address. | ||
- `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/commercetools'; | ||
import { onSSR } from '@vue-storefront/core' | ||
export default { | ||
setup () { | ||
const { load, billing } = useBilling(); | ||
onSSR(async () => { | ||
await load(); | ||
}); | ||
return { | ||
billing | ||
}; | ||
} | ||
} | ||
``` |
103 changes: 103 additions & 0 deletions
103
packages/core/docs/commercetools/composables/use-make-order.md
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,103 @@ | ||
# `useMakeOrder` | ||
|
||
## Features | ||
|
||
`useMakeOrder` composable is responsible for making an order | ||
|
||
## API | ||
|
||
- `make` - function for making an order. This method accepts a single optional `params` object. The `params` has the following option: | ||
|
||
- `customQuery?: CustomQuery` | ||
|
||
```ts | ||
type CustomQuery = Record<string, string> | ||
``` | ||
- `order: Order` - a main data object that contains a made order. | ||
```ts | ||
type Order = Versioned & { | ||
__typename?: "Order"; | ||
customerId?: Maybe<Scalars["String"]>; | ||
customer?: Maybe<Customer>; | ||
customerEmail?: Maybe<Scalars["String"]>; | ||
anonymousId?: Maybe<Scalars["String"]>; | ||
lineItems: Array<LineItem>; | ||
customLineItems: Array<CustomLineItem>; | ||
totalPrice: Money; | ||
taxedPrice?: Maybe<TaxedPrice>; | ||
shippingAddress?: Maybe<Address>; | ||
billingAddress?: Maybe<Address>; | ||
inventoryMode: InventoryMode; | ||
taxMode: TaxMode; | ||
taxRoundingMode: RoundingMode; | ||
taxCalculationMode: TaxCalculationMode; | ||
customerGroup?: Maybe<CustomerGroup>; | ||
customerGroupRef?: Maybe<Reference>; | ||
country?: Maybe<Scalars["Country"]>; | ||
shippingInfo?: Maybe<ShippingInfo>; | ||
discountCodes: Array<DiscountCodeInfo>; | ||
refusedGifts: Array<CartDiscount>; | ||
refusedGiftsRefs: Array<Reference>; | ||
paymentInfo?: Maybe<PaymentInfo>; | ||
locale?: Maybe<Scalars["Locale"]>; | ||
shippingRateInput?: Maybe<ShippingRateInput>; | ||
origin: CartOrigin; | ||
storeRef?: Maybe<KeyReference>; | ||
store?: Maybe<Store>; | ||
itemShippingAddresses: Array<Address>; | ||
completedAt?: Maybe<Scalars["DateTime"]>; | ||
orderNumber?: Maybe<Scalars["String"]>; | ||
orderState: OrderState; | ||
stateRef?: Maybe<Reference>; | ||
state?: Maybe<State>; | ||
shipmentState?: Maybe<ShipmentState>; | ||
paymentState?: Maybe<PaymentState>; | ||
syncInfo: Array<SyncInfo>; | ||
returnInfo: Array<ReturnInfo>; | ||
lastMessageSequenceNumber: Scalars["Long"]; | ||
cartRef?: Maybe<Reference>; | ||
cart?: Maybe<Cart>; | ||
/** This field contains non-typed data. Consider using `customFields` as a typed alternative. */ | ||
customFieldsRaw?: Maybe<Array<RawCustomField>>; | ||
/** This field would contain type data */ | ||
customFields?: Maybe<Type>; | ||
custom?: Maybe<CustomFieldsType>; | ||
id: Scalars["String"]; | ||
version: Scalars["Long"]; | ||
createdAt: Scalars["DateTime"]; | ||
lastModifiedAt: Scalars["DateTime"]; | ||
createdBy?: Maybe<Initiator>; | ||
lastModifiedBy?: Maybe<Initiator>; | ||
/** Custom fields are returned as a list instead of an object structure. */ | ||
customFieldList?: Maybe<Array<CustomField>>; | ||
}; | ||
``` | ||
|
||
- `loading: boolean` - a reactive object containing information about loading state of your `make` method. | ||
|
||
- `error: UseMakeOrderErrors` - a reactive object containing the error message, if `load` or `save` failed for any reason. | ||
|
||
```ts | ||
interface UseMakeOrderErrors { | ||
make?: Error; | ||
} | ||
``` | ||
|
||
## Getters | ||
|
||
We do not provide getters for checkout and its parts. | ||
|
||
## Example | ||
|
||
```js | ||
import { useMakeOrder } from '@vue-storefront/commercetools'; | ||
export default { | ||
setup () { | ||
const { make, order } = useMakeOrder(); | ||
return { | ||
make, | ||
order | ||
}; | ||
} | ||
} | ||
``` |
100 changes: 100 additions & 0 deletions
100
packages/core/docs/commercetools/composables/use-shipping-provider.md
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,100 @@ | ||
# `useShippingProvider` | ||
|
||
## Features | ||
|
||
`useShippingProvider` composable can be used for: | ||
|
||
* Loading shipping methods for the current cart. | ||
* Selecting shipping method for the current cart. | ||
|
||
## API | ||
|
||
- `load` - function for fetching shipping method. When invoked, it requests data from the API and populates the `response` key inside the `state` property. This method accepts a single optional `params` object. The `params` has the following option: | ||
|
||
- `customQuery?: CustomQuery` | ||
|
||
- `save` - function for selecting shipping method. This method accepts a single `saveParams` object. The `saveParams` has the following options: | ||
|
||
- `shippingMethod: ShippingMethod` | ||
|
||
- `customQuery?: CustomQuery` | ||
|
||
```ts | ||
type ShippingMethod = Versioned & { | ||
__typename?: "ShippingMethod"; | ||
id: Scalars["String"]; | ||
version: Scalars["Long"]; | ||
name: Scalars["String"]; | ||
description?: Maybe<Scalars["String"]>; | ||
zoneRates: Array<ZoneRate>; | ||
isDefault: Scalars["Boolean"]; | ||
predicate?: Maybe<Scalars["String"]>; | ||
createdAt: Scalars["DateTime"]; | ||
lastModifiedAt: Scalars["DateTime"]; | ||
key?: Maybe<Scalars["String"]>; | ||
lastModifiedBy?: Maybe<Initiator>; | ||
createdBy?: Maybe<Initiator>; | ||
taxCategoryRef?: Maybe<Reference>; | ||
taxCategory?: Maybe<TaxCategory>; | ||
}; | ||
|
||
type CustomQuery = Record<string, string> | ||
``` | ||
- `state: ShippingProviderState` - a main data object that contains a shipping method | ||
```ts | ||
interface ShippingProviderState { | ||
response: ShippingInfo | ||
} | ||
|
||
type ShippingInfo = { | ||
__typename?: "ShippingInfo"; | ||
shippingMethodName: Scalars["String"]; | ||
price: Money; | ||
shippingRate: ShippingRate; | ||
taxRate?: Maybe<TaxRate>; | ||
taxCategory?: Maybe<Reference>; | ||
deliveries: Array<Delivery>; | ||
discountedPrice?: Maybe<DiscountedLineItemPrice>; | ||
taxedPrice?: Maybe<TaxedItemPrice>; | ||
shippingMethodState: ShippingMethodState; | ||
shippingMethod?: Maybe<ShippingMethod>; | ||
shippingMethodRef?: Maybe<Reference>; | ||
}; | ||
``` | ||
|
||
- `loading: boolean` - a reactive object containing information about loading state of your `load` or `save` method. | ||
|
||
- `error: UseShippingProviderErrors` - a reactive object containing the error message, if `load` or `save` failed for any reason. | ||
|
||
```ts | ||
interface UseShippingProviderErrors { | ||
load?: Error; | ||
save?: Error; | ||
} | ||
``` | ||
|
||
## Getters | ||
|
||
We do not provide getters for checkout and its parts. | ||
|
||
## Example | ||
|
||
```js | ||
import { useShippingProvider } from '@vue-storefront/commercetools'; | ||
import { onSSR } from '@vue-storefront/core'; | ||
import { computed } from '@vue/composition-api'; | ||
|
||
export default { | ||
setup () { | ||
const { load, state } = useShippingProvider(); | ||
|
||
onSSR(async () => { | ||
await load(); | ||
}); | ||
|
||
return { | ||
selectedShippingMethod: computed(() => state.value && state.value.response) | ||
}; | ||
} | ||
} | ||
``` |
Oops, something went wrong.