Jump to content

Module: ViewAdminOrder > Form to submit to api then echo data (little help needed).


Recommended Posts

Hi,

I have created a module where a form is added to the admin view order page with:

public function hookDisplayAdminOrderSide($params)

The form posts data to the same url:

 <form method="POST" action="#">

I then use the hook "hookDisplayAdminOrderTop" to capture the post data and submit to the API on the page reload. I then collect the results of the api and assign it to $result. This then allows me to echo if the submission worked etc

This all works fine.

However, I'm pretty sure this is not the correct way to do this with Prestashop. Usually with a form I would send the user to another page e.g. 

 <form method="POST" action="/submit.php">

Then on that page once the data has been submitted, redirect the user to a confirmation page.

Whilst what I have done is working, what is the correct way to do this with prestashop (p.s. I'm new to Prestashop, this is my 1st module) so try and keep the advice easy to follow?

I looked at the other forms on the page e.g. status update form and private note form, they all seem to post to the same url but with a slight change e.g.

index.php/sell/customers/2/set-private-note
index.php/sell/orders/2/status
index.php/sell/orders/2/send-message

I'm assuming the "set-private-note" and "status" etc are linked to some form for submission form in the PS back end.

 

Finally, on a second note, if you create a 2nd php file in the module root folder, what needs to be added to keep this secure e.g. so someone outside of the admin can't run it etc?

 

Any help would be greatly appreciated.

Thanks in advance :) 

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...