Page 1 of 1

[MOD] - How to display downloads when using Free Checkout

Posted: Sun Jul 10, 2011 12:37 am
by michelk
I wanted to display downloads when they were bought with the Free Checkout payment option and that option was set to Complete.

I modified catalog\model\account\download.php

Code: Select all

	public function getDownload($order_download_id) {
	
	   $q="SELECT * FROM " . DB_PREFIX . "order_download od LEFT JOIN `" . 
        DB_PREFIX . "order` o ON (od.order_id = o.order_id) WHERE o.customer_id = '" . 
        (int)$this->customer->getId(). 
        "' AND o.order_status_id > '0'  AND (o.order_status_id = '" . 
        (int)$this->config->get('config_download_status') . 
        "'  OR  o.payment_method = 'Free Checkout')  AND od.order_download_id = '" . 
        (int)$order_download_id . "' AND od.remaining > 0";
 	 
		$query = $this->db->query($q);
		 
		return $query->row;
	}

Code: Select all

	public function getDownloads($start = 0, $limit = 20) {
		if ($start < 0) {
			$start = 0;
		}
 
        $q="SELECT o.order_id, o.date_added, od.order_download_id, od.name, od.filename, od.remaining FROM " . 
            DB_PREFIX . "order_download od LEFT JOIN `" . 
            DB_PREFIX . "order` o ON (od.order_id = o.order_id) WHERE o.customer_id = '" . 
            (int)$this->customer->getId() . 
            "' AND o.order_status_id > '0' ".
            " AND (o.order_status_id = '" . 
            (int)$this->config->get('config_download_status') . 
            "' OR  o.payment_method = 'Free Checkout') ".
            "ORDER BY o.date_added DESC LIMIT " . 
            (int)$start . "," . (int)$limit;
 
        $query = $this->db->query($q); 		 
		//$query = $this->db->query("SELECT o.order_id, o.date_added, od.order_download_id, od.name, od.filename, od.remaining FROM " . DB_PREFIX . "order_download od LEFT JOIN `" . DB_PREFIX . "order` o ON (od.order_id = o.order_id) WHERE o.customer_id = '" . (int)$this->customer->getId() . "' AND o.order_status_id > '0' AND o.order_status_id = '" . (int)$this->config->get('config_download_status') . "' ORDER BY o.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);     
 
		return $query->rows;
	}
May be there is a better way... I didn't find.

Re: [MOD] - How to display downloads when using Free Checkou

Posted: Mon Jul 11, 2011 1:50 am
by lair12
It should work without any mods. If you see my site www.ariososheetmusic.com and go to the bottom of the quartet music, there is a free test download. No mod needed as the download is available after you go through free checkout.

Re: [MOD] - How to display downloads when using Free Checkou

Posted: Mon Jul 11, 2011 2:16 am
by Qphoria
Yea, the free checkout is the same as any other checkout. When the order completes, the order status is updated to the status id you set. In this case, you'd set the free checkout to COMPLETE and when they checked out, they would see the download in their download page.

Not really sure what the point of this mod is. It is unnecessary.

You may want to do to get rid of complete downloads.

Posted: Mon Jul 11, 2011 9:58 am
by lair12
I made this language change to get completed downloads to no longer show once they are done.

http://forum.opencart.com/viewtopic.php ... 51#p170856