Skip to content

Fix checkout error #1468

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

Merged
merged 2 commits into from
Jun 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ Optional plugin:
- [headless-wordpress](https://github.com/w3bdesign/headless-wp) Disables the frontend so only the backend is accessible.
- [wp-graphql-cors](https://github.com/funkhaus/wp-graphql-cors) Ensures that CORS works correctly. Remember to add the domain to the store under `Extend "Access-Control-Allow-Origin” header`

The current release has been tested and is confirmed working with the following plugin versions:
The current release has been tested and is confirmed working with the following versions:

- WordPress version 6.6.2
- WooCommerce version 7.4.0
- WP GraphQL version 1.13.8
- WooGraphQL version 0.12.0
- WordPress version 6.8.1
- WooCommerce version 9.9.5
- WP GraphQL version 2.3.3
- WooGraphQL version 0.19.0
- WPGraphQL CORS version 2.1

2. Make sure WooCommerce has some products already or import some sample products
Expand Down
28 changes: 20 additions & 8 deletions components/Checkout/CheckoutForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,28 @@ const handleSubmit = ({
transactionId: "hjkhjkhsdsdiui",
};

const variables = { input: checkoutData };
const { mutate, onDone, onError } = useMutation(CHECKOUT_MUTATION);

const { mutate, onDone, onError } = useMutation(CHECKOUT_MUTATION, {
variables,
});

mutate(checkoutData);
mutate({ input: checkoutData });

onDone(async () => await navigateTo("/success"));
onDone(async (result) => {
const { data } = result;
if (data?.checkout?.result === "success") {
await navigateTo("/success");
} else {
alert("Error, order not placed. Please try again.");
}
});

onError(() => alert("Error, order not placed"));
onError((error) => {
console.error("Checkout error:", error);
if (error.message.includes("session")) {
alert(
"Your session has expired. Please refresh the page and try again.",
);
} else {
alert("An unexpected error occurred. Please try again.");
}
});
};
</script>