Jump to content

Override order module


macjo

Recommended Posts

Hey everyone, 

Here is the problem that I'm facing. I want to modify the ordering process to so that I can integrate my own order validation (while keeping the Prestashop validation).
In the lack of a pen and paper here I'll try to explain it the best I can.
 

While prestashop confirms the order I want to add an "extra step" where I contact my ERP server and ask him to validate me the products. This would be when "proceed to checkout" is "clicked". This process is made possible by a simple http post to my server where in confirms me that everything ok (ex: all the items are in stock) or not ok and I get an http get in return with code 202 ,500 or 504...
If everything is ok I get to the payment method. If error occurs I should use prestashop error handling and go back to the cart and display an error message.

I'm having a hard time figuring out which file/class I should override or modify.
Any tips are helpful.

Thank you

Edited by macjo (see edit history)
Link to comment
Share on other sites

The Proceed to Checkout button only exists when using 5 page checkout with PS v1.6, so I am going with that assumption.

When you click Proceed to Checkout, that executes the OrderController step 1 (which extends from ParentOrderController)

Now there are generally 2 approachs.

1) You create a module and hope there is a module hook that you can use

2) You customize/override the OrderController or ParentOrderController

 

For option 1, there are the displayShoppingCart and displayPaymentTop hooks that come to mind. 

I believe displayShoppingCart hook would allow you to execute code and display a message directly above the "Proceed to Checkout" button.  One idea is to display the message and then via javascript disable or alter the "Proceed to Checkout" button so the customer cannot proceed if there is an issue

The displayPaymentTop hook could also be used, in a similar way it would allow you to execute code and display a message on the top of the payment step.  However it would not prevent them from selecting a payment method.

 

For option 2, you could customize or override the initContent function.  This will take some exploring as to where to inject your custom logic.  I would probably advise you to figure out how to accomplish it using a module and the hooks above.

Link to comment
Share on other sites

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...