PPV and discount for premium members on PPVs

parent b5c7d0aa
......@@ -30,11 +30,18 @@ function wcpms_adminpage()
sh_get_template('admin/wcpms.php');
}
function settings_wcpms_section()
{
echo "<h2>SexHackMe PMS - WooCommerce integration Settings</h2>";
}
function settings_wcpms_section_premium_discount()
{
echo "<h2>Premium users discount on Videos</h2>";
}
function settings_wcpms_section_email()
{
echo "<h2>WooCommerce Checkout Email endpoint</h2>";
......
......@@ -61,6 +61,7 @@ if(!class_exists('SH_Admin')) {
add_settings_section('sexhackme-wcpms-settings', ' ', 'wp_SexHackMe\settings_wcpms_section_prodcat', 'sexhackme-wcpms-settings-prodcat');
register_setting('sexhackme-wcpms-settings', 'sexhack_wcpms-prodcat');
register_setting('sexhackme-wcpms-settings', 'sexhack_wcpms-prodvisible');
register_setting('sexhackme-wcpms-settings', 'sexhack_wcpms_premium_discount');
}
......
......@@ -51,6 +51,7 @@ if(!class_exists('SH_Video')) {
'hls_public' => false,
'hls_members' => false,
'hls_premium' => false,
'premium_is_ppv' => 'N',
'thumbnail' => false,
'gif' => false,
'gif_small' => false,
......
......@@ -116,6 +116,7 @@ if(!class_exists('SH_VideoGallery')) {
$hls_premium = $video->hls_premium;
$video_preview = $video->preview;
$gif_preview = $video->gif_small;
$premium_is_ppv = $video->premium_is_ppv;
//sexhack_log($video);
......@@ -140,7 +141,10 @@ if(!class_exists('SH_VideoGallery')) {
if($hls_public) $vtags[] = '<label class="sexhack_vtag sexhack_public" style="*LEFT*">public</label>';
elseif($video_preview) $vtags[] = '<label class="sexhack_vtag sexhack_preview" style="*LEFT*">preview</label>';
if($hls_member)$vtags[] = '<label class="sexhack_vtag sexhack_members" style="*LEFT*">members</label>';
if($hls_premium)$vtags[] = '<label class="sexhack_vtag sexhack_premium" style="*LEFT*">premium</label>';
if($hls_premium) {
if($video->ppv_is_ppv) $vtags[] = '<label class="sexhack_vtag sexhack_premium" style="*LEFT*">PPV</label>';
else $vtags[] = '<label class="sexhack_vtag sexhack_premium" style="*LEFT*">premium</label>';
}
if($video->has_downloads()) $html .= '<label class="sexhack_vtag sexhack_download"">download</label>';
if($video->video_type == 'VR') $html .= '<label class="sexhack_vtag sexhack_VR"">VR/3D</label>';
......
This diff is collapsed.
......@@ -135,6 +135,11 @@ function save_sexhack_video_forms( $post_id)
if(array_key_exists('video_private', $_POST) && in_array($_POST['video_private'], array('Y','N')))
$video->private = $_POST['video_private'];
// Premium Video is PPV?
if(array_key_exists('premium_is_ppv', $_POST) && in_array($_POST['premium_is_ppv'], array('Y','N')))
$video->premium_is_ppv = $_POST['premium_is_ppv'];
// Video visible
if(array_key_exists('video_visible', $_POST) && in_array($_POST['video_visible'], array('Y','N')))
$video->visible = $_POST['video_visible'];
......@@ -148,6 +153,7 @@ function save_sexhack_video_forms( $post_id)
if(array_key_exists('video_type', $_POST) && in_array($_POST['video_type'], array('VR', 'FLAT')))
$video->video_type = $_POST['video_type'];
// VR Projection
if(array_key_exists('video_vr_projection', $_POST) && in_array($_POST['video_vr_projection'], array('VR180_LR','VR360_LR')))
$video->vr_projection = $_POST['video_vr_projection'];
......
......@@ -47,7 +47,7 @@ if(!class_exists('SexHackMe_Plugin')) {
public function __construct()
{
define( 'SH_VERSION', '0.0.2' );
define( 'SH_VERSION', '0.0.3' );
define( 'SH_PLUGIN_DIR_PATH', plugin_dir_path( __FILE__ ) );
define( 'SH_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ) );
define( 'SH_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
......@@ -190,6 +190,7 @@ if(!class_exists('SexHackMe_Plugin')) {
download_public varchar(1024) DEFAULT NULL,
download_members varchar(1024) DEFAULT NULL,
download_premium varchar(1024) DEFAULT NULL,
premium_is_ppv ENUM('Y', 'N') NOT NULL DEFAULT 'N',
size_public varchar(256) DEFAULT NULL,
size_members varchar(256) DEFAULT NULL,
size_premium varchar(256) DEFAULT NULL,
......@@ -218,6 +219,7 @@ if(!class_exists('SexHackMe_Plugin')) {
KEY post_id (post_id),
KEY slug (slug),
KEY price (price),
KEY premium_is_ppv (premium_is_ppc),
KEY video_type (video_type),
KEY product_id (product_id)
) {$charset_collate};
......
......@@ -108,6 +108,12 @@ if($video->product_id > 0)
<label>USD:</label>
<input type='text' name="video_price" value='<?php echo esc_attr( $video->price ); ?>' />
</p>
<p>
<h4>is premium a PPV?</h4>
<input type='radio' name='premium_is_ppv' value='Y' <?php if($video->premium_is_ppv=='Y') echo "checked"; ?>>Yes</input>
<input type='radio' name='premium_is_ppv' value='N' <?php if($video->premium_is_ppv=='N') echo "checked"; ?>>No</input>
</p>
<p>
<?php
$vaccess=array('public','members','premium');
......
......@@ -62,6 +62,18 @@ $plans = wp_SexHackMe\sh_get_subscription_plans();
}
?>
</table>
<table class="form-table">
<tr align="top">
<td>
<label><b>Premium member discount on PPVs</b></label><br>
<input type='number' name='sexhack_wcpms_premium_discount' value="<?php echo get_option('sexhack_wcpms_premium_discount', '0'); ?>" />
<p class="description">insert a percentage of discount all premium members will have on PPV videos</p>
</td>
</tr>
</table>
<?php do_settings_sections( 'sexhackme-wcpms-settings-email' ); ?>
<table class="form-table">
<tr align="top">
......
......@@ -120,6 +120,13 @@ foreach(array('public','members','premium') as $level) { ?>
<input type='radio' name='video_isdownload_<?php echo $level; ?>' value='N' <?php if(!$video->has_downloads($level)) echo "checked"; ?>>No</input>
</p>
<?php if($level == 'premium') { ?>
<p>
<label>Is premium video a PPV?</label>
<input type='radio' name='premium_is_ppv' value='Y' <?php if($video->premium_is_ppv=='Y') echo "checked"; ?>>Yes</input>
<input type='radio' name='premium_is_ppv' value='N' <?php if($video->premium_is_ppv=='N') echo "checked"; ?>>No</input>
</p>
<p>
<label> Create Members video HLS from this video? </label>
<input type='radio' name='video_createMembers_<?php echo $level; ?>' value='Y' >Yes</input>
......
......@@ -84,6 +84,7 @@ get_header(); ?>
$video_preview = $video->preview;
$gif_preview = $video->gif_small;
$gif = $video->gif;
$premium_is_ppv = $video->premium_is_ppv;
$categories = $video->get_categories(true);
......@@ -116,7 +117,7 @@ get_header(); ?>
else
{
if(user_has_premium_access() || $video->user_bought_video()) {
if($hls_premium) $tab = 'subscribers';
if($hls_premium && ((!$premium_is_ppv) || $video->user_bought_video() )) $tab = 'subscribers';
elseif($hls_members) $tab = 'members';
else $tab = 'public';
}
......@@ -162,7 +163,7 @@ get_header(); ?>
break;
case "subscribers":
if(user_has_premium_access() || $video->user_bought_video())
if((user_has_premium_access() && !$premium_is_ppv) || $video->user_bought_video())
{
if($filterurl && $hls_premium && $video->video_type=="VR")
echo do_shortcode( "[sexvideo url=\"".wp_nonce_url($filterurl.$sh_video."/premium/".basename($hls_premium), 'shm_premium_video-'.$video->id)."\" posters=\"".$thumb."\"]" );
......@@ -252,6 +253,9 @@ get_header(); ?>
</div>
<?php } ?>
<?php if(!$video->user_bought_video() && $hls_premium && $premium_is_ppv) { ?>
<h3><a href="<?php echo get_permalink($video->product_id); ?>">Buy unlimited full access to this video</a></h3>
<?php } ?>
<?php if($video->has_downloads()) { ?>
<h3><a href="<?php echo get_permalink($video->product_id); ?>">Download the full lenght hi-res version of this video</a></h3>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment