mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 03:31:23 +00:00
✨ feat: add shipping address to order
:%s
This commit is contained in:
@@ -62,6 +62,11 @@ export type Cart = {
|
||||
id: string
|
||||
// ID of the customer to which the cart belongs.
|
||||
customerId?: string
|
||||
customer?: {
|
||||
firstName: string,
|
||||
lastName: string,
|
||||
emailAddress: string,
|
||||
}
|
||||
// The email assigned to this cart
|
||||
email?: string
|
||||
// The date and time when the cart was created.
|
||||
|
16
framework/vendure/schema.d.ts
vendored
16
framework/vendure/schema.d.ts
vendored
@@ -332,17 +332,9 @@ export type SetCustomerForOrderMutation = { __typename?: 'Mutation' } & {
|
||||
>)
|
||||
}
|
||||
|
||||
export type SetCustomerForOrderMutation = { __typename?: 'Mutation' } & {
|
||||
setCustomerForOrder:
|
||||
| ({ __typename: 'ActiveOrderCustomerFragment' } & Pick<ActiveOrderCustomerFragment, 'customer', 'lines'>)
|
||||
| ({ __typename: 'AlreadyLoggedInError' } & Pick<
|
||||
AlreadyLoggedInError,
|
||||
'errorCode' | 'message'
|
||||
>)
|
||||
| ({ __typename: 'EmailAddressConflictError' } & Pick<
|
||||
EmailAddressConflictError,
|
||||
'errorCode' | 'message'
|
||||
>)
|
||||
export type SetOrderShippingAddressMutation = { __typename?: 'Mutation' } & {
|
||||
setOrderShippingAddress:
|
||||
| ({ __typename: 'Order' } & Pick<Order, 'id' | 'total' | 'totalQuantity' | 'code' | 'shippingAddress'>)
|
||||
| ({ __typename: 'NoActiveOrderError' } & Pick<
|
||||
NoActiveOrderError,
|
||||
'errorCode' | 'message'
|
||||
@@ -3060,7 +3052,7 @@ export type CartFragment = { __typename?: 'Order' } & Pick<
|
||||
| 'totalWithTax'
|
||||
| 'currencyCode'
|
||||
> & {
|
||||
customer?: Maybe<{ __typename?: 'Customer' } & Pick<Customer, 'id'>>
|
||||
customer?: Maybe<{ __typename?: 'Customer' } & Pick<Customer, 'id' | 'firstName' | 'lastName' | 'emailAddress'>>
|
||||
lines: Array<
|
||||
{ __typename?: 'OrderLine' } & Pick<
|
||||
OrderLine,
|
||||
|
@@ -11,6 +11,9 @@ export const cartFragment = /* GraphQL */ `
|
||||
currencyCode
|
||||
customer {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
emailAddress
|
||||
}
|
||||
lines {
|
||||
id
|
||||
|
@@ -0,0 +1,25 @@
|
||||
export const setOrderShippingAddressMutation = /* GraphQL */ `
|
||||
mutation setOrderShippingAddress($input: CreateAddressInput!) {
|
||||
setOrderShippingAddress(input: $input) {
|
||||
__typename
|
||||
... on Order {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
code
|
||||
shippingAddress {
|
||||
streetLine1
|
||||
city
|
||||
province
|
||||
postalCode
|
||||
countryCode
|
||||
phoneNumber
|
||||
}
|
||||
}
|
||||
... on ErrorResult {
|
||||
errorCode
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
@@ -45,6 +45,11 @@ export function normalizeCart(order: CartFragment): Cart {
|
||||
subtotalPrice: order.subTotalWithTax / 100,
|
||||
totalPrice: order.totalWithTax / 100,
|
||||
customerId: order.customer?.id,
|
||||
customer: {
|
||||
firstName: order.customer?.firstName || '',
|
||||
lastName: order.customer?.lastName || '',
|
||||
emailAddress: order.customer?.emailAddress || '',
|
||||
},
|
||||
lineItems: order.lines?.map((l) => ({
|
||||
id: l.id,
|
||||
name: l.productVariant.name,
|
||||
|
Reference in New Issue
Block a user