To create a support ticket, start a search

Grille Produits : Interval de jours depuis la dernière commande


We would like to add the field in the products grid showing the laps of time in days since the last order made for products.


To add the field to the list of available fields for your products grids, click on the add_dis.png in the 'Add a field' panel and enter the following information:

What is the field ID?: order_interval 


SC creates the field, you now need to populate the grid with:

Field name: Interval days since last order
Table: Another table
Type: Just displayed
Refresh combinations: No


From the Advanced Properties panel on the right handside:

- select the menu Select options and enter:

return ' ,(SELECT DATEDIFF(NOW(),o.date_add) FROM '._DB_PREFIX_.'orders o WHERE o.id_order IN (SELECT DISTINCT(od.id_order) FROM '._DB_PREFIX_.'order_detail od WHERE od.product_id = p.id_product) ORDER BY o.date_add DESC LIMIT 1) AS order_interval';


Adapt this code to your specific needs.

Exit the editing window.

The new field is now present in the list of available fields and you can add it to your product grids.


Related articles