File download when using attachserial and 1 product generates multiple serials

  • Posts: 128
  • Thank you received: 2
7 years 9 months ago #260473

-- HikaShop version -- : 2.6.4
-- HikaSerial version -- : 1.10.4
-- Joomla version -- : 3.6.5
-- PHP version -- : 5.6

Hi there,

I was able to configure the attach serial plugin for products that generated 1 serial. So the e-ticket image is attached to the order confirmation email fine and the link for file download also generates the e-ticket on the fly OK.

Now I'm having problems configuring the same for products that generate 2 serials from the same pack. So, the product quantity is 1 but the serials quantity is 2. The attach serial plugin is attaching the email attachments fine, so I get 2 e-ticket images attached to the order email but the download links always show the e-ticket for the same serial, this is the problem.

So on the product configuration I created 2 file download items, both pointing to the same attach serial instance, that is #hikaserial:attachserial:2 - where 2 is the ID of the attach serial plugin instance. The customer receives two download links with the product he purchased, but both links download the e-ticket for the first serial generated for the purchased product.

How can I make the second link open the e-ticket for the second serial generated for the product?

Many thanks!

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 9 months ago #260497

Hi,

Thank you for your report.

There is an issue with the multiple serial and the download.
The system can manage when there are several files to download in the way that the customer bought more than one item.
But there is no parameter to handle the "position" of the serial you want to download when the pack link is more than one.

I was trying to implement a patch but I have a little issue with both information ; because I can't know how many files a product have or how many serials a product have.
So I have to investigate more on that point and maybe some modification in HikaShop would be required.

Right now I can propose you a small patch but I know that it will not work if the user have several items.
If, just after the content :

	if(substr($params, 0, 1) == ':')
		$params = substr($params, 1);
You add
	$serial_position = 1;
	if(strpos($params, ':') !== false) {
		list($params, $serial_position) = explode(':', $params, 2);
		$serial_position = (int)$serial_position;
	}
You will be able to add a "position" in the attach serial virtual file ( #attachserial:1:1 / #attachserial:1:2 / ...)
So it means that you'll have to create several virtual files depending the pack link.

Then you have a line which load the first serial
$serial = reset($serials);
and then, there is the support of the "file_pos", which is handle by HikaShop to indicate which file is downloaded (when the item quantity is more than 1).
You can add
$file->file_pos = !empty($file->file_pos) ? $file->file_pos : $serial_position;
so it will handle partially the serial position.

I hope that I will be able to fix that issue without modifying the HikaShop core (to get more details of the files and the items).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 128
  • Thank you received: 2
7 years 9 months ago #260524

Hi Jerome,

Thanks for that.

I tested your proposed patch and unfortunately I keep getting the same serial for the two virtual files. Even in orders where the user just bought one item with two serials.

I trust you will be able to come up with a good solution, I'll wait for your news.

Thanks!

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 9 months ago #260525

Hi,

Probably because the file_pos is set to 1 by HikaShop.

$file->file_pos = max($file->file_pos, $serial_position);

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 128
  • Thank you received: 2
7 years 9 months ago #260568

Thanks Jerome, that works in the front end.

However if trying to download the file from the backend it happens as follows:
- from the vendor suborder I get "file not found"
- from the Hikashop parent order I get the same serial for both file downloads.

Thanks!

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 9 months ago #260589

Hi,

1 - It is normal yes.
You can't download from the vendor suborder from the backend because the suborder does not have any serial, only the main order have it and the support for that specific download is not implemented (because there is no real use).

2 - Okay.
As I wrote, it was a fast and untested patch ; I still need to perform a more deep investigation for that case and maybe some modifications in the HikaShop core would be required.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 128
  • Thank you received: 2
7 years 9 months ago #260616

OK, thanks!

I'll wait for your news about a permanent solution.

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

Moderators: Obsidev
Time to create page: 0.066 seconds
Powered by Kunena Forum