Prestashop 大写客户地址

Prestashop capitalize customer address

我需要将 Prestashop 1.6 中的所有用户数据都大写 - 我已经设法完成名称等操作,但我不知道在哪里可以对地址进行此​​操作。

我猜是 AddressController 的 processSubmitAddress() 方法,但我找不到它从哪里获取输入,所以我可以 strotupper() 那个。感谢您的指导。

由于缺乏帮助,我决定采取一些解决方法 - 我实际上在数据库上设置了一个触发器,它在插入或更新时使用 SQL 的 UPPER() 转换指定的数据函数。

有点晚了,但就在这里。只需根据需要更改 ucfirst,在本例中为 strotupper()。这是客户的地址。在同一个文件中应该有针对不同客户数据的其他文件。这也适用于 PS 1.7.2(已测试)

转到yourprojectfolder/classes/Address.php

在第 169 行搜索 public function add($autodate = true, $null_values = false)

替换:

public function add($autodate = true, $null_values = false)
{
    if (!parent::add($autodate, $null_values)) {
        return false;
    }

    if (Validate::isUnsignedId($this->id_customer)) {
        Customer::resetAddressCache($this->id_customer, $this->id);
    }
    return true;
}

与:

public function add($autodate = true, $null_values = false)
{
  if (!parent::add($autodate, $null_values)) {
      return false;
  }

  // Capitalize the first name
  $this->firstname = ucfirst($this->firstname);

  // Capitalize the first name
  $this->lastname = ucfirst($this->lastname);

  // Capitalize the address fields
  $this->address1 = ucfirst($this->address1);
  $this->address2 = ucfirst($this->address2);

  if (Validate::isUnsignedId($this->id_customer)) {
      Customer::resetAddressCache($this->id_customer, $this->id);
  }
  return true;
}

在第 181 行搜索 public function update($null_values = false)

Replace :



public function update($null_values = false)
{
    // Empty related caches
    if (isset(self::$_idCountries[$this->id])) {
        unset(self::$_idCountries[$this->id]);
    }
    if (isset(self::$_idZones[$this->id])) {
        unset(self::$_idZones[$this->id]);
    }

    if (Validate::isUnsignedId($this->id_customer)) {
        Customer::resetAddressCache($this->id_customer, $this->id);
    }

    return parent::update($null_values);
}

与:

public function update($null_values = false)
{
  // Empty related caches
  if (isset(self::$_idCountries[$this->id])) {
      unset(self::$_idCountries[$this->id]);
  }
  if (isset(self::$_idZones[$this->id])) {
      unset(self::$_idZones[$this->id]);
  }

  // Capitalize the first name
  $this->firstname = ucfirst($this->firstname);

  // Capitalize the first name
  $this->lastname = ucfirst($this->lastname);

  // Capitalize the address fields
  $this->address1 = ucfirst($this->address1);
  $this->address2 = ucfirst($this->address2);

  if (Validate::isUnsignedId($this->id_customer)) {
      Customer::resetAddressCache($this->id_customer, $this->id);
  }

  return parent::update($null_values);
}

而不是更改 PrestaShop 核心。您还可以使用覆盖选项。

创建文件 yourprojectfolder/override/classes/Address.php 并插入此代码并保存文件:

<?php
/**
* Fix for capitalize and submit the first letters of the name and address input fields
*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
*  @author Peter Visser <info@mark-app.com>
*/

class Address extends AddressCore
{

  public function update($null_values = false)
  {
    // Empty related caches
    if (isset(self::$_idCountries[$this->id])) {
        unset(self::$_idCountries[$this->id]);
    }
    if (isset(self::$_idZones[$this->id])) {
        unset(self::$_idZones[$this->id]);
    }

    // Capitalize the first name
    $this->firstname = ucfirst($this->firstname);

    // Capitalize the first name
    $this->lastname = ucfirst($this->lastname);

    // Capitalize the address fields
    $this->address1 = ucfirst($this->address1);
    $this->address2 = ucfirst($this->address2);

    if (Validate::isUnsignedId($this->id_customer)) {
        Customer::resetAddressCache($this->id_customer, $this->id);
    }

    return parent::update($null_values);
  }

  public function add($autodate = true, $null_values = false)
  {
    if (!parent::add($autodate, $null_values)) {
        return false;
    }

    // Capitalize the first name
    $this->firstname = ucfirst($this->firstname);

    // Capitalize the first name
    $this->lastname = ucfirst($this->lastname);

    // Capitalize the address fields
    $this->address1 = ucfirst($this->address1);
    $this->address2 = ucfirst($this->address2);

    if (Validate::isUnsignedId($this->id_customer)) {
        Customer::resetAddressCache($this->id_customer, $this->id);
    }
    return true;
  }
}

之后重置缓存以覆盖 bij 删除 yourprojectfolder/cache/class_index.php

来源:https://www.prestashop.com/forums/topic/333935-capitalize-first-letters-of-address-input-fields-and-submit-to-database