3 Replies - 110 Views - Last Post: 06 May 2019 - 12:40 PM Rate Topic: -----

#1 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 64
  • Joined: 04-February 19

Help with adding ‘purchased’ videos to the ‘liked’ video page

Posted 06 May 2019 - 11:14 AM

In the web video script I’m using, it has ‘like’ the video option, and then the (logged-in) User can select the liked-videos link to see which videos he liked.
I’m trying to modify the script so that instead of having ‘liked’ videos appear on the Users’ kied-video page, each time the User paid to view a video, it gets added to his liked-videos page instead, for a simple way for the User to always see what he has purchased.
So, I can remove the html ‘like’ icon from the displaying html page (to eliminate the ‘like’ option), and I’m looking for assistance with having each ‘purchased’ video added to the (users’) existing liked-video page. I looking for help with getting part of the liked-videos php file code to be added to the paid-videos php file, to accomplish that. Here is the liked-video.php code:

<?php
if (IS_LOGGED == false) {
    header("Location: " . PT_Link('login'));
    exit();
}

$list = '<div class="text-center no-content-found empty_state"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-video-off"><path d="M16 16v1a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2m5.66 0H14a2 2 0 0 1 2 2v3.34l1 1L23 7v10"></path><line x1="1" y1="1" x2="23" y2="23"></line></svg>' . $lang->no_videos_found_liked . '</div>';
$final = '';

$get = $db->where('user_id', $user->id)->where('type', 1)->orderby('id', 'DESC')->get(T_DIS_LIKES, 20);
$get_history_videos = array();
if (!empty($get)) {
    foreach ($get as $key => $video_) {
       $fetched_video = $db->where('id', $video_->video_id)->getOne(T_VIDEOS);
       $fetched_video->like_id = $video_->id;
       $get_history_videos[] = $fetched_video;
    }
}
if (!empty($get_history_videos)) {
    $len = count($get_history_videos);
    foreach ($get_history_videos as $key => $video) {
        $video = PT_GetVideoByID($video, 0, 0, 0);
        $pt->last_video = false;
        if ($key == $len - 1) {
            $pt->last_video = true;
        }
        $final .= PT_LoadPage('liked-videos/list', array(
            'ID' => $video->like_id,
            'USER_DATA' => $video->owner,
            'THUMBNAIL' => $video->thumbnail,
            'URL' => $video->url,
            'TITLE' => $video->title,
            'DESC' => $video->markup_description,
            'VIEWS' => $video->views,
            'TIME' => $video->time_ago,
            'VIDEO_ID_' => PT_Slug($video->title, $video->video_id)
        ));
    }
}
if (empty($final)) {
	$final = $list;
}
$pt->page_url_ = $pt->config->site_url.'/liked-videos';
$pt->videos      = $get_history_videos;
$pt->page        = 'liked-videos';
$pt->title       = $lang->liked_videos . ' | ' . $pt->config->title;
$pt->description = $pt->config->description;
$pt->keyword     = $pt->config->keyword;
$pt->content     = PT_LoadPage('liked-videos/content', array(
    'LIKED_LIST' => $final
));



and here is the paid-video.php code:

<?php

if (IS_LOGGED == false) {
    header("Location: " . PT_Link('login'));
    exit();
}
$user_id               = $user->id;
$pt->is_admin          = PT_IsAdmin();
$pt->is_settings_admin = false;


$list = '<div class="text-center no-content-found empty_state"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-video-off"><path d="M16 16v1a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2m5.66 0H14a2 2 0 0 1 2 2v3.34l1 1L23 7v10"></path><line x1="1" y1="1" x2="23" y2="23"></line></svg>' . $lang->no_videos_found_for_now . '</div>';
$list2 = '<div class="text-center no-content-found empty_state"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-video-off"><path d="M16 16v1a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2m5.66 0H14a2 2 0 0 1 2 2v3.34l1 1L23 7v10"></path><line x1="1" y1="1" x2="23" y2="23"></line></svg></div>';
$final = '';


$get_videos = $db->rawQuery("SELECT DISTINCT(v.id), v.* FROM u_paid_videos AS upv LEFT JOIN " . T_VIDEOS . " AS v ON (upv.id_video = v.id) WHERE upv.id_user = {$user->id} AND upv.session_key = '{$_SESSION['session_key']}' ORDER BY upv.id DESC");


if (!empty($get_videos)) {
    $len = count($get_videos);
    foreach ($get_videos as $key => $video) {
        $video = PT_GetVideoByID($video, 0, 0, 0);
        $pt->last_video = false;
        if ($key == $len - 1) {
            $pt->last_video = true;
        }
        $final .= PT_LoadPage('paid-list/list', array(
            'ID' => $video->id,
            'USER_DATA' => $video->owner,
            'THUMBNAIL' => $video->thumbnail,
            'URL' => $video->url,
            'TITLE' => $video->title,
            'DESC' => $video->markup_description,
            'VIEWS' => $video->views,
            'VIEWS_NUM' => number_format($video->views),
            'TIME' => $video->time_ago,
            'DURATION' => $video->duration
        ));
    }
}
if (empty($final)) {
	$final = $list;
}

$pt->videos      = $get_videos;
$pt->page        = 'paid-list';
$pt->title       = $lang->search . ' | ' . $pt->config->title;
$pt->description = $pt->config->description;
$pt->keyword     = $pt->config->keyword;
$pt->content     = PT_LoadPage('paid-list/content', array(
    'VIDEOS' => $final,
    'KEYWORD' => $keyword
));



