Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filter shipping options #368

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/modules/checkout/templates/checkout-form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,20 @@ export default async function CheckoutForm({
return null
}

const shippingMethods = await listCartShippingMethods(cart.id)
const _shippingMethods = await listCartShippingMethods(cart.id)
const paymentMethods = await listCartPaymentMethods(cart.region?.id ?? "")

const shippingMethods = _shippingMethods.filter((sm) => {
const isReturn = sm.rules.some(
(rule) => rule.attribute === "is_return" && rule.value === "true"
)
const isEnabledInStore = sm.rules.some(
(rule) => rule.attribute === "enabled_in_store" && rule.value === "true"
)
fPolic marked this conversation as resolved.
Show resolved Hide resolved

return !isReturn && isEnabledInStore
})

if (!shippingMethods || !paymentMethods) {
return null
}
Expand Down
Loading