/** This function starts download*/ function downStart() { $comquick2cartHelper = new comquick2cartHelper(); $Quick2cartControllerProduct = new Quick2cartControllerProduct(); $productHelper = new productHelper(); global $mainframe; $mainframe = JFactory::getApplication(); $myDonloadItemid = $comquick2cartHelper->getitemid('index.php?option=com_quick2cart&view=downloads'); $jinput = JFactory::getApplication()->input; $file_id = $jinput->get('fid', 0, 'INTEGER'); $strorecall = $jinput->get('strorecall', 0, 'INTEGER'); $guest_email = $jinput->get('guest_email', '', 'RAW'); $orderid = $jinput->get('orderid', 0, 'INTEGER'); $order_item_id = $jinput->get('order_item_id', 0, 'INTEGER'); $authorize = $productHelper->mediaFileAuthorise($file_id, $strorecall, $guest_email, $order_item_id); if (!empty($authorize['validDownload']) && $authorize['validDownload'] == 1) { $productHelper = new productHelper(); $filepath = $productHelper->getFilePathToDownload($file_id); // Download will start $down_status = $productHelper->download($filepath, '', '', 0); if ($down_status === 2) { // If filepath not exists The requested download file does not exists JFactory::getApplication()->enqueueMessage(JText::_('QTC_DOWNLOAD_FILEPATH_NOTEXISTS'), 'error'); $mainframe->redirect(JUri::root() . substr(JRoute::_('index.php?option=com_quick2cart&view=downloads&Itemid=' . $myDonloadItemid), strlen(JUri::base(true)) + 1)); } elseif (!empty($authorize['orderItemFileId'])) { // YOU WILL GET FOR THIS FIELD ONLY FOR PURCHASE REQUIRED FILE $productHelper->updateFileDownloadCount($authorize['orderItemFileId']); // kart_orderItemFiles tables primary key } // Exit tab return; } else { JFactory::getApplication()->enqueueMessage(JText::_('QTC_DOWNLOAD_NOT_AUTHORIZED'), 'error'); $mainframe->redirect(JUri::root() . substr(JRoute::_('index.php?option=com_quick2cart&view=downloads&Itemid=' . $myDonloadItemid), strlen(JUri::base(true)) + 1)); } JFactory::getApplication()->enqueueMessage(JText::_('SOME_ERROR_OCCURRED'), 'error'); $mainframe->redirect(JUri::root() . substr(JRoute::_('index.php?option=com_quick2cart&view=downloads&Itemid=' . $myDonloadItemid), strlen(JUri::base(true)) + 1)); }