Page 1 of 1

How to setting up a free download files

Posted: Sat May 19, 2018 5:56 am
by SusieRucy
Hello,
I have been struggling with this subject How can I add a free download files for register user in my opencast 3.0.2 I have set up the one that they have to pay for with now problem but couldn't set up the free one.

Re: How to setting up a free download files

Posted: Sat May 19, 2018 10:08 pm
by Johnathan
You should be able to do it by making the product price $0.00, and enabling your Free Checkout payment method in Extensions > Payments. Customers can then add the $0.00 product that has the download attached, go through checkout (choosing "Free Checkout", which only shows up if the cart total is $0.00) and the download will be in their account after they complete their order.

Re: How to setting up a free download files

Posted: Sun May 20, 2018 4:55 am
by SusieRucy
Thank you for your fast replay and help. I did every thing you told me to do but i don't get the file please see the attached screens. Is there anything I am doing incorrect?

Re: How to setting up a free download files

Posted: Sun May 20, 2018 10:01 am
by sw!tch
If you look at the model for download.php.

https://github.com/opencart/opencart/bl ... hp#L21-L45

Code: Select all

$order_statuses = $this->config->get('config_complete_status');
^ Note this line.

In other words, its looking to only show downloads when a order status is "complete".

Check your payment module settings and see if the order status is set to the complete status you have set in the store settings. If it's not then they most likely won't show up.

Might be the issue or might not.

Re: How to setting up a free download files

Posted: Sun May 20, 2018 6:06 pm
by SusieRucy
sw!tch wrote:
Sun May 20, 2018 10:01 am
If you look at the model for download.php.

https://github.com/opencart/opencart/bl ... hp#L21-L45

Code: Select all

$order_statuses = $this->config->get('config_complete_status');
^ Note this line.

In other words, its looking to only show downloads when a order status is "complete".

Check your payment module settings and see if the order status is set to the complete status you have set in the store settings. If it's not then they most likely won't show up.

