- Posts: 12
- Thank you received: 0
Intercept "next page" on checkout for custom plugin.
- raphaelr@alkaonline.be
-
Topic Author
- Offline
Less
More
7 years 9 months ago #301228
by raphaelr@alkaonline.be
Hello everybody.
I am currently creating a plugin for hikashop.
During the checkout process I added some fields dynamically with onCheckoutStepDisplay and onCheckoutStepList.
My fields are correctly created and works well. But if the fields are not filled I would like to make an alert to the customer before he goes to the next checkout step. Something "are you sure you didn't want to blablabla...".
I tried to "intercept" the submit of the form (the checkout is not in ajax on the website I am working on) but the event.prenventDefault() doesn't work.
So I made some research and found that there's something to do with window.Oby but I can't find what to do and if this is compatible without using the ajax checkout.
Please I need some help.
Best regards.
I am currently creating a plugin for hikashop.
During the checkout process I added some fields dynamically with onCheckoutStepDisplay and onCheckoutStepList.
My fields are correctly created and works well. But if the fields are not filled I would like to make an alert to the customer before he goes to the next checkout step. Something "are you sure you didn't want to blablabla...".
I tried to "intercept" the submit of the form (the checkout is not in ajax on the website I am working on) but the event.prenventDefault() doesn't work.
So I made some research and found that there's something to do with window.Oby but I can't find what to do and if this is compatible without using the ajax checkout.
Please I need some help.
Best regards.
Please Log in or Create an account to join the conversation.
7 years 9 months ago #301231
by nicolas
Replied by nicolas on topic Intercept "next page" on checkout for custom plugin.
Hi,
If you implement the onAfterCheckoutStep trigger www.hikashop.com/support/documentation/6...#onAfterCheckoutStep in your plugin.
There, check if the data is there, and if not set the variable $go_back to true and the user won't be able to go to the next step.
You can also use the $app->enqueueMessage() function of Joomla to display a message to the user.
Now that's in PHP.
If you also want to do a similar check in javascript, you can redefine the window.checkout.onFormSubmit function like that:
That will be triggered when you click on the "next" button of each step of your checkout.
If you implement the onAfterCheckoutStep trigger www.hikashop.com/support/documentation/6...#onAfterCheckoutStep in your plugin.
There, check if the data is there, and if not set the variable $go_back to true and the user won't be able to go to the next step.
You can also use the $app->enqueueMessage() function of Joomla to display a message to the user.
Now that's in PHP.
If you also want to do a similar check in javascript, you can redefine the window.checkout.onFormSubmit function like that:
Code:
window.checkout.onFormSubmit = function(form) {
// your code
// return false if you don't want the form to submit.
}
Please Log in or Create an account to join the conversation.
- raphaelr@alkaonline.be
-
Topic Author
- Offline
Less
More
- Posts: 12
- Thank you received: 0
7 years 9 months ago - 7 years 9 months ago #301287
by raphaelr@alkaonline.be
Replied by raphaelr@alkaonline.be on topic Intercept "next page" on checkout for custom plugin.
Thanks for your answer.
It's the javascript side that I needed.
I'll make some tests
It's the javascript side that I needed.
I'll make some tests
Last edit: 7 years 9 months ago by raphaelr@alkaonline.be.
Please Log in or Create an account to join the conversation.
Time to create page: 0.157 seconds