any guidance with my goal will be appreciated

Is This A Good Question/Topic? 0
  • +

Replies To: Help with adding ‘purchased’ videos to the ‘liked’ video page

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14987
  • View blog
  • Posts: 59,843
  • Joined: 12-June 08

Re: Help with adding ‘purchased’ videos to the ‘liked’ video page

Posted 06 May 2019 - 11:46 AM

First up, that is most definitely _NOT_ a good idea. 'Liked' is not close to 'purchase history', and it is the wrong rabbit hole to go about making it so.

Not knowing what script this is, where it came from, or what it looks like I can only give vague hand waving gestures that I would think there would be a 'purchase history' screen (most seem to have that), and at worst a simple DB query - for a given user ID - would pull back the results.


Also seen here:
https://www.sitepoin...o-page/327053/3
Was This Post Helpful? 0
  • +
  • -

#3 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 64
  • Joined: 04-February 19

Re: Help with adding ‘purchased’ videos to the ‘liked’ video page

Posted 06 May 2019 - 12:34 PM

Thanks for your reply.

I appreciate your advice. I wasn't completely sure if that was a good idea.

So, yes the web script has a page for a Users' purchases, however, the script was modified(improved) so that purchases are made via the paid-video php file above (not the scripts original purch-vid file - below), essentially by-passing the script's paid system. So, the current Users' purchases page remains blank, although the improved script works successfully (just no User purchase page info).

So, if I can get some guidance with modifying the original file that will display the Users' purchases (instead of doing the 'liked' videos idea), it would be appreciated.

Modifying the original purch-vid file (below), where the 'get video' data comes from the 'u_paid_videos' table (instead of T_VIDEOS_TRSNS) may solve this problem):


<?php

if (IS_LOGGED == false || $pt->config->sell_videos_system == 'off' ) {
    header("Location: " . PT_Link('login'));
    exit();
}

$list = '<div class="text-center no-content-found empty_state"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-video-off"><path d="M16 16v1a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2m5.66 0H14a2 2 0 0 1 2 2v3.34l1 1L23 7v10"></path><line x1="1" y1="1" x2="23" y2="23"></line></svg>' . $lang->no_videos_found_paid . '</div>';
$final = '';
$type = 'videos';
if (!empty($_GET['type']) && $_GET['type'] == 'movies' && $pt->config->movies_videos == 'on') {
    $get = $db->rawQuery('SELECT * FROM '.T_VIDEOS_TRSNS.' t WHERE `paid_id` = '.$user->id.' AND (SELECT id FROM '.T_VIDEOS.' WHERE id = t.video_id AND `is_movie` = 1) = video_id ORDER BY id DESC LIMIT 20');
    $type = 'movies';

}
else{
    $get = $db->rawQuery('SELECT * FROM '.T_VIDEOS_TRSNS.' t WHERE `paid_id` = '.$user->id.' AND (SELECT id FROM '.T_VIDEOS.' WHERE id = t.video_id AND `is_movie` != 1) = video_id ORDER BY id DESC LIMIT 20');
   //$get = $db->where('paid_id', $user->id)->orderby('id', 'DESC')->get(T_VIDEOS_TRSNS, 20); 
}
$get_paid_videos = array();
if (!empty($get)) {
    foreach ($get as $key => $video_) {
       $fetched_video = $db->where('id', $video_->video_id)->getOne(T_VIDEOS);
       if (!empty($fetched_video)) {
           $fetched_video->tr_id = $video_->id;
           $get_paid_videos[] = $fetched_video;
       }
    }
}
if (!empty($get_paid_videos)) {
    $len = count($get_paid_videos);
    foreach ($get_paid_videos as $key => $video) {
        $video = PT_GetVideoByID($video, 0, 0, 0);
        $pt->last_video = false;
        if ($key == $len - 1) {
            $pt->last_video = true;
        }
        $final .= PT_LoadPage('paid-videos/list', array(
            'ID' => $video->tr_id,
            'USER_DATA' => $video->owner,
            'THUMBNAIL' => $video->thumbnail,
            'URL' => $video->url,
            'TITLE' => $video->title,
            'DESC' => $video->markup_description,
            'VIEWS' => $video->views,
            'TIME' => $video->time_ago,
            'VIDEO_ID_' => PT_Slug($video->title, $video->video_id)
        ));
    }
}
if (empty($final)) {
	$final = $list;
}
$pt->page_url_ = $pt->config->site_url.'/paid-videos?type='.$type;
$pt->videos      = $get_paid_videos;
$pt->page        = 'paid-videos';
$pt->title       = $lang->paid_videos . ' | ' . $pt->config->title;
$pt->description = $pt->config->description;
$pt->keyword     = $pt->config->keyword;
$pt->content     = PT_LoadPage('paid-videos/content', array(
    'PAID_LIST' => $final
));



I look forward to additional assistance.

This post has been edited by chrisjchrisj: 06 May 2019 - 12:36 PM

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14987
  • View blog
  • Posts: 59,843
  • Joined: 12-June 08

Re: Help with adding ‘purchased’ videos to the ‘liked’ video page

Posted 06 May 2019 - 12:40 PM

Again - I would check the documentation and see if that is an existing feature. No clue where this all came from so you'll have to do that.

Outside of that a basic SQL statement, executed with php, would suffice.

select video name from video purchase table where the key id is equal to the user id from the page... or somethign along those lines.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1