我正在为Prestashop 1.5开发支付模块。由于没有与付款相关的订单状态,我决定在安装过程中创建一个。
我使用了官方论坛中的this主题,建议使用此
$OrderState = new OrderState();
$OrderState->name = array_fill(0,10,"Saman Bank Payment accepted");
$OrderState->template = array_fill(0,10,"SB24");
$OrderState->send_email = 1;
$OrderState->invoice = 1;
$OrderState->color = "#f8dbec";
$OrderState->unremovable = false;
$OrderState->logable = 0;
$OrderState->add();
所以现在createOrderState看起来像这样
private function createOrderState($db_name, $name)
{
if (!Configuration::get($db_name))//if status does not exist
{
$orderState = new OrderState();
$orderState->name = array_fill(0,10,$name);
$orderState->send_email = false;
$orderState->color = 'royalblue';
$orderState->hidden = false;
$orderState->delivery = false;
$orderState->logable = false;
$orderState->invoice = false;
if ($orderState->add())//save new order status
{
Configuration::updateValue($db_name, (int)$orderState->id);
}
}
}
但是,当我安装模块并进入订单状态列表时,我发现插入了四个空状态(ID 14,15,16和17)以及我打算创建的状态(id 18)。
另一方面,uninstall函数包含deleteOrderState函数,就像这样
public function deleteOrderState($db_name, $name)
{
$orderState = new OrderState();
$orderState->name = array_fill(0,10,$name);
$orderState->send_email = false;
$orderState->color = 'royalblue';
$orderState->hidden = false;
$orderState->delivery = false;
$orderState->logable = false;
$orderState->invoice = false;
$order_state.delete();
}
但是,当我尝试卸载模块时,我收到以下错误消息
Fatal error: Call to undefined function delete() in D:\xampp\htdocs\prestashop\modules\example\example.php on line 114
[PrestaShop] Fatal error in module example:
Call to undefined function delete()
TL,DR;我想知道
先谢谢。
答案 0 :(得分:0)
1º - 您必须通过参数传递order_state_id
。
2º - 要访问方法,您必须使用如下:
$obj->method
而不是
$obj.method
按照我的例子:
public function deleteOrderState($id_order_state) {
$orderState = new OrderState($id_order_state);
$orderState->delete();
}
然后,要删除OrderState
,首先需要知道其ID。
稍后,就这样做:
$yourObj->deleteOrderState(59);