Jump to content

[Solved]地址问题 / Address show wrong state


ladivito

Recommended Posts

Back Office >> Shipping >> Countries(你设置的国家) >> Contains states 有没有Enable?


已经enable了。

比如正确的地址是China (ShangHai), 但是在Prestashop的却是China (Hawaii) <--突然之间变成美国的州属
正在懊恼中,已经来回确认很多次。
Link to comment
Share on other sites

Add/Modify 也确认设置正确了

<?php

/**
 * State class, State.php
 * States management
 * @category classes
 *
 * @author PrestaShop 
 * @copyright PrestaShop
 * @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
 * @version 1.2
 *
 */

class        State extends ObjectModel
{
   /** @var integer Country id which state belongs */
   public         $id_country;

   /** @var integer Zone id which state belongs */
   public         $id_zone;

   /** @var string 2 letters iso code */
   public         $iso_code;

   /** @var string Name */
   public         $name;

   /** @var interger Tax behavior */
   public        $tax_behavior;

   /** @var boolean Status for delivery */
   public        $active = true;

    protected     $fieldsRequired = array('id_country', 'id_zone', 'iso_code', 'name', 'tax_behavior');
    protected     $fieldsSize = array('iso_code' => 4, 'name' => 32);
    protected     $fieldsValidate = array('id_country' => 'isUnsignedId', 'id_zone' => 'isUnsignedId', 'iso_code' => 'isStateIsoCode', 'name' => 'isGenericName', 'tax_behavior' => 'isUnsignedInt', 'active' => 'isBool');

   protected     $table = 'state';
   protected     $identifier = 'id_state';

   public function getFields()
   {
       parent::validateFields();
       $fields['id_country'] = intval($this->id_country);
       $fields['id_zone'] = intval($this->id_zone);
       $fields['iso_code'] = pSQL(strtoupper($this->iso_code));
       $fields['name'] = pSQL($this->name);
       $fields['tax_behavior'] = intval($this->tax_behavior);
       $fields['active'] = intval($this->active);
       return $fields;
   }

   public static function getStates($id_lang, $active = false)
   {
       return Db::getInstance()->ExecuteS('
           SELECT `id_state`, `id_country`, `id_zone`, `iso_code`, `name`, `tax_behavior`, `active`
           FROM `'._DB_PREFIX_.'state`
           '.($active ? 'WHERE active = 1' : '').'
           ORDER BY `name` ASC');
   }

   /**
   * Get a state name with its ID
   *
   * @param integer $id_state Country ID
   * @return string State name
   */
   static public function getNameById($id_state)
   {
       $result = Db::getInstance()->getRow('
       SELECT `name`
       FROM `'._DB_PREFIX_.'state`
       WHERE `id_state` = '.intval($id_state));

       return $result['name'];
   }

   /**
   * Get a state id with its name
   *
   * @param string $id_state Country ID
   * @return integer state id
   */
   static public function getIdByName($state)
   {
         $result = Db::getInstance()->getRow('
       SELECT `id_state`
       FROM `'._DB_PREFIX_.'state`
       WHERE `name` LIKE \''.pSQL($state).'\'');

       return (intval($result['id_state']));
   }    
}

?>



谢谢你的协助 ~ 非常感谢 :)

Link to comment
Share on other sites

本地XAMPP测试使用的是default versions。你可以比较一下各个版本的AdminStates.php和AdminCountries.php,然后再merge;或者直接override。

BTW,在SVN里,没有找到相关的改动。

(如果我有错误,请更正我。)

Link to comment
Share on other sites

应该是文件出错了。。。。我overwrite之前的有问题的文件那么新的folder就有同样问题。。。。

请问,在country,state....etc 相关的文件有哪些 ? 我不可以全部overwrite新的文件下去因为目前我做了相当多的更改在其他文件里面

谢谢

Link to comment
Share on other sites

相关的文件就是admin/tab/AdminStates.php和AdminCountries.php。这两个文件你有改动吗?

关于override,最好不要在FTP里直接覆盖,应先删除旧文件或者更名备份,再上传新文件。这是我的方法。

另外,改动较大的话,你可以尝试用WinMerge来合并更改内容。

Link to comment
Share on other sites

admin/tab/AdminStates.php和AdminCountries.php 你没有改动吧?其实也不需要有什么改动。他们是程序文件而已。你改动的是模板文件。所以程序是对的。记得去cancel你的bug report哦。还有修改这帖子的标题,以便其他人获取经验。谢谢!;-)

Link to comment
Share on other sites

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...