Sachin@Sharma Posted June 21, 2019 Share Posted June 21, 2019 Hi Guys, I am so new to Prestashop and i would like to edit the "postcode" , "City" and "state" textbox on the checkout page. I would like to put a default un-editable entry to the textbox(I would like to freeze the textbox with a single value) on the checkout page. I have attached the pdf of that page i wish to edit. Please let me know which file to edit and how...please. Decathlon.pdf Link to comment Share on other sites More sharing options...
Thierry_montpellier Posted June 25, 2019 Share Posted June 25, 2019 Hello, I have the same problem as you but to block to a zip code / city Prestashop version: 1.7.5 Did you find a solution? Thierry Link to comment Share on other sites More sharing options...
Sachin@Sharma Posted June 26, 2019 Author Share Posted June 26, 2019 ya I got the solution. you can do one-thing inside your form-fields.tpl which is inside this directory- ..../templates/_partials/form-fields.tpl: {block name='form_field_item_other'} <input class="form-control input-box" name="{$field.name}" type="{$field.type}" placeholder="{$field.name}" value="{$field.value}" {if isset($field.availableValues.placeholder)}placeholder="{$field.availableValues.placeholder}"{/if} {if $field.maxLength}maxlength="{$field.maxLength}"{/if} {if $field.required}required{/if} {if $field.readonly}readonly{/if} // add this line > after that is customerAddressFormatter.php set $formField->setReadonly(true); in city and state inside validation part, file path is - ...override/classes/forms, after that in formfields.php write get and set methods for readonly like...... class FormFieldCore { private $readonly = false; public function toArray() { return [ 'required' => $this->isRequired(), 'readonly' => $this->isReadonly(), ]; } public function setReadonly($readonly) { $this->readonly = $readonly; return $this; } public function isReadonly() { return $this->readonly; } } Link to comment Share on other sites More sharing options...
Thierry_montpellier Posted July 1, 2019 Share Posted July 1, 2019 Hi Thank you for your answer You are on prestashop 1.7.5 because I can not find the same files as you ? for : ../themes/xxxxxxxx/templates/_partials/form-fields.tpl I added the line as you say {if $field.readonly}readonly{/if} // add this line then i do not understand where you find the file customerAddressFormatter.php and what needs to be done. Could you be more precise? Link to comment Share on other sites More sharing options...
Sachin@Sharma Posted July 1, 2019 Author Share Posted July 1, 2019 inside clases/form/ directory there is a file names as customerAddressFormatter.php there is a function getFormate() inside that function a foreach loop like foreach ($fields as $field) { //inside this something like this if ( xxxxxxxxx) { if ($field === 'city') { $formField->setType('text'); $formField->setReadonly(true); //add this line $formField->setName(strtolower($field)); } if ($field === 'other') { if($autopincodecity && !($OtherFiledEnable)){ $formField->setType('select'); } if($autopincodecity && $OtherFiledEnable){ $formField->setType('hidden'); } } } if ($entity === 'Country') { $formField->setType('countrySelect'); $formField->setValue($this->country->id); foreach ($this->availableCountries as $country) { $formField->addAvailableValue( $country['id_country'], $country[$entityField] ); } } elseif ($entity === 'State') { $formField->setType('text'); $formField->setRequired(true); $formField->setReadonly(true); //add this line // if ($this->country->contains_states) { // $states = State::getStatesByIdCountry($this->country->id, true); // foreach ($states as $state) { // $formField->addAvailableValue( // $state['id_state'], // $state[$entityField] // ); // } // $formField->setRequired(true); // } } } and after this classes/formfield.php inside this file difine variable like private $readonly = false; inside toArray() function 'readonly' => $this->isReadonly(). after that add get and set property... public function setReadonly($readonly) { $this->readonly = $readonly; return $this; } public function isReadonly() { return $this->readonly; } hope you understand now.. Thanks Link to comment Share on other sites More sharing options...
Sachin@Sharma Posted July 1, 2019 Author Share Posted July 1, 2019 for zipcode you also add $formField->setReadonly(true); like city and state 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