Lwack Posted February 26, 2019 Share Posted February 26, 2019 (edited) Hello, I've developped a small Carrier module to add delivery options with checkboxes. I'm displaying the checkboxes with the DisplayCarrierExtraContent hook. My problem is I don't know how to retrieve the $_POST values from the form. My module hookActionCarrierProcess method is correctly called, but it seems that the $_POST variable is empty (dumping it is showing [ ]). I've tried with Tools::getValue but obviously it returns false too. When I press the submit button after selecting my carrier and checking some options, it seems that the $_POST values are correctly sent but the server responds with the following HTTP code: 302 Moved Temporarly. What's weird is that submitting the form does trigger my code from the hookActionCarrierProcess method. Why is $_POST value empty when hookActionCarrierProcess is called ? Is there another way to send the form values (the checkboxes) to the hookActionCarrierProcess method ? I hope I am clear enough. Thanks a lot for your help Edited February 26, 2019 by Lwack typo (see edit history) Link to comment Share on other sites More sharing options...
Teemu Mäntynen Posted February 27, 2019 Share Posted February 27, 2019 Use ajax to send input field data from carrier extra content to a front controller of your module. Have the front controller to save the data to database. Read the data from database during later stages of the checkout process. Link to comment Share on other sites More sharing options...
Lwack Posted February 27, 2019 Author Share Posted February 27, 2019 That should work indeed. Though I'm still curious why $_POST is empty when hookActionCarrierProcess is triggered... Link to comment Share on other sites More sharing options...
Vania Elizondo Posted July 22, 2020 Share Posted July 22, 2020 Did you make it work? Can you provide an example of how you are displaying your carriers on the delivery process? I'm having problems myself with the radio button as well. Thank you Link to comment Share on other sites More sharing options...
Lwack Posted July 28, 2020 Author Share Posted July 28, 2020 I ended up overriding OrderController::displayAjaxselectDeliveryOption in my module. From there you can access Tools::getValue('your_value') <?php // modules/MyModule/override/controllers/front/OrderController.php class OrderController extends OrderControllerCore { public function displayAjaxselectDeliveryOption() { $cart = $this->cart_presenter->present( $this->context->cart ); if ($this->context->cart->id_carrier == Configuration::get('MY_DELIVERY_CARRIER_ID')) { // Setting the options here } ob_end_clean(); header('Content-Type: application/json'); $this->ajaxDie(Tools::jsonEncode(array( 'preview' => $this->render('checkout/_partials/cart-summary', array( 'cart' => $cart, 'static_token' => Tools::getToken(false), )) ))); } } Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now