如何在 prestashop 中按照我们的意愿增加订单参考长度
How to increase the order reference length as our wish in prestashop
我们想修改 prestashop 中的订单参考逻辑,为此,我们实现了逻辑。逻辑没问题。运行良好,但出现一个错误
[PrestaShopException]
Property OrderPayment->order_reference length (14) must be between 0 and 9 at line 909 in file classes/ObjectModel.php
904. }
905.
906. $message = $this->validateField($field, $this->$field);
907. if ($message !== true) {
908. if ($die) {
909. throw new PrestaShopException($message);
910. }
911. return $error_return ? $message : false;
912. }
913. }
914.
我们的长度是 30。我们怎样才能将长度从 9 增加到 30?
您需要使用此文件覆盖 class OrderPayment
/override/classes/order/OrderPayment.php
:
<?php
class OrderPayment extends OrderPaymentCore
{
public function __construct($id = null, $id_lang = null, $id_shop = null)
{
self::$definition['fields']['order_reference']['size'] = 30;
parent::__construct($id, $id_lang, $id_shop);
}
}
此外,您还必须更新数据库 order_reference phpmyadmin SQL 选项卡中的字段大小:
ALTER TABLE `ps_order_payment`
CHANGE `order_reference`
`order_reference` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
我们想修改 prestashop 中的订单参考逻辑,为此,我们实现了逻辑。逻辑没问题。运行良好,但出现一个错误
[PrestaShopException]
Property OrderPayment->order_reference length (14) must be between 0 and 9 at line 909 in file classes/ObjectModel.php
904. }
905.
906. $message = $this->validateField($field, $this->$field);
907. if ($message !== true) {
908. if ($die) {
909. throw new PrestaShopException($message);
910. }
911. return $error_return ? $message : false;
912. }
913. }
914.
我们的长度是 30。我们怎样才能将长度从 9 增加到 30?
您需要使用此文件覆盖 class OrderPayment
/override/classes/order/OrderPayment.php
:
<?php
class OrderPayment extends OrderPaymentCore
{
public function __construct($id = null, $id_lang = null, $id_shop = null)
{
self::$definition['fields']['order_reference']['size'] = 30;
parent::__construct($id, $id_lang, $id_shop);
}
}
此外,您还必须更新数据库 order_reference phpmyadmin SQL 选项卡中的字段大小:
ALTER TABLE `ps_order_payment`
CHANGE `order_reference`
`order_reference` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;