Describe the bug
When using ActionCarrierProcess hook in a module, the callback is correctly called but no POST value is availabled. Dumping $_POST returns an empty array and Tools::getValue returns false.
I found quite a few post online about this but no fix. Apparently this used to work on 1.6.
To Reproduce
Screenshots
If applicable, add screenshots or screenrecords to help explain your problem.
Additionnal information
PrestaShop version: 1.7.4.3
PHP version: 5.6.39
Hi @Lwackp,
Thanks for your report.
I manage to reproduce the issue with PS1.7.5.1 & PS1.7.4.4.
I checked with this code line added in my module
public function hookactionCarrierProcess($params)
{
if (isset($params['cart']->id_carrier)) {
$carrier_name = Db::getInstance()->getValue('SELECT name FROM `'._DB_PREFIX_.'carrier` WHERE id_carrier = '.(int)$params['cart']->id_carrier);
$this->_manageData('MBG.addCheckoutOption(2,\''.$carrier_name.'\');', 'A');
var_dump($_POST);
var_dump(Tools::getValue($_POST));
//die();
}
}
public function hookDisplayAfterCarrier()
{
return $this->display(__FILE__, 'views/templates/front/footer.tpl');
}
In the FO, in the checkout page
var_dump($_POST); => array(0) { } => an empty array
var_dump(Tools::getValue($_POST)); => bool(false) => false return


@marionf, what do you think?
Thanks!
No idea, let's ask to a dev @PrestaShop/prestashop-core-developers
This is because there is no POST data sent as you can see in request headers. It's a GET request.
GET /order HTTP/1.1
Host: ps-develop.localhost
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: http://ps-develop.localhost/cart?action=show
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,fr;q=0.8
Cookie: install_baf12c02e8ee=8n3a188h2pi1p41iel0ore2d1h; PrestaShop-a80f2042c85a205e9b790c4cd8a77b96=def5020027918413505cc49e012c987332ea5d078f17453244e19ae2f2a6206c1691b18f0ad3855286d1c4bc3afb3ba61597aca63cf6f32d621bac4178fc0b4627f7bc33a807c3029651b6a0de8cce0c30ef9020d525b5ffaaaf44a9c2ee0726032f91061a8a2822328d0b8b8ca012a75552cd4f3574e405d66ea58c2a4db7d8aeada3012693e7e9528f781d2ed7a92f40c9092e270c9714e9d967770afcd5005bdc09e9dc9e3f343a1f6447c33fe5747b272549df52e33febbe28b8deb187166a056b477fafdb23fb1ba2fe8ea9879fe5918937215e31bfe3eb4e113cc04683aa253283452b76c23bda3c5af89195b243678d96fd32f4b0b9f811ebe0fb1a8680b3a51343aac70b6eb037cd0af0ff7d827c3daaf80a9b4fffd17dcf3de653cb0033e39222c85874b63dd5fe0b86831a05f7534ca1ca03b9e490beab79; sf_redirect=%7B%22token%22%3A%22afc6e8%22%2C%22route%22%3A%22admin_module_configure_action%22%2C%22method%22%3A%22GET%22%2C%22controller%22%3A%7B%22class%22%3A%22PrestaShopBundle%5C%5CController%5C%5CAdmin%5C%5CImprove%5C%5CModuleController%22%2C%22method%22%3A%22configureModuleAction%22%2C%22file%22%3A%22%5C%2Fhome%5C%2Fprambaud%5C%2Fprojects%5C%2Fprestashop%5C%2Fsource%5C%2Fdevelop%5C%2Fsrc%5C%2FPrestaShopBundle%5C%2FController%5C%2FAdmin%5C%2FImprove%5C%2FModuleController.php%22%2C%22line%22%3A217%7D%2C%22status_code%22%3A302%2C%22status_text%22%3A%22Found%22%7D; PHPSESSID=5mvtsuar9p9g9t6n3kg8q0g73n; PrestaShop-cfa419bf99f08ced4690f66ea60f7187=def5020081248ba942293794c926c7598edcc58d99657a78c78497c439c40805a1b607d919b9b8a6d323e1b99698ffb56695d03e5dbea3373ca13a33306ef3f9276f7b55f8d0cd55777c2bafa7a83a51449cb83f23639bed087a1f05b7bc36a0580ae1e744ce8dff98d046cd02925a17e7e6146f077cda99cc32013688336e3c72e155d2bbdc10a6bfc2475ca65854fdfc531db9409f087209a3de3a2f36e19beb830dae474bc82a1d0c9f0ffee6785458f5f014e6735d6e4543db5de910ae30d865077c60606210cf44beff300a93e05347f34028fc3a566fbdbeb00ade7bef60
Is that a bug or a feature?
@Lwackp, it is a feature, @PierreRambaud is it?
Thanks!
As I know, it's not a feature nor a bug, you can't send POST data in GET context.
If you need to add some parameters, you maybe need to do it in javascript and add parameters to your request URL.
I'm not the best one to answer you maybe @Quetzacoalt91 knows a better way to play with custom fields here.
In my opinion, data retrieved via POST or GET is totally unrelated to the hook feature. As the checkout funnel has changed on PS 1.7, I'm not surprised to read you cannot retrieve data this way.
The only reliable source of data in a hook can be found in the $param variable of the method, or eventually the Context content.