Post by p4m » Wed May 20, 2009 4:54 am

Hi,

Would it be possible to add the choice to associate a different download file to a product option?
ex: I have a pdf in french or english for download by customers,
option is language,
option values french and english
and only one download file for both option which is not possible and make the option unusuable. I have to create a new product just for a different language. One can imagine what this means if one deal with 3 or 4 options that change a bit the file....
That would be a very useful add.

Thanks

p4m
New member

Posts

Joined
Mon May 04, 2009 7:53 pm

Post by Daniel » Wed May 20, 2009 5:16 am

you don't have to create another product for each language. you can have multiple downloads for each product.

User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by eyeseesound » Thu Aug 19, 2010 6:55 pm

Hey,

what if i want different downloads DEPENDING on the option chosen.

We have music DVDs. The choices are

1) mp3s only
2) mp3 + .mov
3) DVD

with option 1) they get the mp3.zip file
with option 2) they get the mp3.zip file and mov.zip file
with option 3) they get the mp3.zip file and mov.zip file as well

At the moment it seems that i can only attach multiple downloads so even if they pick mp3 they also get the mov.zip file

Any ideas greatly appreciated as i'd rather not have to have seperate product pages for each option as it's nice them all being in one place.

New member

Posts

Joined
Tue Aug 18, 2009 4:42 am

Post by Chones » Wed Dec 15, 2010 4:26 am

I have this problem as well. I'm working on a music download store too, and obviously only want to list each track once. However, I'd like the customer to have a choice of options e.g. mp3 file or WAV file. Depending on the option they choose they get a different download.

I've played around with the admin system but don't seem to be able to do it. Anyone have any ideas?

http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by Xsecrets » Wed Dec 15, 2010 7:23 am

it is not possible with the current system. It would take quite a bit of hacking to make it work that way.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Chones » Wed Dec 15, 2010 4:24 pm

Yeah, I didn't think so. Guess it's time to get hacking. Or pray that v1.5 comes out soon ;)

http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by Chones » Thu Dec 16, 2010 3:42 am

Think I've worked out a quick way to do it:

Add both download files to the product i.e. 'Track Name mp3 version' and 'Track Name wav version'
Name the options 'mp3' and 'wav'
When customer buys the track, in the downloads section by default they currently get to download both files, no matter what option they chose.

All I have to do is only show the one that contains the string of their chosen option. E.g. if they chose 'mp3', only show 'Track Name mp3 version' for download.

This seems a lot easier than adding files to each option, which I thought I was going to have to do.

Right... now I just have to code it! Will post when I'm done.

http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by Chones » Thu Dec 16, 2010 5:31 am

Okay, think I've made it work, but will have to do more testing. Basically I'm only adding a download to the order database if the name of the download contains the option. If anyone has any better ideas please let me know. And please excuse the code - I'm more of a designer than a programmer.

Basically, in catalog > model > checkout > order.php find this:

Code: Select all

foreach ($product['download'] as $download) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "order_download SET order_id = '" . (int)$order_id . "', order_product_id = '" . (int)$order_product_id . "', name = '" . $this->db->escape($download['name']) . "', filename = '" . $this->db->escape($download['filename']) . "', mask = '" . $this->db->escape($download['mask']) . "', remaining = '" . (int)($download['remaining'] * $product['quantity']) . "'");
			}
Replace it with the following, which just checks if the name of the download contains the option.

Code: Select all

foreach ($product['download'] as $download) {

$valuequery = $this->db->query("SELECT value FROM `" . DB_PREFIX . "order_option` WHERE order_product_id = '" . (int)$order_product_id . "'");
$optionvalue = $valuequery->row['value'];
$downloadname = $this->db->escape($download['name']);
if (strstr($downloadname, $optionvalue)) {

				$this->db->query("INSERT INTO " . DB_PREFIX . "order_download SET order_id = '" . (int)$order_id . "', order_product_id = '" . (int)$order_product_id . "', name = '" . $this->db->escape($download['name']) . "', filename = '" . $this->db->escape($download['filename']) . "', mask = '" . $this->db->escape($download['mask']) . "', remaining = '" . (int)($download['remaining'] * $product['quantity']) . "'");
				}
			}
Hope that makes sense and isn't too badly coded! :-\

http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by Photospirit » Sun Feb 06, 2011 9:09 pm

Hi,

I've used your code, but the result is still the same. I'm having a picture to download in different sizes (L, XL, S, etc.).
I've added the sizes (L, XL, ...) as option and named the picture to download card1_L / card1_XL / etc.

When I now choose L from the option, I still get both products for download.

What have I done wrong? Any idea?
I'm using OC 1.4.9.3

Many thanks, Chris

New member

Posts

Joined
Sat Oct 23, 2010 8:16 pm

Post by Chones » Sun Feb 06, 2011 9:54 pm

Well, both of those options have L in them, so when it looks to see if the name contains L it will add both L and XL to the downloads.

Test it to see if it does the same thing when you buy XL. If that works then it's purely down to the naming of your options. You're going to have to think of a different way to differentiate them that doesn't use the same string, or same letter.

As I said, it's not a perfect solution I'm afraid.

http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by Photospirit » Sun Feb 06, 2011 10:19 pm

well sometimes things are so easy :-) Now as you mention it, it's obvoius that it was not working with my settings. I've changed it and now it works perfectly....many thanks for your help.

Cheers, Chris

New member

Posts

Joined
Sat Oct 23, 2010 8:16 pm

Post by webbutvecklarna » Wed Oct 05, 2011 8:19 pm

I know it's a little late but I don't think it's secure enough. strstr finds the first occurrence. So if the name of the downloaded file contains the letter L for large it will add the downloadable file.

Try this instead. It splits the name by underscore and takes the last letter/word for matching. For example.
Options: Small, Medium Large
Downloadable files: image_001_small, image_001_medium, image_001_large

Code: Select all

foreach ($product['download'] as $download) {
				$valuequery = $this->db->query("SELECT value FROM `" . DB_PREFIX . "order_option` WHERE order_product_id = '" . (int)$order_product_id . "'");
				$optionvalue = $valuequery->row['value'];
				$downloadname = $this->db->escape($download['name']);
				$tmp = split('_', $downloadname);
				$size = count($tmp);
				
				if (strtolower($optionvalue) == strtolower($tmp[$size - 1])) {
					$this->db->query("INSERT INTO " . DB_PREFIX . "order_download SET order_id = '" . (int)$order_id . "', order_product_id = '" . (int)$order_product_id . "', name = '" . $this->db->escape($download['name']) . "', filename = '" . $this->db->escape($download['filename']) . "', mask = '" . $this->db->escape($download['mask']) . "', remaining = '" . (int)($download['remaining'] * $product['quantity']) . "'");
				}
			}


Posts

Joined
Thu Sep 08, 2011 4:11 pm

Post by animani » Tue Jan 24, 2012 3:45 pm

I don't know if I might come in handy but I think the problem having several downloads when just one selected is due to the confusion of product downloads tab (auto-free download with every purchase) and options tab (free or with price downloads non automatic). If you create download options make sure you don't get confused by the first download section you find in products... The created options appear in any product options tab and has to be recalled by typing the first letter of the option download name in order to add them.

Hope someone find that useful.

Newbie

Posts

Joined
Sat Aug 28, 2010 1:28 am
Who is online

Users browsing this forum: Majestic-12 [Bot] and 77 guests