Intercept "next page" on checkout for custom plugin.

  • Posts: 12
  • Thank you received: 0
5 years 3 months ago #301228

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.

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
5 years 3 months ago #301231

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:

window.checkout.onFormSubmit =  function(form) {
 // your code
 // return false if you don't want the form to submit.
}
That will be triggered when you click on the "next" button of each step of your checkout.

Please Log in or Create an account to join the conversation.

  • Posts: 12
  • Thank you received: 0
5 years 3 months ago #301287

Thanks for your answer.
It's the javascript side that I needed.

I'll make some tests

Last edit: 5 years 3 months ago by raphaelr@alkaonline.be.

Please Log in or Create an account to join the conversation.

Time to create page: 0.037 seconds
Powered by Kunena Forum