Skip to content

Commit 2470f9c

Browse files
authored
Merge pull request #315 from medusajs/fix/cart-shipping-options
fix: use listCartOptions instead of list
2 parents 4939435 + 65c04a9 commit 2470f9c

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

src/lib/data/index.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,22 +199,11 @@ export const retrieveOrder = cache(async function (id: string) {
199199
})
200200

201201
// Shipping actions
202-
export const listShippingMethods = cache(async function listShippingMethods(
203-
regionId: string,
204-
productIds?: string[]
205-
) {
202+
export const listCartShippingMethods = cache(async function (cartId: string) {
206203
const headers = getMedusaHeaders(["shipping"])
207204

208-
const product_ids = productIds?.join(",")
209-
210205
return medusaClient.shippingOptions
211-
.list(
212-
{
213-
region_id: regionId,
214-
product_ids,
215-
},
216-
headers
217-
)
206+
.listCartOptions(cartId, headers)
218207
.then(({ shipping_options }) => shipping_options)
219208
.catch((err) => {
220209
console.log(err)

src/modules/checkout/templates/checkout-form/index.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import Addresses from "@modules/checkout/components/addresses"
2-
import Shipping from "@modules/checkout/components/shipping"
3-
import Payment from "@modules/checkout/components/payment"
4-
import Review from "@modules/checkout/components/review"
51
import {
62
createPaymentSessions,
73
getCustomer,
8-
listShippingMethods,
4+
listCartShippingMethods,
95
} from "@lib/data"
6+
import { getCheckoutStep } from "@lib/util/get-checkout-step"
7+
import Addresses from "@modules/checkout/components/addresses"
8+
import Payment from "@modules/checkout/components/payment"
9+
import Review from "@modules/checkout/components/review"
10+
import Shipping from "@modules/checkout/components/shipping"
1011
import { cookies } from "next/headers"
1112
import { CartWithCheckoutStep } from "types/global"
12-
import { getCheckoutStep } from "@lib/util/get-checkout-step"
1313

1414
export default async function CheckoutForm() {
1515
const cartId = cookies().get("_medusa_cart_id")?.value
@@ -30,9 +30,9 @@ export default async function CheckoutForm() {
3030
cart.checkout_step = cart && getCheckoutStep(cart)
3131

3232
// get available shipping methods
33-
const availableShippingMethods = await listShippingMethods(
34-
cart.region_id
35-
).then((methods) => methods?.filter((m) => !m.is_return))
33+
const availableShippingMethods = await listCartShippingMethods(cart.id).then(
34+
(methods) => methods?.filter((m) => !m.is_return)
35+
)
3636

3737
if (!availableShippingMethods) {
3838
return null

0 commit comments

Comments
 (0)