How to hide order state in BO Prestasho 1.7.7 or above

the origin post is from https://github.com/PrestaShop/PrestaShop/issues/14752

However, since the 1.7.7 version, there is some changes. Our below paragraph is for the 1.7.7 or above

Run a sql query in database client app

ALTER TABLE ps_order_state ADD hide_admin tinyint(1) unsigned NOT NULL DEFAULT '0';

 

classes/order/OrderState.php

line 28

// edited by jimmy @17Aug2022
/** @var bool Hide in BO order view */
public $hide_admin;


line 128

// edited by Jimmy @17Aug2022
public static function getOrderStates($id_lang, $hide_admin = false)
{
 
// Exclude order states for order admin
if ($hide_admin == true) {
 
$cache_id = 'OrderState::getOrderStates_hide_admin'.(int)$id_lang;
$sql_where = 'WHERE deleted = 0 AND hide_admin = 0';
 
} else {
 
$cache_id = 'OrderState::getOrderStates_'.(int)$id_lang;
$sql_where = 'WHERE deleted = 0';
 
}
 
if (!Cache::isStored($cache_id)) {
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT *
FROM `'._DB_PREFIX_.'order_state` os
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$id_lang.')
' . $sql_where . '
ORDER BY `name` ASC');
Cache::store($cache_id, $result);
return $result;
}
 
return Cache::retrieve($cache_id);
 
}
 
// public static function getOrderStates($id_lang, $filterDeleted = true)
// {
// $deletedStates = $filterDeleted ? ' WHERE deleted = 0' : '';
// $cache_id = 'OrderState::getOrderStates_' . (int) $id_lang;
// $cache_id .= $filterDeleted ? '_filterDeleted' : '';

// if (!Cache::isStored($cache_id)) {
// $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
// SELECT *
// FROM `' . _DB_PREFIX_ . 'order_state` os
// LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = ' . (int) $id_lang . ')'
// . $deletedStates . ' ORDER BY `name` ASC');
// Cache::store($cache_id, $result);

// return $result;
// }

// return Cache::retrieve($cache_id);
// }

src/Adapter/OrderState/OrderStateDataProvider.php
line 41

public function getOrderStates($languageId)
{
//edited by Jimmy @17Aug2022
return OrderState::getOrderStates($languageId, true);
}

controllers/admin/AdminStatusesController.php
line 324

[
'type' => 'checkbox',
'name' => 'logable',
'values' => [
'query' => [
['id' => 'on', 'name' => $this->trans('Consider the associated order as validated.', [], 'Admin.Shopparameters.Feature'), 'val' => '1'],
],
'id' => 'id',
'name' => 'name',
],
],
// edited by Jimmy @17Aug2022
[
'type' => 'checkbox',
'name' => 'hide_admin',
'values' => [
'query' => [
array('id' => 'on', 'name' => $this->trans('Hide on order screen', array(), 'Admin.Shopparameters.Feature'), 'val' => '1'),
],
'id' => 'id',
'name' => 'name',
],
],


line 462

'logable_on' => $this->getFieldValue($obj, 'logable'),
// edited by Jimmy @17Aug2022
'hide_admin_on' => $this->getFieldValue($obj, 'hide_admin'),

 

line 652

$_POST['logable'] = (int) Tools::getValue('logable_on');
//edited by Jimmy @17Aug2022
$_POST['hide_admin'] = (int)Tools::getValue('hide_admin_on');