sidro Posted February 20, 2010 Share Posted February 20, 2010 how to add "city" tab under "carriers" tab in back-office to be used to calculate the price of expedition by city not by state/country/zone?in front-office registration needs to appear as a dropdown and the client to select it, not write it.I've tried to modify the AdminStates.php into AdminCities.php (State variabe transformed in City variabe) and create new ps_city table from phpmyadmin but in BO I get "Bad SQL" <?php /** * Cities tab for admin panel, AdminCities.php * @category admin * */ include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php'); class AdminCities extends AdminTab { public function __construct() { $this->table = 'city'; $this->className = 'Cities'; $this->edit = true; $this->delete = true; $this->fieldsDisplay = array( 'id_city' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Name'), 'width' => 140, 'filter_key' => 'a!name'), 'iso_code' => array('title' => $this->l('ISO code'), 'align' => 'center', 'width' => 50), 'country' => array('title' => $this->l('Country'), 'width' => 100, 'filter_key' => 'z!name')); $this->_select = 'z.`name` AS country'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'country` z ON (z.`id_country` = a.`id_country`)'; parent::__construct(); } public function displayForm() { global $currentIndex, $cookie; $obj = $this->loadObject(true); echo ' <form action="'.$currentIndex.'&submitAdd;'.$this->table.'=1&token;='.$this->token.'" method="post"> '.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').' '.$this->l('Cities').' '.$this->l('Name:').' <input type="text" size="30" maxlength="32" name="name" value="'.htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8').'" /> * '.$this->l('State name to display in addresses and on invoices').' '.$this->l('ISO code:').' <input type="text" size="4" maxlength="3" name="iso_code" value="'.htmlentities($this->getFieldValue($obj, 'iso_code'), ENT_COMPAT, 'UTF-8').'" style="text-transform: uppercase;" /> * '.$this->l('2- or 3-letter ISO code').' ('.$this->l('official list here').') '.$this->l('State:').' '; $states = State::getStates(intval($cookie->id_lang), false, true); foreach ($states AS $state) echo 'getFieldValue($obj, 'id_state') == $state['id_state']) ? ' selected="selected"' : '').'>'.$state['name'].''; echo ' '.$this->l('States where city is located').' '.$this->l('Country:').' '; $countries = Country::getCountries(); foreach ($countrie AS $country) echo 'getFieldValue($obj, 'id_country') == $country['id_country']) ? ' selected="selected"' : '').'>'.$country['name'].''; echo ' '.$this->l('Geographical zone where this city is located').' '.$this->l('Used for shipping').' '.$this->l('Status:').' <input type="radio" name="active" id="active_on" value="1" '.((!$obj->id OR $this->getFieldValue($obj, 'active')) ? 'checked="checked" ' : '').'/> l('Enabled').'" title="'.$this->l('Enabled').'" /> <input type="radio" name="active" id="active_off" value="0" '.((!$this->getFieldValue($obj, 'active') AND $obj->id) ? 'checked="checked" ' : '').'/> l('Disabled').'" title="'.$this->l('Disabled').'" /> '.$this->l('Enabled or disabled').' <input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" /> * '.$this->l('Required field').' </form>'; } } ?> AdminCities.php Link to comment Share on other sites More sharing options...
sidro Posted February 22, 2010 Author Share Posted February 22, 2010 any idea ? anyone ? Link to comment Share on other sites More sharing options...
saulon Posted December 4, 2010 Share Posted December 4, 2010 did you solve it mate? i need something like this!! Link to comment Share on other sites More sharing options...
sidro Posted December 5, 2010 Author Share Posted December 5, 2010 not yet. but i do need some help with this. Link to comment Share on other sites More sharing options...
saulon Posted December 5, 2010 Share Posted December 5, 2010 hmmm i was thinking something like creating a new table of cities just like states, and copy the way states work for the cities, i mean instead of COUNTRY CODE, they would have STATE CODE, just to identify... but im not sure where to start, any further ideas? Link to comment Share on other sites More sharing options...
sidro Posted December 5, 2010 Author Share Posted December 5, 2010 already tried that and it's not working Link to comment Share on other sites More sharing options...
beginpresta Posted December 29, 2010 Share Posted December 29, 2010 Have you solved it? Link to comment Share on other sites More sharing options...
beginpresta Posted January 3, 2011 Share Posted January 3, 2011 I have done it.Do you need any help? Link to comment Share on other sites More sharing options...
semijaya Posted January 8, 2011 Share Posted January 8, 2011 Hi all,I'm new in prestashop. Can you continue the add cities discussion, it will be very helpful for us the students of prestashop.I've tried some steps in building the tab cities on the shipping tab :1. Make the ps_city2. Build the city class3. Adopt the admincities.phpBut still with no result, not even the cities tab appears in my backoffice page.Can someone help me with this.Thanks Link to comment Share on other sites More sharing options...
beginpresta Posted January 8, 2011 Share Posted January 8, 2011 Hi, Please alter PS_Tab and PS_Access tables.Add gif file for cities to Img/t.If you need any more help,please let me know. Link to comment Share on other sites More sharing options...
eCasper Posted January 9, 2011 Share Posted January 9, 2011 @sidro.ro I can see you have defined a different class for cities. $this->className = 'Cities'; May I know where is the source of the Cities class? Link to comment Share on other sites More sharing options...
xmax316 Posted January 31, 2011 Share Posted January 31, 2011 I have done it.Do you need any help? Hello... Did you finaly did the city thing for scrolling down?Can you pls help me get it? Link to comment Share on other sites More sharing options...
evilnick Posted February 20, 2011 Share Posted February 20, 2011 Hi mates,I also need some help on this.Is there any naming convention for className?Must the table name be equal to the class name?SOLVED: I just discovered the table name must be the same as the class name and the identifier must be id_tablename Link to comment Share on other sites More sharing options...
clarify Posted March 10, 2011 Share Posted March 10, 2011 Hi Sidro.roCould you please suggest me if you have found solution to this?I am also looking to customize my shop with the same requirement.I would like to restrict my shipping to certain cities and hence it would be appropriate to allow the users to select the city instead of typing into the input box.Your help would be highly appreciated.thanks in advance Link to comment Share on other sites More sharing options...
GhoHan Posted April 2, 2011 Share Posted April 2, 2011 Here also same requesting Link to comment Share on other sites More sharing options...
Baby Moon Posted June 8, 2011 Share Posted June 8, 2011 Hi, there,It's worked after I've changed 'country' to 'state'. But the new problem is the Add New has no actions.BTW, whether ps_city needs a id_zone field? Link to comment Share on other sites More sharing options...
velasko Posted February 18, 2012 Share Posted February 18, 2012 Did anyone could make this work? Link to comment Share on other sites More sharing options...
velasko Posted February 29, 2012 Share Posted February 29, 2012 OK. I guess no... Link to comment Share on other sites More sharing options...
doigro Posted October 20, 2013 Share Posted October 20, 2013 Hello, did you find any solution to this? 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