Jump to content

How to edit admin orders list tpl


ava8c

Recommended Posts

  • 2 weeks later...
  • 5 months later...

You can create override/controllers/admin/AdminOrdersController.php and add columns to $this->fields_list. For example, if you wanted to add a "Newsletter" column, use the following code:

<?php

class AdminOrdersController extends AdminOrdersControllerCore
{
    public function __construct()
    {
        parent::__construct();

        $this->fields_list['newsletter'] = array(
            'title' => $this->l('Newsletter'),
            'filter_key' => 'c!newsletter',
            'callback' => 'displayNewsletter'
        );
    }
    
    public function displayNewsletter($value) {
        return $value ? $this->l('Yes') : $this->l('No');   
    }
}

This gets the newsletter column from the customer table, displays the translatable title "Newsletter" and then calls the displayNewsletter function to format the value to make it more readable.

  • Like 1
Link to comment
Share on other sites

Hi Rocky,

 

thanks for good editing tip. I hope I can throw another question same way - is there a way to change the color of the orer list rows according to the order status - like in older version of Prestashop? For example, if the status of the order has green color, the whole order row would be green instead of just the bubble around the status word?

I've found that {main_dir}\themes\default\template\helpers\list\list_content.tpl has something to do with it:

{foreach $list AS $index => $tr}
	<tr{if $position_identifier} id="tr_{$position_group_identifier}_{$tr.$identifier}_{if isset($tr.position['position'])}{$tr.position['position']}{else}0{/if}"{/if} class="{if isset($tr.class)}{$tr.class}{/if} {if $tr@iteration is odd by 1}odd{/if}"{if isset($tr.color) && $color_on_bg} style="background-color: {$tr.color}"{/if} >

I've changed it to:

{foreach $list AS $index => $tr}
	<tr{if $position_identifier} id="tr_{$position_group_identifier}_{$tr.$identifier}_{if isset($tr.position['position'])}{$tr.position['position']}{else}0{/if}"{/if} class="{if isset($tr.class)}{$tr.class}{/if} {if $tr@iteration is odd by 1}odd{/if}"{if isset($params.color) && isset($tr[$params.color])} style="background-color:{$tr[$params.color]};color:{if Tools::getBrightness($tr[$params.color]) < 128}white{else}#383838{/if}"{/if}

But the output of the change in this file gives empty "background-color:" property, seems that the coding does not know what $tr[$params.color] is, but it's strange because the code is used few rows after to color the status cell.

I would really appreciate the help, because this would greatly help my employees not to mix up or miss orders.

 

 

 

EDIT: I've managed to find the solution here! https://www.prestashop.com/forums/topic/214749-solved-changing-order-color-in-prestashop-15-back-office/

Edited by sting5 (see edit history)
Link to comment
Share on other sites

Sure, you can add the following to the bottom of admin/themes/default/template/helpers/list/list_content.tpl:

<script type="text/javascript">
    $('.color_field').each(function() {
       $(this).parent().parent().children('td').css('background-color', $(this).css('background-color'));
       $(this).parent().parent().children('td').css('color', getBrightness($(this).css('background-color')) < 128 ? 'white' : '#383838');
    });
    
    function getBrightness(color)
    {
        var rgb = color.substring(4, color.length-1).replace(/ /g, '').split(',');        
        return ((rgb[0] * 299) + (rgb[1] * 587) + (rgb[2] * 114)) / 1000;
    }
</script>
Link to comment
Share on other sites

  • 1 year later...

hello guys,

 

im a bit stuck.. i would to add a prefix on order reference through this file only : admin/themes/default/template/helpers/list/list_content.tpl

But damn, i cant figure out how to do because it seems very generic file pour a lot of purpose :o

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...