在Prestashop行政办公室的订单表中为承运人栏中添加颜色

问题描述 投票:0回答:1

[添加运营商列,并在表'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',它将为我带来与订单状态相同的颜色,但我想为承运人定义另一种颜色

prestashop prestashop-1.7
1个回答
0
投票

添加回叫:

...
'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>';
}
© www.soinside.com 2019 - 2024. All rights reserved.