Post by SusieRucy » Sat May 19, 2018 5:56 am

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.

Newbie

Posts

Joined
Sun Apr 29, 2018 10:05 pm

Post by Johnathan » Sat May 19, 2018 10:08 pm

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.

Image
Image Image Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by SusieRucy » Sun May 20, 2018 4:55 am

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?

Attachments

4.JPG

4.JPG (15.48 KiB) Viewed 1112 times

3.JPG

3.JPG (38.22 KiB) Viewed 1112 times

2.JPG

2.JPG (59 KiB) Viewed 1112 times


Newbie

Posts

Joined
Sun Apr 29, 2018 10:05 pm

Post by sw!tch » 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.

Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by SusieRucy » Sun May 20, 2018 6:06 pm

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;
		}
	}
}

Newbie

Posts

Joined
Sun Apr 29, 2018 10:05 pm

Post by sw!tch » 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.

Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by cyclops12 » 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

Attachments

free1.JPG

free1.JPG (35.04 KiB) Viewed 1003 times

freebie.JPG

freebie.JPG (35.6 KiB) Viewed 1003 times


Active Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by SusieRucy » Mon May 21, 2018 5:45 pm

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.

Newbie

Posts

Joined
Sun Apr 29, 2018 10:05 pm

Post by SusieRucy » Mon May 21, 2018 6:32 pm

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.

Newbie

Posts

Joined
Sun Apr 29, 2018 10:05 pm

Post by SusieRucy » Tue May 22, 2018 11:11 pm

Any more help and suggestions anyone please

Newbie

Posts

Joined
Sun Apr 29, 2018 10:05 pm

Post by sw!tch » Wed May 23, 2018 1:23 am

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

Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by S.M.T.F » 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 ?

Newbie

Posts

Joined
Tue Feb 06, 2018 4:20 pm

Post by sw!tch » 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

Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by S.M.T.F » Sat May 26, 2018 1:43 am

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.

Newbie

Posts

Joined
Tue Feb 06, 2018 4:20 pm

Post by sw!tch » 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.

Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by S.M.T.F » Sat May 26, 2018 12:06 pm

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

Newbie

Posts

Joined
Tue Feb 06, 2018 4:20 pm

Post by sw!tch » 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.

Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by S.M.T.F » Sat May 26, 2018 6:51 pm

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.

Newbie

Posts

Joined
Tue Feb 06, 2018 4:20 pm

Post by DigitCart » 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.

My Extensions / DigitCart


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by S.M.T.F » Sat May 26, 2018 8:38 pm

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.

Newbie

Posts

Joined
Tue Feb 06, 2018 4:20 pm
Who is online

Users browsing this forum: GameLand19 and 11 guests