PrestasShop 1.6设置自定义订单状态


PrestasShop 1.6 Set custom order status

我在CMS中创建了自定义订单状态,如"Send to approval",我想在myypaymentmodule中创建的订单中设置此状态。我可以在CMS中看到ID,但如何在模块中获得这个ID ?

$mypaymentmodule->validateOrder($id_cart, [ID OF STATUS] , $total, $mypaymentmodule->displayName);
$order = new Order(intval($mypaymentmodule->currentOrder));

如果您从后台手动创建状态,它只存储在order_state表中,要获取模块中的所有状态,您可以使用:

$order_states = OrderState::getOrderStates($this->context->language->id);
foreach ($order_states as $state) {
    if($state['name'] == 'Send to approval')
        $status_id = $state['id_order_state'];
}
echo $status_id;

但是这样做不是一个好主意,最好以编程方式创建订单状态并存储它,例如在配置中,然后只使用Configuration::get('CUSTOM_STATE_NAME')