Hi,
I can see that you didn't enter any name for the files in your first screenshot, so it's normal that the code of Xavier doesn't do anything.
Instead, use that code:
<?php
$product_id = hikashop_getCID('product_id');
$database = JFactory::getDBO();
if(!empty($product_id)) {
$query = 'SELECT * FROM '.hikashop_table('file').' WHERE file_ref_id = '.$product_id.' AND file_type=\'file\' ORDER BY file_path ASC, file_ordering ASC, file_id ASC';
$database->setQuery($query);
$this->element->files = $database->loadObjectList('file_id');
if(!empty($this->element->files)){
$query = 'SELECT SUM(download_number) AS download_number,file_id FROM '.hikashop_table('download').' WHERE file_id IN ( '.implode(',',array_keys($this->element->files)).' ) GROUP BY file_id';
$database->setQuery($query);
$downloads = $database->loadObjectList('file_id');
if(!empty($downloads)){
foreach($downloads as $download){
$this->element->files[$download->file_id]->download_number = $download->download_number;
}
}
}
}
?>
That will order the files instead on the filename of the files on the backend.
For the customer emails, you need to change the line:
$query = 'SELECT a.* FROM '.hikashop_table('file').' AS a WHERE '.implode(' AND ',$filters).' ORDER BY file_ref_id ASC, file_ordering ASC';
to:
$query = 'SELECT a.* FROM '.hikashop_table('file').' AS a WHERE '.implode(' AND ',$filters).' ORDER BY file_ref_id ASC, file_path ASC, file_ordering ASC';
in the file administrator/components/com_hikashop/classes/order.php