feat: Create cart with line items (#6449)

**What**
- Add support for creating a cart with items
- Add endpoint `POST /store/carts/:id/line-items`
- Add `CreateCartWorkflow`
- Add `AddToCartWorkflow`
- Add steps for both workflows

**Testing**
- Endpoints
- Workflows

I would still call this a first iteration, as we are missing a few pieces of the full flow, such as payment sessions, discounts, and taxes.

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
Oli Juhl
2024-02-26 13:32:16 +00:00
committed by GitHub
co-authored by Adrien de Peretti
parent ac86362e81
commit 7ebe885ec9
26 changed files with 1100 additions and 157 deletions
+37 -3
View File
@@ -1,6 +1,35 @@
export interface CreateCartLineItemDTO {
variant_id: string
import { CartDTO } from "./common"
export interface CreateCartCreateLineItemDTO {
quantity: number
variant_id: string
title?: string
subtitle?: string
thumbnail?: string
product_id?: string
product_title?: string
product_description?: string
product_subtitle?: string
product_type?: string
product_collection?: string
product_handle?: string
variant_sku?: string
variant_barcode?: string
variant_title?: string
variant_option_values?: Record<string, unknown>
requires_shipping?: boolean
is_discountable?: boolean
is_tax_inclusive?: boolean
is_giftcard?: boolean
compare_at_unit_price?: number
unit_price?: number | string
metadata?: Record<string, unknown>
}
export interface CreateCartAddressDTO {
@@ -29,5 +58,10 @@ export interface CreateCartWorkflowInputDTO {
billing_address?: CreateCartAddressDTO | string
metadata?: Record<string, unknown>
items?: CreateCartLineItemDTO[]
items?: CreateCartCreateLineItemDTO[]
}
export interface AddToCartWorkflowInputDTO {
items: CreateCartCreateLineItemDTO[]
cart: CartDTO
}
+1 -1
View File
@@ -98,7 +98,7 @@ export interface ProductDTO {
*
* @expandable
*/
type: ProductTypeDTO[]
type: ProductTypeDTO
/**
* The associated product tags.
*