Mark orders with returned products in the order list of ThirtyBees and PrestaShop

In this video for ThirtyBees and Prestashop 1.6, we will see how to add a checkmark for orders that contain returned products, so that they are easy to spot in the back office order list

Watch the screencast

Text Version

All of the modifications need to be applied to AdminOrdersController.php, located in controllers/admin
Add to $this->_select (do not forget the comma!):

od.product_quantity_return as has_returned,

Add to $this->_join:

LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order` = a.`id_order`)

Right after the join variable is set, add:

$this->_group = 'GROUP BY a.id_order';

This way we avoid duplicates in the order list.

In the next step we will add the actual column, scroll down to around line 130, and add the following to the $this->fields_list variable:

                'has_returned'            => [
                    'title'      => $this->l('Return'),
                    'align'      => 'text-center',
                    'type'       => 'bool',
                    'callback'       => 'getIsReturned',
                ],

Lastly, out of the construct method (it can be anywhere, right after it or at the end of the file) we will add the callback function:

    public function getIsReturned($a, $order)
    {
        $has_returned = Db::getInstance()->getValue('SELECT product_quantity_return FROM '._DB_PREFIX_.'order_detail WHERE id_order =' .(int)$order['id_order'] .' AND product_quantity_return > 0');

        $class = $has_returned ? 'icon-check' : 'icon-remove';
        return '<i class="'.$class.'"></i>';

    }

You like the tuts and want to say "thank you"? Well, you can always feel free to donate:

Store Top Sales

You like the tuts and want to say "thank you"? Well, you can always feel free to donate: