fix(core-flows, medusa): Prevent cart addresses duplication on update (#13841)
* Allow id field in addresses properties for cart update validator * Update cart addresses in update step where id is provided, both reference and nested fields * Add tests * Add changeset * Remove unnecessary map step * Review changes
This commit is contained in:
@@ -43,13 +43,17 @@ export const StoreRemoveCartPromotions = z
|
||||
})
|
||||
.strict()
|
||||
|
||||
const StoreCartUpsertAddress = AddressPayload.merge(z.object({
|
||||
id: z.string().optional(),
|
||||
}))
|
||||
|
||||
export type StoreUpdateCartType = z.infer<typeof UpdateCart>
|
||||
export const UpdateCart = z
|
||||
.object({
|
||||
region_id: z.string().optional(),
|
||||
email: z.string().email().nullish(),
|
||||
billing_address: z.union([AddressPayload, z.string()]).optional(),
|
||||
shipping_address: z.union([AddressPayload, z.string()]).optional(),
|
||||
billing_address: z.union([StoreCartUpsertAddress, z.string()]).optional(),
|
||||
shipping_address: z.union([StoreCartUpsertAddress, z.string()]).optional(),
|
||||
sales_channel_id: z.string().nullish(),
|
||||
metadata: z.record(z.unknown()).nullish(),
|
||||
promo_codes: z.array(z.string()).optional(),
|
||||
|
||||
Reference in New Issue
Block a user