Jump to content



Recommended Posts

Is there any such thing in PrestaShop?


By which I mean, is there anywhere I can set a pre-defined URL to POST data upon a PrestaShop action such as creating a new order.



  1. User places order
  2. Webhook is fired and POSTS the order data to a pre-defined URL such as http://www.example.com/incoming
  3. Data is then parsed and synchronised with our stock control services.


The only way I can think of doing this is extending the OrderDetailCore class and adding in the hook manually using cURL. Something like:

class OrderDetail extends OrderDetailCore {
    public function create(Order $order, Cart $cart, $product, $id_order_state, $id_order_invoice, $use_taxes = true, $id_warehouse = 0) {
        parent::create($order, $cart, $product, $id_order_state, $id_order_invoice, $use_taxes, $id_warehouse);
        curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/incoming');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $product);
Link to comment
Share on other sites

i don't understand your expectactions well but i think that you're talking about webservice (?)

it's a kind of API to manage store based on something like "SOAP"



No I'm not talking about the SOAP Webservice. I want a method to be called whenever another method is called. The method I want calling will fire off some data via a POST request.


Something like the Github webhooks. https://developer.github.com/webhooks/


A good definition of a webhook can be seen here: http://en.wikipedia.org/wiki/Webhook


Webhooks are "user-defined HTTP callbacks".[2] They are usually triggered by some event, such as pushing code to a repository[3] or a comment being posted to a blog.[4] When that event occurs, the source site makes an HTTP request to the URI configured for the webhook. Users can configure them to cause events on one site to invoke behaviour on another.


Don't those just hook into the views?
Edited by xbenjii (see edit history)
Link to comment
Share on other sites


Ah, I see. Thanks for the help.


Came up with something like this, will be expanded later.


if (!defined("_PS_VERSION_"))

class orderHook extends Module {

    public function __construct() {
        $this->name = "orderHook";
        $this->tab = "checkout";
        $this->version = "0.1";
        $this->author = "Benjamin Fortune";

        $this->need_instance = 0;
        $this->ps_versions_compliancy = array('min' => '1.6', 'max' => '1.6');
        $this->dependencies = array();


        $this->displayName = $this->l("Order Hook");
        $this->description = $this->l("Fires a POST request to a pre-defined URL upon order creation.");

        $this->confirmUninstall = $this->l("Are you sure you want to uninstall?");

        if (!Configuration::get('orderHook'))
            $this->warning = $this->l('No name provided.');

    public function install() {
        if (Shop::isFeatureActive())

        return parent::install() &&
                $this->registerHook('actionValidateOrder') &&
                Configuration::updateValue('ORDER_HOOK_URL', 'http://localhost/orders/incoming');

    public function uninstall() {
        return parent::uninstall() &&

    public function hookactionValidateOrder($params) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, Configuration::get('ORDER_HOOK_URL'));
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));

Link to comment
Share on other sites

  • 8 months later...

Did this webhook module ever get added to the store?

I really need one for slack.

Basically on the exact same scenario as you.

This really should be build into the system IMO.


Not as such, I did end up creating a little module which should do the job though. It hasn't been updated so I don't know how it'll work with the latest version. Let me know if you have any problems.



  • Like 1
Link to comment
Share on other sites

  • 3 months later...



I tried uploading the webhook.zip that you provided and got the following errors in prestashop:


  1. webhook (parse error in /modules/webhook/webhook.php)
  2. webhook (class missing in /modules/webhook/webhook.php)

I was wondering if you could help since I really want to be able to use webhooks in the form you have implemented.


I am also surprised such a standard feature isn't available.

Link to comment
Share on other sites

  • 6 months later...
  • 1 year later...
40 minutes ago, stweet said:


This is very old module. Don't think it is working in latest Prestashop versions. Which PS version are you using ?

The hack mentioned here before does not work ?

On 10.5.2016 at 6:01 PM, bpoller said:



I encountered the same problem.


In webhook.php, replacing <?PHP by <?php did the trick for me.


Hope this helps someone...


Link to comment
Share on other sites

  • 1 year 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...