I need to add unique downloadable digital product on each product page.
For example I am a VPN account provider and need to send custom username and password for each customer.
and need to create a page for many accounts.
for example 1 month USA account and upload many one month USA account and add to this page from download section. and each customer just able to download one of them and next customer download the next user name.
I did this but each user can download all files but I need each user able to download just one file
Can you please help me about this kind of product ?
for example is this code is according my request or not ?
http://forum.opencart.com/viewtopic.php?f=20&t=4084
Regards
That code is for options so not really what you're after, but you should add some code around the same place to do what you're after.
As you've noticed, when a customer buys a product every download file is added to their account. What you need to do is just add one unique download to their account.
Basically, after
Code: Select all
foreach ($product['download'] as $download) {
At least, that's what I would try.
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
It's in in catalog > model > checkout > order.php
You'll need to SELECT the download from the database. If you get no result, meaning it has not been ordered by anyone yet, then you can add it.
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
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']) . "'");
}
Code: Select all
$count = 1;
foreach ($product['download'] as $download) {
$downloadfile = $this->db->escape($download['filename']);
$downloadquery = $this->db->query("SELECT filename FROM `" . DB_PREFIX . "order_download` WHERE filename = '" . $downloadfile . "'");
$downloadfilename = $downloadquery->row['filename'];
if (($downloadfilename == '') && ($count == 1)) {
$count = 2;
$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']) . "'");
}
}
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
One of my friends test it and got this error
I have tested the code with version 1.4.91 and this is the error:
Notice: Undefined index: filename in
D:\AppServ\www\opencart1491\catalog\model\checkout\order.php on line 94Notice:
Undefined index: filename in
D:\AppServ\www\opencart1491\catalog\model\checkout\order.php on line 94Notice:
Undefined index: filename in
D:\AppServ\www\opencart1491\catalog\model\checkout\order.php on line 94
It seems to be for a version easier than 1.4.9.1
Anyway thank you very much for your help
It is the solution you need, it's just my coding obviously leaves a bit to be desired.
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
Users browsing this forum: No registered users and 3 guests