feat(MED-100): update cart checkout flow and views
This commit is contained in:
@@ -154,6 +154,8 @@ export async function addToCart({
|
||||
revalidateTag(fulfillmentCacheTag);
|
||||
})
|
||||
.catch(medusaError);
|
||||
|
||||
return cart;
|
||||
}
|
||||
|
||||
export async function updateLineItem({
|
||||
@@ -394,7 +396,7 @@ export async function placeOrder(cartId?: string) {
|
||||
const id = cartId || (await getCartId());
|
||||
|
||||
if (!id) {
|
||||
throw new Error("No existing cart found when placing an order");
|
||||
return;
|
||||
}
|
||||
|
||||
const headers = {
|
||||
@@ -411,17 +413,14 @@ export async function placeOrder(cartId?: string) {
|
||||
.catch(medusaError);
|
||||
|
||||
if (cartRes?.type === "order") {
|
||||
const countryCode =
|
||||
cartRes.order.shipping_address?.country_code?.toLowerCase();
|
||||
|
||||
const orderCacheTag = await getCacheTag("orders");
|
||||
revalidateTag(orderCacheTag);
|
||||
|
||||
removeCartId();
|
||||
redirect(`/${countryCode}/order/${cartRes?.order.id}/confirmed`);
|
||||
redirect(`/home/order/${cartRes?.order.id}/confirmed`);
|
||||
} else {
|
||||
throw new Error("Cart is not an order");
|
||||
}
|
||||
|
||||
return cartRes.cart;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@ export const listProducts = async ({
|
||||
regionId,
|
||||
}: {
|
||||
pageParam?: number
|
||||
queryParams?: HttpTypes.FindParams & HttpTypes.StoreProductParams
|
||||
queryParams?: HttpTypes.FindParams & HttpTypes.StoreProductParams & { collection_id?: string }
|
||||
countryCode?: string
|
||||
regionId?: string
|
||||
}): Promise<{
|
||||
|
||||
@@ -57,7 +57,7 @@ export const getRegion = async (countryCode: string) => {
|
||||
|
||||
const region = countryCode
|
||||
? regionMap.get(countryCode)
|
||||
: regionMap.get("us")
|
||||
: regionMap.get("et")
|
||||
|
||||
return region
|
||||
} catch (e: any) {
|
||||
|
||||
Reference in New Issue
Block a user