Might be the issue or might not.
Thanks a lot for your help and I did find it set to canceled and I have changed it to complete like you recommended but I keep getting nothing. :(

and this is my code in the download.php

Code: Select all

<?php
class ModelAccountDownload extends Model {
	public function getDownload($download_id) {
		$implode = array();

		$order_statuses = $this->config->get('config_complete_status');

		foreach ($order_statuses as $order_status_id) {
			$implode[] = "o.order_status_id = '" . (int)$order_status_id . "'";
		}

		if ($implode) {
			$query = $this->db->query("SELECT d.filename, d.mask FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) LEFT JOIN " . DB_PREFIX . "product_to_download p2d ON (op.product_id = p2d.product_id) LEFT JOIN " . DB_PREFIX . "download d ON (p2d.download_id = d.download_id) WHERE o.customer_id = '" . (int)$this->customer->getId() . "' AND (" . implode(" OR ", $implode) . ") AND d.download_id = '" . (int)$download_id . "'");

			return $query->row;
		} else {
			return;
		}
	}

	public function getDownloads($start = 0, $limit = 20) {
		if ($start < 0) {
			$start = 0;
		}

		if ($limit < 1) {
			$limit = 20;
		}

		$implode = array();

		$order_statuses = $this->config->get('config_complete_status');

		foreach ($order_statuses as $order_status_id) {
			$implode[] = "o.order_status_id = '" . (int)$order_status_id . "'";
		}

		if ($implode) {
			$query = $this->db->query("SELECT DISTINCT d.download_id, o.order_id, o.date_added, dd.name, d.filename FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) LEFT JOIN " . DB_PREFIX . "product_to_download p2d ON (op.product_id = p2d.product_id) LEFT JOIN " . DB_PREFIX . "download d ON (p2d.download_id = d.download_id) LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id) WHERE o.customer_id = '" . (int)$this->customer->getId() . "' AND dd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND (" . implode(" OR ", $implode) . ") ORDER BY o.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);

			return $query->rows;
		} else {
			return array();
		}
	}

	public function getTotalDownloads() {
		$implode = array();

		$order_statuses = $this->config->get('config_complete_status');

		foreach ($order_statuses as $order_status_id) {
			$implode[] = "o.order_status_id = '" . (int)$order_status_id . "'";
		}

		if ($implode) {
			$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) LEFT JOIN " . DB_PREFIX . "product_to_download p2d ON (op.product_id = p2d.product_id) WHERE o.customer_id = '" . (int)$this->customer->getId() . "' AND (" . implode(" OR ", $implode) . ")");

			return $query->row['total'];
		} else {
			return 0;
		}
	}
}

Re: How to setting up a free download files

Posted: Mon May 21, 2018 12:58 am
by sw!tch
The only thing I can suggest is going to one of your free orders and add an order history of complete. Then login to the account and see if the download shows.

If you updated the payment module to a complete status, that won't actually do anything to existing orders. You would need to run through with another test order.

Re: How to setting up a free download files

Posted: Mon May 21, 2018 3:20 am
by cyclops12
This is the settings i have in a test 3.0.2.0 version with a test download file...

And this works fine

Hope it helps

Re: How to setting up a free download files

Posted: Mon May 21, 2018 5:45 pm
by SusieRucy
cyclops12 wrote:
Mon May 21, 2018 3:20 am
This is the settings i have in a test 3.0.2.0 version with a test download file...

And this works fine

Hope it helps
HI cyclops12, Thanks for your feedback and help. I tried that but nothing changed :-[ I don't know what to do.

Re: How to setting up a free download files

Posted: Mon May 21, 2018 6:32 pm
by SusieRucy
sw!tch wrote:
Mon May 21, 2018 12:58 am
The only thing I can suggest is going to one of your free orders and add an order history of complete. Then login to the account and see if the download shows.

If you updated the payment module to a complete status, that won't actually do anything to existing orders. You would need to run through with another test order.
Hi sw!tch it did work thanks for you support . But this is not going to solve the problem going to the admin page and adding free download.

Re: How to setting up a free download files

Posted: Tue May 22, 2018 11:11 pm
by SusieRucy
Any more help and suggestions anyone please

Re: How to setting up a free download files

Posted: Wed May 23, 2018 1:23 am
by sw!tch
SusieRucy wrote:
Tue May 22, 2018 11:11 pm
Any more help and suggestions anyone please
As I posted above - as long as you properly link a download (like @cyclops12 has shown ) and set your payment module to a complete status, it should work fine. Thats what the code says, so something on your end isn't setup correct.

Edit:

Looking at the code for the free checkout module it looks like it has some bugs on the variables, so this may be your problem.

catalog....free_checkout.php

Code: Select all

$this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('payment_free_checkout_order_status_id'));
payment_free_checkout_order_status_id is not actually being saved to the DB so its just reverting back to the unset status.

Apparently there is already a fix for this, you may want to try below.

viewtopic.php?t=192113

Re: How to setting up a free download files

Posted: Sat May 26, 2018 1:00 am
by S.M.T.F
hello everyone
i have also this problem , i enable the free checkout module and it works on website but the download file don't go to download page of user.

i checked my module and understand when i setting the status of that to "Complete" and save it , it doesn't set on complete and again it back to "canceled "

many times i change the status to "Complete" and save it but when i check it again it going back to "canceled"

Can some help me about this ?

Re: How to setting up a free download files

Posted: Sat May 26, 2018 1:09 am
by sw!tch
S.M.T.F wrote:
Sat May 26, 2018 1:00 am
hello everyone
i have also this problem , i enable the free checkout module and it works on website but the download file don't go to download page of user.

i checked my module and understand when i setting the status of that to "Complete" and save it , it doesn't set on complete and again it back to "canceled "

many times i change the status to "Complete" and save it but when i check it again it going back to "canceled"

Can some help me about this ?
Did you read what I posted above?

Apparently there is already a fix for this, you may want to try below.

viewtopic.php?t=192113

Re: How to setting up a free download files

Posted: Sat May 26, 2018 1:43 am
by S.M.T.F
sw!tch wrote:
Sat May 26, 2018 1:09 am
S.M.T.F wrote:
Sat May 26, 2018 1:00 am
hello everyone
i have also this problem , i enable the free checkout module and it works on website but the download file don't go to download page of user.

i checked my module and understand when i setting the status of that to "Complete" and save it , it doesn't set on complete and again it back to "canceled "

many times i change the status to "Complete" and save it but when i check it again it going back to "canceled"

Can some help me about this ?
Did you read what I posted above?

Apparently there is already a fix for this, you may want to try below.

viewtopic.php?t=192113
yeah i said there i can't understand what i must to do exactly in second action
i did the first edits in first post on topic but still not working .
but unfortunately i can't understand second action they said there.

Re: How to setting up a free download files

Posted: Sat May 26, 2018 2:09 am
by sw!tch
Just follow the instructions on the first post - viewtopic.php?f=201&t=192113#p692020

Make sure you Uninstall the free checkout payment module first.

Clear the OC cache when done.

Re: How to setting up a free download files

Posted: Sat May 26, 2018 12:06 pm
by S.M.T.F
sw!tch wrote:
Sat May 26, 2018 2:09 am
Just follow the instructions on the first post - viewtopic.php?f=201&t=192113#p692020

Make sure you Uninstall the free checkout payment module first.

Clear the OC cache when done.
Hello again
first i uninstall the free checkout and after that , i reload in the modification and also i did the clean the cache and also i open my admin page with "CTRL+F5"
after that i edit those 2 "free_checkout.php" and "free_checkout.twig" files.
and after that i install free checkout again but nothing changed :(
can you please tell what i do wrong in my steps ?
thanks

Re: How to setting up a free download files

Posted: Sat May 26, 2018 1:20 pm
by sw!tch
S.M.T.F wrote:
Sat May 26, 2018 12:06 pm
Hello again
first i uninstall the free checkout and after that , i reload in the modification and also i did the clean the cache and also i open my admin page with "CTRL+F5"
after that i edit those 2 "free_checkout.php" and "free_checkout.twig" files.
and after that i install free checkout again but nothing changed :(
can you please tell what i do wrong in my steps ?
thanks
Did you clear the cache in the dashboard? You have to click the COG icon. Are the order statutes saving in the backend under free checkout? If not you didn't do something correct.

I just tested the fix with a downloadable file and having a completed status. it works fine.

Re: How to setting up a free download files

Posted: Sat May 26, 2018 6:51 pm
by S.M.T.F
sw!tch wrote:
Sat May 26, 2018 1:20 pm
S.M.T.F wrote:
Sat May 26, 2018 12:06 pm
Hello again
first i uninstall the free checkout and after that , i reload in the modification and also i did the clean the cache and also i open my admin page with "CTRL+F5"
after that i edit those 2 "free_checkout.php" and "free_checkout.twig" files.
and after that i install free checkout again but nothing changed :(
can you please tell what i do wrong in my steps ?
thanks
Did you clear the cache in the dashboard? You have to click the COG icon. Are the order statutes saving in the backend under free checkout? If not you didn't do something correct.

I just tested the fix with a downloadable file and having a completed status. it works fine.
hello dear again
can you please tell me how can clean the cache files ?
i try many many way but still not working.
sorry to bothering you.

Re: How to setting up a free download files

Posted: Sat May 26, 2018 7:33 pm
by DigitCart
Hi,
To clear Twig cache:
In Admin panel dashboard there's a blue button with a cog icon (bellow Logout link), click on this button and then click on refresh button.

Re: How to setting up a free download files

Posted: Sat May 26, 2018 8:38 pm
by S.M.T.F
DigitCart wrote:
Sat May 26, 2018 7:33 pm
Hi,
To clear Twig cache:
In Admin panel dashboard there's a blue button with a cog icon (bellow Logout link), click on this button and then click on refresh button.
Thanks dear it solved
sorry to bothering everyone !
OC technicians are the best.