OpenCart - PHP - Check if a product (download) is already purchased
Regarding OpenCart store selling digital downloads.
I am trying to add a script to the product page to warn the customer if that specific product (download) is already purchased and exists in Account>Downloads.
The reason is to avoid customers purchasing the same product twice.
Appreciate your help.
Edit:
I have tried getting the product IDs of all orders by a customer using a SQL query and that works fine externally but inside OpenCart I am facing issues.
A query such as:
SELECT product_id
FROM ocuk_order_product
WHERE order_id IN (
SELECT order_id
FROM ocuk_order
WHERE customer_id = 'xxxx'
)
My main problem is not being sure how to get similar results in OpenCart Product page. (Which pages and path exactly and where inside the files)
Tried this post as well: Opencart get product downloads
But it is not exactly working on product page (product.php)
Opencart Version 3.0.2.0
php opencart
|
show 5 more comments
Regarding OpenCart store selling digital downloads.
I am trying to add a script to the product page to warn the customer if that specific product (download) is already purchased and exists in Account>Downloads.
The reason is to avoid customers purchasing the same product twice.
Appreciate your help.
Edit:
I have tried getting the product IDs of all orders by a customer using a SQL query and that works fine externally but inside OpenCart I am facing issues.
A query such as:
SELECT product_id
FROM ocuk_order_product
WHERE order_id IN (
SELECT order_id
FROM ocuk_order
WHERE customer_id = 'xxxx'
)
My main problem is not being sure how to get similar results in OpenCart Product page. (Which pages and path exactly and where inside the files)
Tried this post as well: Opencart get product downloads
But it is not exactly working on product page (product.php)
Opencart Version 3.0.2.0
php opencart
3
Hi Matty - that's pretty broad and SO is not a code writing service. You'll need to check if they are a customer who's logged in, query their past order downloads, and present the data on the product page. I'd be happy to help if you get stuck but you at least need to demonstrate that you've made an attempt here.
– billynoah
Nov 16 '18 at 2:18
Sure. let me edit my post
– Matty
Nov 16 '18 at 2:21
Thanks - be sure to include the version you are working with.
– billynoah
Nov 16 '18 at 2:22
Please show the query you are using and explain "works fine externally / (not) inside opencart"
– billynoah
Nov 16 '18 at 2:38
A query such as "select product_id from ocuk_order_product where order_id in (select order_id from ocuk_order where customer_id = 'xxxx') " outside of OpenCart.
– Matty
Nov 16 '18 at 2:49
|
show 5 more comments
Regarding OpenCart store selling digital downloads.
I am trying to add a script to the product page to warn the customer if that specific product (download) is already purchased and exists in Account>Downloads.
The reason is to avoid customers purchasing the same product twice.
Appreciate your help.
Edit:
I have tried getting the product IDs of all orders by a customer using a SQL query and that works fine externally but inside OpenCart I am facing issues.
A query such as:
SELECT product_id
FROM ocuk_order_product
WHERE order_id IN (
SELECT order_id
FROM ocuk_order
WHERE customer_id = 'xxxx'
)
My main problem is not being sure how to get similar results in OpenCart Product page. (Which pages and path exactly and where inside the files)
Tried this post as well: Opencart get product downloads
But it is not exactly working on product page (product.php)
Opencart Version 3.0.2.0
php opencart
Regarding OpenCart store selling digital downloads.
I am trying to add a script to the product page to warn the customer if that specific product (download) is already purchased and exists in Account>Downloads.
The reason is to avoid customers purchasing the same product twice.
Appreciate your help.
Edit:
I have tried getting the product IDs of all orders by a customer using a SQL query and that works fine externally but inside OpenCart I am facing issues.
A query such as:
SELECT product_id
FROM ocuk_order_product
WHERE order_id IN (
SELECT order_id
FROM ocuk_order
WHERE customer_id = 'xxxx'
)
My main problem is not being sure how to get similar results in OpenCart Product page. (Which pages and path exactly and where inside the files)
Tried this post as well: Opencart get product downloads
But it is not exactly working on product page (product.php)
Opencart Version 3.0.2.0
php opencart
php opencart
edited Nov 16 '18 at 3:32
Matty
asked Nov 16 '18 at 2:10
MattyMatty
85
85
3
Hi Matty - that's pretty broad and SO is not a code writing service. You'll need to check if they are a customer who's logged in, query their past order downloads, and present the data on the product page. I'd be happy to help if you get stuck but you at least need to demonstrate that you've made an attempt here.
– billynoah
Nov 16 '18 at 2:18
Sure. let me edit my post
– Matty
Nov 16 '18 at 2:21
Thanks - be sure to include the version you are working with.
– billynoah
Nov 16 '18 at 2:22
Please show the query you are using and explain "works fine externally / (not) inside opencart"
– billynoah
Nov 16 '18 at 2:38
A query such as "select product_id from ocuk_order_product where order_id in (select order_id from ocuk_order where customer_id = 'xxxx') " outside of OpenCart.
– Matty
Nov 16 '18 at 2:49
|
show 5 more comments
3
Hi Matty - that's pretty broad and SO is not a code writing service. You'll need to check if they are a customer who's logged in, query their past order downloads, and present the data on the product page. I'd be happy to help if you get stuck but you at least need to demonstrate that you've made an attempt here.
– billynoah
Nov 16 '18 at 2:18
Sure. let me edit my post
– Matty
Nov 16 '18 at 2:21
Thanks - be sure to include the version you are working with.
– billynoah
Nov 16 '18 at 2:22
Please show the query you are using and explain "works fine externally / (not) inside opencart"
– billynoah
Nov 16 '18 at 2:38
A query such as "select product_id from ocuk_order_product where order_id in (select order_id from ocuk_order where customer_id = 'xxxx') " outside of OpenCart.
– Matty
Nov 16 '18 at 2:49
3
3
Hi Matty - that's pretty broad and SO is not a code writing service. You'll need to check if they are a customer who's logged in, query their past order downloads, and present the data on the product page. I'd be happy to help if you get stuck but you at least need to demonstrate that you've made an attempt here.
– billynoah
Nov 16 '18 at 2:18
Hi Matty - that's pretty broad and SO is not a code writing service. You'll need to check if they are a customer who's logged in, query their past order downloads, and present the data on the product page. I'd be happy to help if you get stuck but you at least need to demonstrate that you've made an attempt here.
– billynoah
Nov 16 '18 at 2:18
Sure. let me edit my post
– Matty
Nov 16 '18 at 2:21
Sure. let me edit my post
– Matty
Nov 16 '18 at 2:21
Thanks - be sure to include the version you are working with.
– billynoah
Nov 16 '18 at 2:22
Thanks - be sure to include the version you are working with.
– billynoah
Nov 16 '18 at 2:22
Please show the query you are using and explain "works fine externally / (not) inside opencart"
– billynoah
Nov 16 '18 at 2:38
Please show the query you are using and explain "works fine externally / (not) inside opencart"
– billynoah
Nov 16 '18 at 2:38
A query such as "select product_id from ocuk_order_product where order_id in (select order_id from ocuk_order where customer_id = 'xxxx') " outside of OpenCart.
– Matty
Nov 16 '18 at 2:49
A query such as "select product_id from ocuk_order_product where order_id in (select order_id from ocuk_order where customer_id = 'xxxx') " outside of OpenCart.
– Matty
Nov 16 '18 at 2:49
|
show 5 more comments
1 Answer
1
active
oldest
votes
Ok I'll take a stab at this but let's clarify a few things:
1) DB_PREFIX
is simply a php constant that's declared in your config.php file. Based on the query you provided it's probably equal to ocuk
. The point is, you write queries using this constant and they become portable across installations regardless of the users' chosen database prefix.
2) Opencart is based on the MCVL (an extension of MVC which includes language files) structure. The place to execute queries is in the model. The place to call model methods is in the controller. The controller passes output to the view and often uses language variables from language files.
So what I would do is write function and put it in your product model – in this case that's catalog/model/catalog/product.php
. This function is called a method since it's now part of your model class. The function will output the rows in your table that a logged in customer has purchased the given product. It's also important to check (a) that the customer is logged in and (b) that the orders you are querying against are real orders - with an order_status_id > 0. We can go into that but suffice to say that you always need to check the order_status_id if you want to know about actual completed orders. Such a method could look something like this:
public function getOrderProductHistory($product_id) {
$result = ;
if ($customer_id = $this->customer->getId()) {
$sql = "
SELECT *
FROM " . DB_PREFIX . "order o
JOIN " . DB_PREFIX . "order_product op USING (order_id)
WHERE o.order_status_id > 0
AND o.customer_id = '" . (int)$customer_id . "'
";
$query = $this->db->query($sql);
$result = $query->rows;
}
return $result;
}
Now in your controller (on a product page that's catalog/controller/product/product.php
) you can call this method to get results like this:
$order_product_history = $this->model_catalog_product->getOrderProductHistory($product_id);
And then do something based on the output:
if ($order_product_history) {
$data['has_been_ordered'] = true;
} else {
$data['has_been_ordered'] = false;
}
Now $has_been_ordered
is a boolean that you can access in your view to display a message to the customer. There's still a bit more code for you to write but hopefully this helps get you off to a good start.
This is perfect. Thank you.
– Matty
Nov 16 '18 at 4:33
@Matty - Don't forget, if this answer is helpful you can "accept" it for your question by clicking the green check. Later as you gain rep you will also be able to vote up and down.
– billynoah
Nov 16 '18 at 4:38
Sure. All good. Just one more thing: I have ended up creating this $data['has_been_ordered'] = "You have already ordered this product"; ...... Now I need to make it appear in twig. I beleive I have to add something like this {{ has_been_ordered }} but it is not showing up
– Matty
Nov 16 '18 at 4:49
never mind got it. Thank you
– Matty
Nov 16 '18 at 4:55
@Matty - I'm glad you figured that part out. Are you going to accept my answer?
– billynoah
Nov 16 '18 at 14:21
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330473%2fopencart-php-check-if-a-product-download-is-already-purchased%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Ok I'll take a stab at this but let's clarify a few things:
1) DB_PREFIX
is simply a php constant that's declared in your config.php file. Based on the query you provided it's probably equal to ocuk
. The point is, you write queries using this constant and they become portable across installations regardless of the users' chosen database prefix.
2) Opencart is based on the MCVL (an extension of MVC which includes language files) structure. The place to execute queries is in the model. The place to call model methods is in the controller. The controller passes output to the view and often uses language variables from language files.
So what I would do is write function and put it in your product model – in this case that's catalog/model/catalog/product.php
. This function is called a method since it's now part of your model class. The function will output the rows in your table that a logged in customer has purchased the given product. It's also important to check (a) that the customer is logged in and (b) that the orders you are querying against are real orders - with an order_status_id > 0. We can go into that but suffice to say that you always need to check the order_status_id if you want to know about actual completed orders. Such a method could look something like this:
public function getOrderProductHistory($product_id) {
$result = ;
if ($customer_id = $this->customer->getId()) {
$sql = "
SELECT *
FROM " . DB_PREFIX . "order o
JOIN " . DB_PREFIX . "order_product op USING (order_id)
WHERE o.order_status_id > 0
AND o.customer_id = '" . (int)$customer_id . "'
";
$query = $this->db->query($sql);
$result = $query->rows;
}
return $result;
}
Now in your controller (on a product page that's catalog/controller/product/product.php
) you can call this method to get results like this:
$order_product_history = $this->model_catalog_product->getOrderProductHistory($product_id);
And then do something based on the output:
if ($order_product_history) {
$data['has_been_ordered'] = true;
} else {
$data['has_been_ordered'] = false;
}
Now $has_been_ordered
is a boolean that you can access in your view to display a message to the customer. There's still a bit more code for you to write but hopefully this helps get you off to a good start.
This is perfect. Thank you.
– Matty
Nov 16 '18 at 4:33
@Matty - Don't forget, if this answer is helpful you can "accept" it for your question by clicking the green check. Later as you gain rep you will also be able to vote up and down.
– billynoah
Nov 16 '18 at 4:38
Sure. All good. Just one more thing: I have ended up creating this $data['has_been_ordered'] = "You have already ordered this product"; ...... Now I need to make it appear in twig. I beleive I have to add something like this {{ has_been_ordered }} but it is not showing up
– Matty
Nov 16 '18 at 4:49
never mind got it. Thank you
– Matty
Nov 16 '18 at 4:55
@Matty - I'm glad you figured that part out. Are you going to accept my answer?
– billynoah
Nov 16 '18 at 14:21
|
show 1 more comment
Ok I'll take a stab at this but let's clarify a few things:
1) DB_PREFIX
is simply a php constant that's declared in your config.php file. Based on the query you provided it's probably equal to ocuk
. The point is, you write queries using this constant and they become portable across installations regardless of the users' chosen database prefix.
2) Opencart is based on the MCVL (an extension of MVC which includes language files) structure. The place to execute queries is in the model. The place to call model methods is in the controller. The controller passes output to the view and often uses language variables from language files.
So what I would do is write function and put it in your product model – in this case that's catalog/model/catalog/product.php
. This function is called a method since it's now part of your model class. The function will output the rows in your table that a logged in customer has purchased the given product. It's also important to check (a) that the customer is logged in and (b) that the orders you are querying against are real orders - with an order_status_id > 0. We can go into that but suffice to say that you always need to check the order_status_id if you want to know about actual completed orders. Such a method could look something like this:
public function getOrderProductHistory($product_id) {
$result = ;
if ($customer_id = $this->customer->getId()) {
$sql = "
SELECT *
FROM " . DB_PREFIX . "order o
JOIN " . DB_PREFIX . "order_product op USING (order_id)
WHERE o.order_status_id > 0
AND o.customer_id = '" . (int)$customer_id . "'
";
$query = $this->db->query($sql);
$result = $query->rows;
}
return $result;
}
Now in your controller (on a product page that's catalog/controller/product/product.php
) you can call this method to get results like this:
$order_product_history = $this->model_catalog_product->getOrderProductHistory($product_id);
And then do something based on the output:
if ($order_product_history) {
$data['has_been_ordered'] = true;
} else {
$data['has_been_ordered'] = false;
}
Now $has_been_ordered
is a boolean that you can access in your view to display a message to the customer. There's still a bit more code for you to write but hopefully this helps get you off to a good start.
This is perfect. Thank you.
– Matty
Nov 16 '18 at 4:33
@Matty - Don't forget, if this answer is helpful you can "accept" it for your question by clicking the green check. Later as you gain rep you will also be able to vote up and down.
– billynoah
Nov 16 '18 at 4:38
Sure. All good. Just one more thing: I have ended up creating this $data['has_been_ordered'] = "You have already ordered this product"; ...... Now I need to make it appear in twig. I beleive I have to add something like this {{ has_been_ordered }} but it is not showing up
– Matty
Nov 16 '18 at 4:49
never mind got it. Thank you
– Matty
Nov 16 '18 at 4:55
@Matty - I'm glad you figured that part out. Are you going to accept my answer?
– billynoah
Nov 16 '18 at 14:21
|
show 1 more comment
Ok I'll take a stab at this but let's clarify a few things:
1) DB_PREFIX
is simply a php constant that's declared in your config.php file. Based on the query you provided it's probably equal to ocuk
. The point is, you write queries using this constant and they become portable across installations regardless of the users' chosen database prefix.
2) Opencart is based on the MCVL (an extension of MVC which includes language files) structure. The place to execute queries is in the model. The place to call model methods is in the controller. The controller passes output to the view and often uses language variables from language files.
So what I would do is write function and put it in your product model – in this case that's catalog/model/catalog/product.php
. This function is called a method since it's now part of your model class. The function will output the rows in your table that a logged in customer has purchased the given product. It's also important to check (a) that the customer is logged in and (b) that the orders you are querying against are real orders - with an order_status_id > 0. We can go into that but suffice to say that you always need to check the order_status_id if you want to know about actual completed orders. Such a method could look something like this:
public function getOrderProductHistory($product_id) {
$result = ;
if ($customer_id = $this->customer->getId()) {
$sql = "
SELECT *
FROM " . DB_PREFIX . "order o
JOIN " . DB_PREFIX . "order_product op USING (order_id)
WHERE o.order_status_id > 0
AND o.customer_id = '" . (int)$customer_id . "'
";
$query = $this->db->query($sql);
$result = $query->rows;
}
return $result;
}
Now in your controller (on a product page that's catalog/controller/product/product.php
) you can call this method to get results like this:
$order_product_history = $this->model_catalog_product->getOrderProductHistory($product_id);
And then do something based on the output:
if ($order_product_history) {
$data['has_been_ordered'] = true;
} else {
$data['has_been_ordered'] = false;
}
Now $has_been_ordered
is a boolean that you can access in your view to display a message to the customer. There's still a bit more code for you to write but hopefully this helps get you off to a good start.
Ok I'll take a stab at this but let's clarify a few things:
1) DB_PREFIX
is simply a php constant that's declared in your config.php file. Based on the query you provided it's probably equal to ocuk
. The point is, you write queries using this constant and they become portable across installations regardless of the users' chosen database prefix.
2) Opencart is based on the MCVL (an extension of MVC which includes language files) structure. The place to execute queries is in the model. The place to call model methods is in the controller. The controller passes output to the view and often uses language variables from language files.
So what I would do is write function and put it in your product model – in this case that's catalog/model/catalog/product.php
. This function is called a method since it's now part of your model class. The function will output the rows in your table that a logged in customer has purchased the given product. It's also important to check (a) that the customer is logged in and (b) that the orders you are querying against are real orders - with an order_status_id > 0. We can go into that but suffice to say that you always need to check the order_status_id if you want to know about actual completed orders. Such a method could look something like this:
public function getOrderProductHistory($product_id) {
$result = ;
if ($customer_id = $this->customer->getId()) {
$sql = "
SELECT *
FROM " . DB_PREFIX . "order o
JOIN " . DB_PREFIX . "order_product op USING (order_id)
WHERE o.order_status_id > 0
AND o.customer_id = '" . (int)$customer_id . "'
";
$query = $this->db->query($sql);
$result = $query->rows;
}
return $result;
}
Now in your controller (on a product page that's catalog/controller/product/product.php
) you can call this method to get results like this:
$order_product_history = $this->model_catalog_product->getOrderProductHistory($product_id);
And then do something based on the output:
if ($order_product_history) {
$data['has_been_ordered'] = true;
} else {
$data['has_been_ordered'] = false;
}
Now $has_been_ordered
is a boolean that you can access in your view to display a message to the customer. There's still a bit more code for you to write but hopefully this helps get you off to a good start.
edited Nov 16 '18 at 3:46
answered Nov 16 '18 at 3:41
billynoahbillynoah
11k64468
11k64468
This is perfect. Thank you.
– Matty
Nov 16 '18 at 4:33
@Matty - Don't forget, if this answer is helpful you can "accept" it for your question by clicking the green check. Later as you gain rep you will also be able to vote up and down.
– billynoah
Nov 16 '18 at 4:38
Sure. All good. Just one more thing: I have ended up creating this $data['has_been_ordered'] = "You have already ordered this product"; ...... Now I need to make it appear in twig. I beleive I have to add something like this {{ has_been_ordered }} but it is not showing up
– Matty
Nov 16 '18 at 4:49
never mind got it. Thank you
– Matty
Nov 16 '18 at 4:55
@Matty - I'm glad you figured that part out. Are you going to accept my answer?
– billynoah
Nov 16 '18 at 14:21
|
show 1 more comment
This is perfect. Thank you.
– Matty
Nov 16 '18 at 4:33
@Matty - Don't forget, if this answer is helpful you can "accept" it for your question by clicking the green check. Later as you gain rep you will also be able to vote up and down.
– billynoah
Nov 16 '18 at 4:38
Sure. All good. Just one more thing: I have ended up creating this $data['has_been_ordered'] = "You have already ordered this product"; ...... Now I need to make it appear in twig. I beleive I have to add something like this {{ has_been_ordered }} but it is not showing up
– Matty
Nov 16 '18 at 4:49
never mind got it. Thank you
– Matty
Nov 16 '18 at 4:55
@Matty - I'm glad you figured that part out. Are you going to accept my answer?
– billynoah
Nov 16 '18 at 14:21
This is perfect. Thank you.
– Matty
Nov 16 '18 at 4:33
This is perfect. Thank you.
– Matty
Nov 16 '18 at 4:33
@Matty - Don't forget, if this answer is helpful you can "accept" it for your question by clicking the green check. Later as you gain rep you will also be able to vote up and down.
– billynoah
Nov 16 '18 at 4:38
@Matty - Don't forget, if this answer is helpful you can "accept" it for your question by clicking the green check. Later as you gain rep you will also be able to vote up and down.
– billynoah
Nov 16 '18 at 4:38
Sure. All good. Just one more thing: I have ended up creating this $data['has_been_ordered'] = "You have already ordered this product"; ...... Now I need to make it appear in twig. I beleive I have to add something like this {{ has_been_ordered }} but it is not showing up
– Matty
Nov 16 '18 at 4:49
Sure. All good. Just one more thing: I have ended up creating this $data['has_been_ordered'] = "You have already ordered this product"; ...... Now I need to make it appear in twig. I beleive I have to add something like this {{ has_been_ordered }} but it is not showing up
– Matty
Nov 16 '18 at 4:49
never mind got it. Thank you
– Matty
Nov 16 '18 at 4:55
never mind got it. Thank you
– Matty
Nov 16 '18 at 4:55
@Matty - I'm glad you figured that part out. Are you going to accept my answer?
– billynoah
Nov 16 '18 at 14:21
@Matty - I'm glad you figured that part out. Are you going to accept my answer?
– billynoah
Nov 16 '18 at 14:21
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330473%2fopencart-php-check-if-a-product-download-is-already-purchased%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Hi Matty - that's pretty broad and SO is not a code writing service. You'll need to check if they are a customer who's logged in, query their past order downloads, and present the data on the product page. I'd be happy to help if you get stuck but you at least need to demonstrate that you've made an attempt here.
– billynoah
Nov 16 '18 at 2:18
Sure. let me edit my post
– Matty
Nov 16 '18 at 2:21
Thanks - be sure to include the version you are working with.
– billynoah
Nov 16 '18 at 2:22
Please show the query you are using and explain "works fine externally / (not) inside opencart"
– billynoah
Nov 16 '18 at 2:38
A query such as "select product_id from ocuk_order_product where order_id in (select order_id from ocuk_order where customer_id = 'xxxx') " outside of OpenCart.
– Matty
Nov 16 '18 at 2:49