Able to proceed to checkout even after removing all items at checkout page
KeetTechSol opened this issue · 5 comments
KeetTechSol commented
Steps to reproduce:
- Navigate to https://remix-storefront.vendure.io
- Add an items to cart
- Navigate to checkout page
- Remove all items from the cart
- Enter all required details, select shipping method
- Click proceed to payment
- Proceed to Payment
Expected result:
Proceed to payment button disabled
Actual Result:
Proceeding to payment and getting an 400 Bad request after payment
michaelbromley commented
Hi, thanks for the report!
Would you be interested in attempting a fix to this?
KeetTechSol commented
I will give a try
kyunal commented
I don't have the time to make a PR but a solution could look like the following:
import { getActiveOrder } from '~/providers/orders/order';
export async function loader({ request, context }: DataFunctionArgs) {
const session = await sessionStorage.getSession(
request?.headers.get('Cookie'),
);
const activeOrder = await getActiveOrder({ request, context });
if (
!session ||
!activeOrder ||
!activeOrder.active ||
activeOrder.lines.length === 0
) {
return redirect('/');
}
...
}
This would need to be included in the routes/checkout/index.tsx
and routes/checkout/payment.tsx
pages
KeetTechSol commented
Thanks @kyunal. I have raised a PR.
michaelbromley commented
closed in #28
Thanks both for your help!