martr Posted June 13, 2017 Share Posted June 13, 2017 (edited) Hi, everyone! Our web site is renting out products so I need to add "from" and "to" datepicker forms to checkout. I managed to add the forms and figured I will receive the information by adding the date inputs to '#message' variable. So in order-opc.js in $('#message').blur(function() I changed the data line to: data: 'ajax=true&method=updateMessage&message=' + encodeURIComponent($('#message').val()).concat(encodeURIComponent($('#message_delivery').val()), encodeURIComponent($('#message_from').val())) + '&token=' + static_token , However it only saves the '#message_delivery' and '#message_from', but not the '#message' (referring in my case to the „from:“ datepicker input). What am I doing wrong? How could I save all three inputs to #message variable? PS. Here is the link to our web page: http://www.matkavarustuserent.ee/ Any help appreciated. Edited June 15, 2017 by martr (see edit history) Link to comment Share on other sites More sharing options...
martr Posted June 19, 2017 Author Share Posted June 19, 2017 I am trying another approach: to save 'Rent From' and 'Rent To' fields during Checkout into database. What I have done so far:1) Added rent_from and rent_to columns to ps_orders and ps_cart2) Added in Cart.php on line 77 public $rent_from; public $rent_to; and around on line 132 inside 'fields' => array 'rent_from' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'rent_to' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 3) Added in PaymentModule.php on line 333: $order->rent_from = $this->context->cart->rent_from; $order->rent_to = $this->context->cart->rent_to; 4) Added the fields for front end in order-carrier.tpl The input is not yet saved to database. I understand I willl also need to modify the controller files, but I'm unable to find which one and how exactly. Can anyone help? PS. I have found similar topics, but none that would apply to exactly my situation: adding a custom field during checkout for Prestashop 1.6 Link to comment Share on other sites More sharing options...
martr Posted June 19, 2017 Author Share Posted June 19, 2017 (edited) I looked more into my first approach (see first post) and figured it's not an issue with javascript, but with how I add the DatePicker. Because when I change the third input to regular text field, then everything works fine. Here is the code from order-carrier.tpl: <div> <p>{l s='If you would like to add a comment about your order, please write it in the field below.'}</p> <textarea class="form-control" cols="120" rows="1" name="message_delivery" id="message_delivery">{strip} {if isset($oldMessage)}{$oldMessage|escape:'html':'UTF-8'}{/if} {/strip}</textarea> </div> <script> $(document).ready(function() { $('.customDatePicker').datepicker(); }); </script> <h1 class="page-heading">{l s='Rental period:'}</h1> <p>{l s='Please select at what dates you wish to rent the equiptment.'}</p> <div class="required form-group col-50"> <label for="date_from">{l s='From:'} <sup>*</sup></label> <input type="text" class="form-control customDatePicker" name="rent_from" id="rent_from"> </div> <div class="required form-group col-50"> <label for="message">{l s='To:'} <sup>*</sup></label> <input type="text" class="form-control customDatePicker" name="message" id="message"> </div> While order-opc.js is data: 'ajax=true&method=updateMessage&message=' + $('#message_delivery').val() + ', ' + $('#rent_from').val() + ' - ' + $('#message').val() + '&token=' + static_token , When the inputs are 'Rebase', '22.06.2017' and '25.06.2017', only 'Rebase, 22.06.2017 -' is saved to database. Edited June 19, 2017 by martr (see edit history) 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