Show pruduct and variant files

  • Posts: 79
  • Thank you received: 3
9 years 3 weeks ago #219431

-- HikaShop version -- : Business: 2.6.0
-- Joomla version -- : 3.2.3
-- PHP version -- : 5.3.3

Hello, I write this entry because I found a problematic behavior when show product and variant files.

Some days ago, I had a problem to show product files in my site, this problem is solved (see this entry for more information ), but I think the behavior of "show" and "show_block_product_files views are a little strange.

Let see, when you have diferent files in main product, and in variants, only variant files are shown.
If you have one common file for every variant (for example a book table of contents) and diferent files for variants (for example ebook file in differents formats). I think the logical behavior is "I assign common file to main product and different ones to each variant". FAIL, this results in you only can see diferent ones assigned to each variant. You must assign all files to each variant, and if you have many common files and many variants this is a very tedious task.

The solution is to do a little change in "show" and "show_block_product_files views:
in both views, change

if(!empty ($variant->files)) {
	$skip = true;
	foreach ($variant->files as $file) {
		if ($file->file_free_download)
			$skip = false;
	}
With next code:
if(!empty ($variant->files) || !empty ($this->element->main->files));
{
	$skip = true;
	foreach ($this->element->main->files as $mainfile){
		if ($mainfile->file_free_download)
			$skip = false;
	}
	foreach ($variant->files as $file) {
		if ($file->file_free_download)
			$skip = false;
	}
And a few lines down, you must duplicate the loop:
foreach ($variant->files as $file)
In next manner:
foreach ($this->element->main->files as $mainfile) {
	if(empty ($mainfile->file_name)) {
		$mainfile->file_name = $mainfile->file_path;
	}
	$fileHtml = '';
	if(!empty ($mainfile->file_free_download)) {
		$fileHtml = '<a class="hikashop_product_file_link" href="' . hikashop_completeLink('product&task=download&file_id=' . $mainfile->file_id) . '">' . $mainfile->file_name . '</a><br/>';
	}
	$html[] = $fileHtml;
}
foreach ($variant->files as $file) {
...

I hope it has been useful to you.

Regards

Last edit: 9 years 3 weeks ago by pljuarez.
The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

Time to create page: 0.052 seconds
Powered by Kunena Forum