Prehooks

to add a prehook it must be done as follows in the config.json

{
    "name": "Preehooks",
    "description": "Test plugin for prehooks.",
    "author": "Ordering Inc (Jorge Diaz)",
    "url": "https://ordering.co",
    "version": "0.0.1",
    "hooks": {
        "prehooks": {
            "cart_place": "/prehook.php"
        }
    }
}

You can see the list of available prehooks in the hooks List

The response that the prehook must return is necessarily as follows:

  • case of success the merge object will add or replace values sent in the body this field is not mandatory data and error yes
$data = [
    'error' => false,
    'data' => [
        'data_1' => 1,
        'data_2' => 2
    ],
    'merge' => [
        'data_1' => 1,
        'data_2' => 2
    ]
];
  • In case of error, you can only send a string or an array of strings in the result, this can be a lang key or a text explaining the error
$data = [
    'error' => true,
    'data' => [
        'error_1',
        'error_2' 
    ]
];