Page 1 of 1

Group Downloads (listing) by ID

Posted: Sun Jul 16, 2017 4:17 am
by wamfgcom
Hope I'm in the right section for this ;)

My problem is simply one of aesthetics, I am offering digital downloads in several file formats. For each purchase customers will have the availability of six (6) different file extensions; epub, mobi, pdf etc. That mean if someone purchases 6 items their download list will consist of 36 items, which could be a bit confusing as each download "stacks" one upon the other.
What I was hoping to do would be grouping each download by "ID" in it's own separate "block" (Table).

In the account/download.tpl it currently calls for "foreach ($downloads as $download)" and then it sets out the table structure.
I'm hoping to find a way to call for each download by "ID" so that the end result would be a separate table structure for each "ID".

I comfortable creating/adjusting the table structures, just not sure how (or if it's possible) to call by ID.
Any thoughts would be appreciated :)
v 2.3.0.2

Re: Group Downloads (listing) by ID

Posted: Sun Jul 16, 2017 4:43 am
by artcore
Hi,
If bundling them in one zip won't do you could create an array from all the downloads where the keys are the product_id and the downloads an array on each product_id
Now it's a matter of looping and create a new table when a new product_id is coming up; the rows being the downloads on that key.
Hope it makes sense :)

fake code idea:
$bundles = [];
foreach downloads as download
$bundles[download['product_id'] = download;

unset downloads,download
foreach bundles as product=>downloads
<table>
foreach downloads as download
<tr>
<td>echo download['???']
<td>...

Re: Group Downloads (listing) by ID

Posted: Sun Jul 16, 2017 6:22 am
by wamfgcom
Appreciate the response

Zipping the files together isn't an option as the files are fair sized and theoretically the customer will only need one of them. The idea is of offering options for compatibility with various devices but I don't want them to have to choose prior to purchase so if there is a problem of compatibility they'd have ten days to come back and download a different version.

I believe your idea will answer my needs,
but as php isn't my native language I'm still a little lost ;(
Can anyone refine this for me?

Re: Group Downloads (listing) by ID

Posted: Sun Jul 16, 2017 3:16 pm
by artcore
I understand the need, I happen to be an ebook creator as well.
What's your oc version and what do you want to group on? product or order?

Re: Group Downloads (listing) by ID

Posted: Mon Jul 17, 2017 2:38 am
by wamfgcom
Hello and thank you for the interest in my problem,
I'm using oc v 2.3.0.2
Must admit your question had me thinking ;)
Likely "product" would be the way to go as I have the six file extensions listed under "downloads" in the product listing under the one common name.

Re: Group Downloads (listing) by ID

Posted: Mon Jul 17, 2017 4:49 am
by artcore
Yes no problem, I'll create a little ocmod tomorrow

Re: Group Downloads (listing) by ID

Posted: Mon Jul 17, 2017 5:59 am
by wamfgcom
Thrilled :o Thank you!

Re: Group Downloads (listing) by ID

Posted: Mon Jul 17, 2017 5:26 pm
by artcore
Here you go.
Not extensively tested as I don't have too many orders with downloads on my demo. Let me know if all works out.

Group Downloads
Displays a table for all downloads attached to the product(s) in an order.
Change product_id to order_id to group on orders. Find below line in the ocmod.xml to do just that

<add position="replace"><!--[CDATA[$data['downloads'][$result['product_id']][] = array(]]--></add>

Re: Group Downloads (listing) by ID

Posted: Tue Jul 18, 2017 9:43 am
by wamfgcom
Installed successfully ;) and I believe it will do the trick but I need to add some more product to test properly as well, and life calls :( will let you know how it goes soon as I can.
Thanks!

Re: Group Downloads (listing) by ID

Posted: Fri Aug 11, 2017 9:12 am
by wamfgcom
Apologies!
Just after you provided that mod and I installed it then realizing I needed more products to test it properly...
unexpected house guests knocked on the door and stayed for two weeks.

I have just now properly tested it and it works great!
With 7 download options for each product it will help to clean up the very long "downloads" list created by buying multiple products.
Many Thanks!!!

Re: Group Downloads (listing) by ID

Posted: Fri Aug 11, 2017 1:52 pm
by artcore
You're welcome wam, and thanks for the report back!
Cheers