在 Prestashop 行政办公室向载体列添加颜色以订购 table
Add color to carrier column to order table in Prestashop administrative office
添加运营商列,并向 table 'ps_carrier_lang' 添加一个名为 'color' 的列,如状态中所示,我希望显示该颜色。
'carrierdelay' => array(
'title' => $this->l('Envio'),
'type' => 'text',
'align' => 'text-center',
'class' => 'fixed-width-xl',
'color' => 'color',
'filter_key' => 'carrier_lang!delay',
'filter_type' => 'text',
'order_key' => 'carrier_lang!delay'
),
如果我输入 'color' => 'color',它会给我带来相同颜色的订单状态,但我想为承运人定义另一种颜色
添加回调:
...
'carrierdelay' => array(
'title' => $this->l('Envio'),
'type' => 'text',
'align' => 'text-center',
'class' => 'fixed-width-xl',
'color' => 'color',
'filter_key' => 'carrier_lang!delay',
'filter_type' => 'text',
'order_key' => 'carrier_lang!delay'
'callback' => 'colorCarrier'
),
...
function colorCarrier($value, $object) {
if ($object['carrierdelay'] > 3) { // Do the compare that you need, and set desired colors
$backgroundColor = '#4169E1';
$color = 'white';
}
// Return span with color and string
return '<span class="label color_field" style="background-color:'.$backgroundColor.';color:'.$white.'">'.$this->l("Delayed").'</span>';
}
添加运营商列,并向 table 'ps_carrier_lang' 添加一个名为 'color' 的列,如状态中所示,我希望显示该颜色。
'carrierdelay' => array(
'title' => $this->l('Envio'),
'type' => 'text',
'align' => 'text-center',
'class' => 'fixed-width-xl',
'color' => 'color',
'filter_key' => 'carrier_lang!delay',
'filter_type' => 'text',
'order_key' => 'carrier_lang!delay'
),
如果我输入 'color' => 'color',它会给我带来相同颜色的订单状态,但我想为承运人定义另一种颜色
添加回调:
...
'carrierdelay' => array(
'title' => $this->l('Envio'),
'type' => 'text',
'align' => 'text-center',
'class' => 'fixed-width-xl',
'color' => 'color',
'filter_key' => 'carrier_lang!delay',
'filter_type' => 'text',
'order_key' => 'carrier_lang!delay'
'callback' => 'colorCarrier'
),
...
function colorCarrier($value, $object) {
if ($object['carrierdelay'] > 3) { // Do the compare that you need, and set desired colors
$backgroundColor = '#4169E1';
$color = 'white';
}
// Return span with color and string
return '<span class="label color_field" style="background-color:'.$backgroundColor.';color:'.$white.'">'.$this->l("Delayed").'</span>';
}