Jump to content

how to create "CITY" sub-tab under "carriers" ?


sidro

Recommended Posts

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>';
   }
}

?>

19181_1nZ917U0zSt6nvUKV4v3_t

19185_FmhzOG7JwnbK7KXTvujz_t

19186_wc3uQOeI3SUU8bZFTCFC_t

AdminCities.php

Link to comment
Share on other sites

  • 9 months later...

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

  • 4 weeks later...

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_city
2. Build the city class
3. Adopt the admincities.php

But 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

  • 4 weeks later...
  • 3 weeks later...
  • 3 weeks later...

Hi Sidro.ro

Could 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

  • 4 weeks later...
  • 2 months later...
  • 8 months later...
  • 2 weeks later...
  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...