Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
W
WordPress_SexHackMe_Plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SexHackMe
WordPress_SexHackMe_Plugin
Commits
fd4dd83d
Commit
fd4dd83d
authored
Aug 06, 2024
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PPV and discount for premium members on PPVs
parent
b5c7d0aa
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
296 additions
and
142 deletions
+296
-142
functions-wcpms.php
includes/admin/functions-wcpms.php
+7
-0
class-admin.php
includes/class-admin.php
+1
-0
class-video.php
includes/class-video.php
+1
-0
class-videogallery.php
includes/class-videogallery.php
+5
-1
class-woocommerce-support.php
includes/class-woocommerce-support.php
+242
-138
functions-forms-save.php
includes/functions-forms-save.php
+6
-0
sexhackme.php
sexhackme.php
+3
-1
metabox_video.php
templates/admin/metabox_video.php
+6
-0
wcpms.php
templates/admin/wcpms.php
+12
-0
new_video.php
templates/new_video.php
+7
-0
video.php
templates/video.php
+6
-2
No files found.
includes/admin/functions-wcpms.php
View file @
fd4dd83d
...
...
@@ -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>"
;
...
...
includes/class-admin.php
View file @
fd4dd83d
...
...
@@ -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'
);
}
...
...
includes/class-video.php
View file @
fd4dd83d
...
...
@@ -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
,
...
...
includes/class-videogallery.php
View file @
fd4dd83d
...
...
@@ -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>'
;
...
...
includes/class-woocommerce-support.php
View file @
fd4dd83d
...
...
@@ -86,7 +86,7 @@ if(!class_exists("SH_VideoProducts")) {
$prod
->
set_slug
(
$video
->
slug
);
// Product description.
$video_link
=
site_url
()
.
'/'
.
get_option
(
'gallery_slug'
,
'v'
)
.
"/"
.
$video
->
slug
.
"/"
;
$video_link
=
site_url
()
.
'/'
.
get_option
(
'gallery_slug'
,
'v'
)
.
"/"
.
$video
->
slug
.
"/"
;
$prod
->
set_short_description
(
'<p>Whach me <a href="'
.
$video_link
.
'">ONLINE HERE</a></p>'
);
$prod
->
set_description
(
$video
->
description
);
...
...
@@ -112,19 +112,19 @@ if(!class_exists("SH_VideoProducts")) {
// Price
$prod
->
set_regular_price
(
floatval
(
$video
->
price
));
// Prepare product attributes
$attrs
=
array
();
// Prepare product attributes
$attrs
=
array
();
// Videw Preview
$attribute
=
new
\WC_Product_Attribute
();
$attribute
->
set_name
(
'video_preview'
);
$attribute
->
set_options
(
array
(
$video
->
preview
)
);
$attribute
->
set_visible
(
false
);
$attribute
->
set_variation
(
false
);
// Videw Preview
$attribute
=
new
\WC_Product_Attribute
();
$attribute
->
set_name
(
'video_preview'
);
$attribute
->
set_options
(
array
(
$video
->
preview
)
);
$attribute
->
set_visible
(
false
);
$attribute
->
set_variation
(
false
);
$attrs
[]
=
$attribute
;
$prod
->
set_attributes
(
$attrs
);
$attrs
[]
=
$attribute
;
$prod
->
set_attributes
(
$attrs
);
// Download links
$download_public
=
apply_filters
(
'sh_download_url_filter'
,
$video
->
download_public
);
...
...
@@ -139,7 +139,7 @@ if(!class_exists("SH_VideoProducts")) {
$wcdownload
->
set_name
(
basename
(
$video
->
download_public
));
// XXX Do we really want to use basename here?
$wcdownload
->
set_id
(
md5
(
$download_public
));
$wcdownload
->
set_file
(
$download_public
);
$wcdowns
[]
=
$wcdownload
;
$wcdowns
[]
=
$wcdownload
;
}
if
(
$download_members
)
...
...
@@ -148,7 +148,7 @@ if(!class_exists("SH_VideoProducts")) {
$wcdownload
->
set_name
(
basename
(
$video
->
download_members
));
// XXX Do we really want to use basename here?
$wcdownload
->
set_id
(
md5
(
$download_members
));
$wcdownload
->
set_file
(
$download_members
);
$wcdowns
[]
=
$wcdownload
;
$wcdowns
[]
=
$wcdownload
;
}
if
(
$download_premium
)
...
...
@@ -160,7 +160,7 @@ if(!class_exists("SH_VideoProducts")) {
$wcdowns
[]
=
$wcdownload
;
}
$prod
->
set_downloads
(
$wcdowns
);
$prod
->
set_downloads
(
$wcdowns
);
// Categories.
...
...
@@ -197,12 +197,12 @@ if(!class_exists("SH_VideoProducts")) {
}
// Save the product
$prod
->
save
();
$video
->
product_id
=
$prod
->
get_id
();
$prod
->
save
();
$video
->
product_id
=
$prod
->
get_id
();
//sexhack_log($video);
//sexhack_log($video);
return
$video
;
return
$video
;
}
}
...
...
@@ -210,6 +210,110 @@ if(!class_exists("SH_VideoProducts")) {
}
/* Discount for premium members on PPVs */
if
(
!
class_exists
(
'SexhackDiscount'
))
{
class
SexhackDiscount
{
public
function
__construct
()
{
//add_action( 'woocommerce_cart_calculate_fees', 'discount_based_on_user_role', 20, 1 );
add_filter
(
'woocommerce_get_price_html'
,
array
(
$this
,
'custom_price_display_premium'
),
9999
,
2
);
add_action
(
'woocommerce_before_calculate_totals'
,
array
(
$this
,
'custom_price_cart_premium'
),
9999
);
}
public
function
custom_price_display_premium
(
$price_html
,
$product
)
{
if
(
is_admin
()
||
empty
(
$product
->
get_price
()
)
)
return
$price_html
;
if
(
!
user_has_premium_access
())
return
$price_html
;
$product_id
=
$product
->
get_parent_id
()
?
$product
->
get_parent_id
()
:
$product
->
get_id
();
$discount
=
$this
->
check_discount_premium
(
$product_id
);
if
(
$discount
[
'apply'
]
)
{
if
(
$product
->
get_type
()
==
'variable'
)
{
$price_html
=
sprintf
(
'%s - %s'
,
wc_price
(
$product
->
get_variation_regular_price
(
'min'
)
*
$discount
[
'percentage'
]
),
wc_price
(
$product
->
get_variation_regular_price
(
'max'
)
*
$discount
[
'percentage'
]
));
}
else
{
$price_html
=
wc_price
(
$product
->
get_regular_price
()
*
$discount
[
'percentage'
]
);
}
}
return
$price_html
;
}
public
function
custom_price_cart_premium
(
$cart
)
{
if
(
is_admin
()
&&
!
defined
(
'DOING_AJAX'
)
)
return
;
if
(
did_action
(
'woocommerce_before_calculate_totals'
)
>=
2
)
return
;
if
(
!
user_has_premium_access
())
return
;
// Apply discount to cart
foreach
(
$cart
->
get_cart
()
as
$cart_item_key
=>
$cart_item
)
{
$product
=
$cart_item
[
'data'
];
$product_id
=
$product
->
get_parent_id
()
?
$product
->
get_parent_id
()
:
$product
->
get_id
();
$discount
=
$this
->
check_discount_premium
(
$product_id
);
if
(
$discount
[
'apply'
]
)
{
$cart_item
[
'data'
]
->
set_price
(
$product
->
get_regular_price
()
*
$discount
[
'percentage'
]
);
}
}
}
public
function
check_discount_premium
(
$product_id
)
{
$premium_discount
=
intval
(
get_option
(
'sexhack_wcpms_premium_discount'
,
'0'
));
if
(
$premium_discount
>
100
||
$premium_discount
<
0
)
$premium_discount
=
0
;
$discount
=
array
(
'apply'
=>
false
,
'precentage'
=>
floatval
((
100
-
$premium_discount
)
/
100
)
);
$video
=
sh_get_video_from_product
(
$product_id
);
if
(
$video
->
premium_is_ppv
==
'Y'
)
$discount
[
'apply'
]
=
true
;
/*
// Get all product categories for the current product
$terms = wp_get_post_terms( $product_id, 'product_cat' );
foreach ( $terms as $term ) {
$product_categories[] = $term->slug;
}
// Check for discounted categories
if ( !empty( $product_categories ) ) {
// Get array of category matches
$cat_matches = array_intersect( $discount['categories'], $product_categories );
if ( count( $cat_matches ) > 0 ) {
// 1 or more matches
$discount['apply'] = true;
}
} */
return
$discount
;
}
//public function discount_based_on_user_role( $cart )
//{
/*
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
if ( ! current_user_can('company') )
return;
$percentage = 10;
$discount = $cart->get_subtotal() * $percentage / 100; // Calculation
// Applying discount
$cart->add_fee( sprintf( __("Discount (%s)", "woocommerce"), $percentage . '%'), -$discount, true );
*/
//}
}
new
SexhackDiscount
;
}
/* Class woocommerce add-to-checkout management */
if
(
!
class_exists
(
'SexhackWoocommerceCheckout'
))
{
...
...
@@ -218,7 +322,7 @@ if(!class_exists('SexhackWoocommerceCheckout')) {
public
function
__construct
()
{
//add_action( 'woocommerce_before_checkout_form', array($this, 'empty_cart'), 1);
add_action
(
'woocommerce_add_to_cart_validation'
,
array
(
$this
,
'empty_cart'
),
1
);
add_action
(
'woocommerce_add_to_cart_validation'
,
array
(
$this
,
'empty_cart'
),
1
);
add_filter
(
'woocommerce_add_to_cart_redirect'
,
array
(
$this
,
'redirect_checkout_add_cart'
));
...
...
@@ -234,7 +338,7 @@ if(!class_exists('SexhackWoocommerceCheckout')) {
if
(
isset
(
$_GET
[
'shm_direct_checkout'
])
&&
is_numeric
(
$_GET
[
'shm_direct_checkout'
]))
{
global
$woocommerce
;
$woocommerce
->
cart
->
empty_cart
();
//WC()->session->set('cart', array());
//WC()->session->set('cart', array());
$woocommerce
->
cart
->
add_to_cart
(
intval
(
$_GET
[
'shm_direct_checkout'
]),
1
);
}
else
{
//$woocommerce->cart->empty_cart();
...
...
@@ -257,12 +361,12 @@ if(!class_exists('SexhackWoocommerceCheckout')) {
}
public
function
product_loop_oneclick
()
{
global
$product
;
global
$product
;
remove_action
(
'woocommerce_after_shop_loop_item'
,
'woocommerce_template_loop_add_to_cart'
);
if
(
!
$product
->
is_type
(
'variable'
))
{
echo
'<div class="custom-add-to-cart">'
;
//woocommerce_template_loop_add_to_cart();
echo
'<a class="button" href="'
.
wc_get_checkout_url
()
.
"?add-to-cart="
.
$product
->
get_id
()
.
"&shm_direct_checkout="
.
$product
->
get_id
()
.
'">Buy now!</a>'
;
//woocommerce_template_loop_add_to_cart();
echo
'<a class="button" href="'
.
wc_get_checkout_url
()
.
"?add-to-cart="
.
$product
->
get_id
()
.
"&shm_direct_checkout="
.
$product
->
get_id
()
.
'">Buy now!</a>'
;
echo
'</div>'
;
}
}
...
...
@@ -270,7 +374,7 @@ if(!class_exists('SexhackWoocommerceCheckout')) {
public
function
oneclick_checkout
()
{
global
$product
;
echo
'<a class="button" href="'
.
wc_get_checkout_url
()
.
"?add-to-cart="
.
$product
->
get_id
()
.
"&shm_direct_checkout="
.
$product
->
get_id
()
.
'">Buy now!</a>'
;
echo
'<a class="button" href="'
.
wc_get_checkout_url
()
.
"?add-to-cart="
.
$product
->
get_id
()
.
"&shm_direct_checkout="
.
$product
->
get_id
()
.
'">Buy now!</a>'
;
remove_action
(
'woocommerce_'
.
$product
->
get_type
()
.
'_add_to_cart'
,
'woocommerce_'
.
$product
->
get_type
()
.
'_add_to_cart'
,
30
);
}
...
...
@@ -601,11 +705,11 @@ if(!class_exists('SH_WooCommerce_Registration_Integration')) {
if
(
!
class_exists
(
'SH_WooCommerce_Chaturbate_Payments'
))
{
add_filter
(
'woocommerce_payment_gateways'
,
'wp_SexHackMe\sh_add_payment_gateway_class'
);
function
sh_add_payment_gateway_class
(
$gateways
)
{
$gateways
[]
=
'wp_SexHackMe\SH_WooCommerce_Chaturbate_Payments'
;
// your class name is here
return
$gateways
;
}
add_filter
(
'woocommerce_payment_gateways'
,
'wp_SexHackMe\sh_add_payment_gateway_class'
);
function
sh_add_payment_gateway_class
(
$gateways
)
{
$gateways
[]
=
'wp_SexHackMe\SH_WooCommerce_Chaturbate_Payments'
;
// your class name is here
return
$gateways
;
}
add_action
(
'plugins_loaded'
,
'wp_SexHackMe\chaturbate_payment_init'
);
function
chaturbate_payment_init
()
{
...
...
@@ -616,32 +720,32 @@ if(!class_exists('SH_WooCommerce_Chaturbate_Payments')) {
$this
->
id
=
'shchaturbate'
;
$this
->
method_title
=
'Chaturbate Payment Gateway (SexHackMe)'
;
$this
->
method_description
=
'Receive payments in chaturbate.com tokens'
;
$this
->
icon
=
SH_PLUGIN_DIR_URL
.
'/img/chaturbate_ico.png'
;
// URL to the icon
$this
->
icon
=
SH_PLUGIN_DIR_URL
.
'/img/chaturbate_ico.png'
;
// URL to the icon
$this
->
has_fields
=
true
;
$this
->
init_form_fields
();
$this
->
init_settings
();
$this
->
supports
=
array
(
'products'
);
$this
->
supports
=
array
(
'products'
);
$this
->
enabled
=
$this
->
get_option
(
'enabled'
);
$this
->
enabled
=
$this
->
get_option
(
'enabled'
);
$this
->
title
=
$this
->
get_option
(
'title'
);
$this
->
description
=
$this
->
get_option
(
'description'
);
$this
->
uuid_prefix
=
$this
->
get_option
(
'uuid_prefix'
);
$this
->
cb_model
=
$this
->
get_option
(
'cb_model'
);
$this
->
cb_change
=
$this
->
get_option
(
'cb_change'
);
$this
->
instructions
=
$this
->
get_option
(
'instructions'
);
$this
->
uuid_prefix
=
$this
->
get_option
(
'uuid_prefix'
);
$this
->
cb_model
=
$this
->
get_option
(
'cb_model'
);
$this
->
cb_change
=
$this
->
get_option
(
'cb_change'
);
$this
->
instructions
=
$this
->
get_option
(
'instructions'
);
$this
->
api_passkey
=
$this
->
get_option
(
'api_passkey'
);
add_action
(
'woocommerce_update_options_payment_gateways_'
.
$this
->
id
,
array
(
$this
,
'process_admin_options'
));
add_action
(
'woocommerce_api_shchaturbate'
,
array
(
$this
,
'webhook_cb'
)
);
//add_action( 'woocommerce_before_thankyou', array( $this, 'thankyou_page' ));
add_filter
(
'woocommerce_thankyou_order_received_text'
,
array
(
$this
,
'thankyou_page'
),
90
,
2
);
add_action
(
'woocommerce_api_shchaturbate'
,
array
(
$this
,
'webhook_cb'
)
);
//add_action( 'woocommerce_before_thankyou', array( $this, 'thankyou_page' ));
add_filter
(
'woocommerce_thankyou_order_received_text'
,
array
(
$this
,
'thankyou_page'
),
90
,
2
);
// Customer Emails.
add_action
(
'woocommerce_email_before_order_table'
,
array
(
$this
,
'email_instructions'
),
10
,
3
);
// Customer Emails.
add_action
(
'woocommerce_email_before_order_table'
,
array
(
$this
,
'email_instructions'
),
10
,
3
);
//add_action( 'woocommerce_order_status_pending', array( $this, 'email_instructions' ), 9000, 2 );
...
...
@@ -673,19 +777,19 @@ if(!class_exists('SH_WooCommerce_Chaturbate_Payments')) {
}
}
die
();
//$order->reduce_order_stock();
//$order->reduce_order_stock();
}
// Initialize settings fields
public
function
init_form_fields
()
{
$this
->
form_fields
=
array
(
'enabled'
=>
array
(
'title'
=>
'Enable/Disable'
,
'label'
=>
'Enable Chaturbate Gateway'
,
'type'
=>
'checkbox'
,
'description'
=>
''
,
'default'
=>
'no'
),
'enabled'
=>
array
(
'title'
=>
'Enable/Disable'
,
'label'
=>
'Enable Chaturbate Gateway'
,
'type'
=>
'checkbox'
,
'description'
=>
''
,
'default'
=>
'no'
),
'title'
=>
array
(
'title'
=>
__
(
'Title'
,
'woocommerce'
),
'type'
=>
'text'
,
...
...
@@ -700,34 +804,34 @@ if(!class_exists('SH_WooCommerce_Chaturbate_Payments')) {
'default'
=>
__
(
'Pay using Chaturbate tokens'
,
'woocommerce'
),
'desc_tip'
=>
true
,
),
'cb_change'
=>
array
(
'title'
=>
'CB Tokens USD conversion'
,
'type'
=>
'number'
,
'custom_attributes'
=>
array
(
'step'
=>
'any'
,
'min'
=>
'0'
),
'description'
=>
'Value of 1 chaturbate token in USD'
,
'desc_tip'
=>
true
,
'default'
=>
0.05
,
),
'cb_change'
=>
array
(
'title'
=>
'CB Tokens USD conversion'
,
'type'
=>
'number'
,
'custom_attributes'
=>
array
(
'step'
=>
'any'
,
'min'
=>
'0'
),
'description'
=>
'Value of 1 chaturbate token in USD'
,
'desc_tip'
=>
true
,
'default'
=>
0.05
,
),
'instructions'
=>
array
(
'title'
=>
__
(
'Instructions'
,
'woocommerce'
),
'type'
=>
'textarea'
,
'description'
=>
__
(
'Instructions that will be added to the thank you page and emails.'
,
'woocommerce'
),
'default'
=>
'Send {TOTAL} chaturbate tokens to https://chaturbate.com/{CB_MODEL} with the message {ORDER_UUID}'
,
'desc_tip'
=>
true
,
),
'uuid_prefix'
=>
array
(
'title'
=>
'Order ID Prefix'
,
'type'
=>
'text'
,
'description'
=>
'order ID prefix for messages included in tokens sent'
,
'desc_tip'
=>
true
,
'default'
=>
'SHMPAY-'
,
),
'cb_model'
=>
array
(
'title'
=>
'Model name'
,
'type'
=>
'text'
,
'description'
=>
'Model name on chaturbate that will receive tokens'
,
'desc_tip'
=>
true
,
'default'
=>
'sexhackme'
,
'title'
=>
__
(
'Instructions'
,
'woocommerce'
),
'type'
=>
'textarea'
,
'description'
=>
__
(
'Instructions that will be added to the thank you page and emails.'
,
'woocommerce'
),
'default'
=>
'Send {TOTAL} chaturbate tokens to https://chaturbate.com/{CB_MODEL} with the message {ORDER_UUID}'
,
'desc_tip'
=>
true
,
),
'uuid_prefix'
=>
array
(
'title'
=>
'Order ID Prefix'
,
'type'
=>
'text'
,
'description'
=>
'order ID prefix for messages included in tokens sent'
,
'desc_tip'
=>
true
,
'default'
=>
'SHMPAY-'
,
),
'cb_model'
=>
array
(
'title'
=>
'Model name'
,
'type'
=>
'text'
,
'description'
=>
'Model name on chaturbate that will receive tokens'
,
'desc_tip'
=>
true
,
'default'
=>
'sexhackme'
,
),
'api_passkey'
=>
array
(
'title'
=>
'API Passkey'
,
...
...
@@ -740,83 +844,83 @@ if(!class_exists('SH_WooCommerce_Chaturbate_Payments')) {
);
}
private
function
print_instructions
(
$order_id
,
$totalusd
=-
1
)
{
$instr
=
str_replace
(
'{CB_MODEL}'
,
$this
->
cb_model
,
$this
->
instructions
);
$instr
=
str_replace
(
'{ORDER_UUID}'
,
$this
->
uuid_prefix
.
strval
(
$order_id
),
$instr
);
if
(
$totalusd
<
0
)
{
$order
=
wc_get_order
(
$order_id
);
$totalusd
=
$order
->
get_total
();
}
$instr
=
str_replace
(
'{TOTAL}'
,
intval
(
$this
->
usd2tokens
(
$totalusd
)),
$instr
);
return
$instr
;
}
//public function thankyou_page($order_id) {
public
function
thankyou_page
(
$msg
,
$order
)
{
$order_id
=
$order
->
get_id
();
if
(
$this
->
instructions
)
{
//$order = wc_get_order( $order_id );
if
(
$order
->
get_payment_method
()
==
'shchaturbate'
)
return
"Thank you, we received your order!
\n
"
.
wp_kses_post
(
wpautop
(
wptexturize
(
$this
->
print_instructions
(
$order_id
,
$order
->
get_total
())
)
)
);
//echo wp_kses_post( wpautop( wptexturize( $this->print_instructions($order_id, $order->get_total()) ) ) );
}
return
$msg
;
}
private
function
print_instructions
(
$order_id
,
$totalusd
=-
1
)
{
$instr
=
str_replace
(
'{CB_MODEL}'
,
$this
->
cb_model
,
$this
->
instructions
);
$instr
=
str_replace
(
'{ORDER_UUID}'
,
$this
->
uuid_prefix
.
strval
(
$order_id
),
$instr
);
if
(
$totalusd
<
0
)
{
$order
=
wc_get_order
(
$order_id
);
$totalusd
=
$order
->
get_total
();
}
$instr
=
str_replace
(
'{TOTAL}'
,
intval
(
$this
->
usd2tokens
(
$totalusd
)),
$instr
);
return
$instr
;
}
//public function thankyou_page($order_id) {
public
function
thankyou_page
(
$msg
,
$order
)
{
$order_id
=
$order
->
get_id
();
if
(
$this
->
instructions
)
{
//$order = wc_get_order( $order_id );
if
(
$order
->
get_payment_method
()
==
'shchaturbate'
)
return
"Thank you, we received your order!
\n
"
.
wp_kses_post
(
wpautop
(
wptexturize
(
$this
->
print_instructions
(
$order_id
,
$order
->
get_total
())
)
)
);
//echo wp_kses_post( wpautop( wptexturize( $this->print_instructions($order_id, $order->get_total()) ) ) );
}
return
$msg
;
}
public
function
email_instructions
(
$order
,
$sent_to_admin
,
$plain_text
=
false
)
{
public
function
email_instructions
(
$order
,
$sent_to_admin
,
$plain_text
=
false
)
{
if
(
$this
->
instructions
&&
!
$sent_to_admin
&&
'shchaturbate'
===
$order
->
get_payment_method
()
&&
$order
->
has_status
(
apply_filters
(
'woocommerce_shchaturbate_email_instructions_order_status'
,
'on-hold'
,
$order
)
)
)
{
$note
=
wp_kses_post
(
wpautop
(
wptexturize
(
$this
->
print_instructions
(
$order
->
get_id
(),
$order
->
get_total
())
)
)
.
PHP_EOL
);
echo
$note
;
echo
$note
;
$order
->
update_status
(
'pending'
,
$note
);
}
}
}
// Process payment
public
function
process_payment
(
$order_id
)
{
$order
=
wc_get_order
(
$order_id
);
$total
=
$order
->
get_total
();
if
(
$total
>
0
)
{
// Mark as on-hold (we're awaiting the shchaturbate).
$order
->
update_status
(
apply_filters
(
'woocommerce_shchaturbate_process_payment_order_status'
,
'on-hold'
,
$order
),
'Waiting for '
.
intval
(
$this
->
usd2tokens
(
$total
))
.
' tokens to https://chaturbate.com/'
.
$this
->
cb_model
.
' with message '
.
$this
->
uuid_prefix
.
$order_id
);
}
else
{
$order
->
payment_complete
();
}
$order
=
wc_get_order
(
$order_id
);
$total
=
$order
->
get_total
();
if
(
$total
>
0
)
{
// Mark as on-hold (we're awaiting the shchaturbate).
$order
->
update_status
(
apply_filters
(
'woocommerce_shchaturbate_process_payment_order_status'
,
'on-hold'
,
$order
),
'Waiting for '
.
intval
(
$this
->
usd2tokens
(
$total
))
.
' tokens to https://chaturbate.com/'
.
$this
->
cb_model
.
' with message '
.
$this
->
uuid_prefix
.
$order_id
);
}
else
{
$order
->
payment_complete
();
}
// if($total<-0)
// $order->payment_complete();
//$order->update_status('on-hold', __( 'Pay by sending '.intval($total/0.05).' tokens to https://chaturbate.com/sexhackme', 'woocommerce' ));
/*
$order->add_order_note(
'Please go on https://chaturbate.com/sexhackme and tip '.intval($total/0.05).' tokens with the message SHM-'.strval($order_id),
true );
*/
// Empty cart
WC
()
->
cart
->
empty_cart
();
return
array
(
'result'
=>
'success'
,
'redirect'
=>
$this
->
get_return_url
(
$order
),
);
//$order->update_status('on-hold', __( 'Pay by sending '.intval($total/0.05).' tokens to https://chaturbate.com/sexhackme', 'woocommerce' ));
/*
$order->add_order_note(
'Please go on https://chaturbate.com/sexhackme and tip '.intval($total/0.05).' tokens with the message SHM-'.strval($order_id),
true );
*/
// Empty cart
WC
()
->
cart
->
empty_cart
();
return
array
(
'result'
=>
'success'
,
'redirect'
=>
$this
->
get_return_url
(
$order
),
);
}
/*
// XXX We don't use anything special here.
/*
// XXX We don't use anything special here.
// Display payment fields during checkout
public function payment_fields() {
...
...
includes/functions-forms-save.php
View file @
fd4dd83d
...
...
@@ -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'
];
...
...
sexhackme.php
View file @
fd4dd83d
...
...
@@ -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
}
;
...
...
templates/admin/metabox_video.php
View file @
fd4dd83d
...
...
@@ -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'
);
...
...
templates/admin/wcpms.php
View file @
fd4dd83d
...
...
@@ -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"
>
...
...
templates/new_video.php
View file @
fd4dd83d
...
...
@@ -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>
...
...
templates/video.php
View file @
fd4dd83d
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment