Methods summary
public static
|
|
public static
boolean
|
#
is_woocommerce_active( )
check if WooCommerce plugin is loaded and allowed by Sensei
check if WooCommerce plugin is loaded and allowed by Sensei
Returns
boolean
Since
1.9.0
|
public static
boolean
|
#
is_woocommerce_present( )
Checks if the WooCommerce plugin is installed and activation.
Checks if the WooCommerce plugin is installed and activation.
If you need to check if WooCommerce is activated use Sensei_Utils::is_woocommerce_active().
This function does nott check to see if the Sensei setting for WooCommerce is enabled.
Returns
boolean
Since
1.9.0
|
public static
array
|
#
get_learner_course_active_order_id( $user_id, $course_id )
Find the order active number (completed or processing ) for a given user on a course. It will return the latest order.
Find the order active number (completed or processing ) for a given user on a course. It will return the latest order.
If multiple exist we will return the latest order.
Parameters
Returns
array $user_course_orders
|
public static
mixed
|
#
add_course_archive_wc_filter_links( $filter_links )
Output WooCommerce specific course filters
Removing the paged argument
Output WooCommerce specific course filters
Removing the paged argument
Parameters
Returns
mixed
Since
1.9.0
|
public static
WP_Query
|
#
course_archive_wc_filter_free( WP_Query $query )
Apply the free filter the the course query
getting all course with no products or products with zero price
Apply the free filter the the course query
getting all course with no products or products with zero price
hooked into pre_get_posts
Parameters
Returns
WP_Query $query
Since
1.9.0
|
public static
WP_Query
|
#
course_archive_wc_filter_paid( WP_Query $query )
Apply the paid filter to the course query on the courses page
will include all course with a product attached with a price
more than 0
Apply the paid filter to the course query on the courses page
will include all course with a product attached with a price
more than 0
hooked into pre_get_posts
Parameters
Returns
WP_Query $query
Since
1.9.0
|
public static
|
#
do_single_course_wc_single_product_action( )
Load the WooCommerce single product actions above
single courses if woocommerce is active allowing purchase
information and actions to be hooked from WooCommerce.
Load the WooCommerce single product actions above
single courses if woocommerce is active allowing purchase
information and actions to be hooked from WooCommerce.
|
public static
boolean
|
#
alter_can_user_view_lesson( $can_user_view_lesson, $lesson_id, $user_id )
Hooking into the single lesson page to alter the
user access permissions based on if they have purchased the
course the lesson belongs to.
Hooking into the single lesson page to alter the
user access permissions based on if they have purchased the
course the lesson belongs to.
This function will only return false or the passed in user_access value.
It doesn't return true in order to avoid altering other options.
Parameters
- $can_user_view_lesson
- $lesson_id
- $user_id
Returns
boolean
Since
1.9.0
|
public static
|
#
course_link_from_order( )
Add course link to order thank you and details pages.
Add course link to order thank you and details pages.
Since
1.4.5
|
public static
|
#
course_in_cart_message( )
Show the message that a user should complete
their purchase if the course is in the cart
Show the message that a user should complete
their purchase if the course is in the cart
This should be used within the course loop or single course page
Since
1.9.0
|
public static
boolean
|
#
is_course_in_cart( $course_id )
Checks the cart to see if a course is in the cart.
Checks the cart to see if a course is in the cart.
Parameters
Returns
boolean
|
public static
boolean
|
#
is_product_in_cart( $product_id )
Check the cart to see if the product is in the cart
Check the cart to see if the product is in the cart
Parameters
Returns
boolean
|
public static
array
|
#
get_free_product_ids( )
Get all free WooCommerce products
Get all free WooCommerce products
Returns
array $free_products{
Since
1.9.0
Type
|
public static
array
|
#
get_free_courses_meta_query_args( )
The metat query for courses that are free
The metat query for courses that are free
Returns
array $wp_meta_query_param
Since
1.9.0
|
public static
array
|
#
get_paid_courses_meta_query_args( )
The metat query for courses that are free
The metat query for courses that are free
Returns
array $wp_query_meta_query_args_param
Since
1.9.0
|
public static
array
|
#
get_paid_products_on_sale_query_args( )
The WordPress Query args
for paid products on sale
The WordPress Query args
for paid products on sale
Returns
array $product_query_args
Since
1.9.0
|
public static
array
|
#
get_paid_products_not_on_sale_query_args( )
Return the WordPress query args for
products not on sale but that is not a free
Return the WordPress query args for
products not on sale but that is not a free
Returns
array
Since
1.9.0
|
public static
array
|
#
get_paid_product_ids( )
Get all WooCommerce non-free product id's
Get all WooCommerce non-free product id's
Returns
array $woocommerce_paid_product_ids
Since
1.9.0
|
public static
array
|
#
get_free_courses( array $args = array() )
Get all free courses.
This course that have a WC product attached
that has a price or sale price of zero and
other courses with no WooCommerce products
attached.
Parameters
Returns
array
Since
1.9.0
|
public static
array
|
#
get_paid_courses( array $args = array() )
Return all products that are not free
Return all products that are not free
Parameters
- $args
- override default arg values
Returns
array
Since
1.9.0
|
public static
string
|
#
the_add_to_cart_button_html( integer $course_id )
Show the WooCommerce add to cart button for the current course
Show the WooCommerce add to cart button for the current course
The function will only show the button if
1- the user can buy the course
2- if they have completed their pre-requisite
3- if the course has a valid product attached
Parameters
Returns
string $html markup for the button or nothing if user not allowed to buy
Since
1.9.0
|
public static
string
|
#
alter_no_permissions_message( $message, $post_id )
Alter the no permissions message on the single course page
Changes the message to a WooCommerce specific message.
Alter the no permissions message on the single course page
Changes the message to a WooCommerce specific message.
Parameters
Returns
string $message
Since
1.9.0
|
public static
|
#
the_course_no_permissions_message( $course_id )
Show the no permissions message when a user is logged in
and have not yet purchased the current course
Show the no permissions message when a user is logged in
and have not yet purchased the current course
Since
1.9.0
|
public static
boolean
|
#
has_customer_bought_product( integer $user_id, integer $product_id )
Checks if a user has bought a product item.
Checks if a user has bought a product item.
Parameters
Returns
boolean
Since
1.9.0
|
public static
string
|
#
get_course_product_id( integer $course_id )
Return the product id for the given course
Return the product id for the given course
Parameters
Returns
string $woocommerce_product_id or false if none exist
Since
1.9.0
|
public static
array
|
#
add_woocommerce_body_class( array $classes )
Alter the body classes adding WooCommerce to the body
Alter the body classes adding WooCommerce to the body
Speciall cases where this is needed is template no-permissions.php
Parameters
Returns
array
|
public static
|
#
activate_subscription( WC_Order $order )
Responds to when a subscription product is purchased
Responds to when a subscription product is purchased
Parameters
Since
1.2.0
1.9.0 move to class Sensei_WC
|
public static
|
#
email_course_details( WC_Order $order )
Adds detail to to the WooCommerce order
Adds detail to to the WooCommerce order
Parameters
Since
1.4.5
1.9.0 function moved to class Sensei_WC and renamed from sensei_woocommerce_email_course_details to email_course_details
|
public static
|
#
complete_order( integer $order_id = 0 )
sensei_woocommerce_complete_order description
sensei_woocommerce_complete_order description
Parameters
Since
1.0.3
|
public static
|
#
cancel_order( integer| $order_id )
Responds to when an order is cancelled.
Responds to when an order is cancelled.
Parameters
- $order_id
- $order_id order ID
Since
1.2.0
1.9.0 Move function to the Sensei_WC class
|
public static
WC_Product
|
#
get_product_object( integer $wc_product_id = 0, string $product_type = '' )
Returns the WooCommerce Product Object
Returns the WooCommerce Product Object
The code caters for pre and post WooCommerce 2.2 installations.
Parameters
- $wc_product_id
- Product ID or Variation ID
- $product_type
- '' or 'variation'
Returns
WC_Product $wc_product_object
Since
1.1.1
|
public static
boolean|integer
|
#
course_update( integer $course_id = 0, array/Object $order_user = array() )
If customer has purchased the course, update Sensei to indicate that they are taking the course.
If customer has purchased the course, update Sensei to indicate that they are taking the course.
Parameters
- $course_id
- (default: 0)
- $order_user
- (default: array()) Specific user's data.
Returns
boolean|integer
Since
1.0.0
1.9.0 move to class Sensei_WC
|
public static
boolean
|
#
disable_guest_checkout( boolean $guest_checkout )
Disable guest checkout if a course product is in the cart
Disable guest checkout if a course product is in the cart
Parameters
- $guest_checkout
- Current guest checkout setting
Returns
boolean Modified guest checkout setting
Since
1.1.0
1.9.0 move to class Sensei_WC
|
public static
string
|
#
virtual_order_payment_complete( string $order_status, integer $order_id )
Change order status with virtual products to completed
Change order status with virtual products to completed
Parameters
Returns
string
Since
1.1.0
1.9.0 move to class Sensei_WC
|
public static
boolean
|
#
get_subscription_permission( boolean$user_access_permission $user_access_permission, integer $user_id )
Determine if the user has and active subscription to give them access
to the requested resource.
Determine if the user has and active subscription to give them access
to the requested resource.
Parameters
- $user_access_permission
- $user_id
Returns
boolean $user_access_permission
Since
1.9.0
|
public static
boolean
|
#
get_subscription_user_started_course( $has_user_started_course, $course_id, $user_id )
Parameters
- $has_user_started_course
- $course_id
- $user_id
Returns
boolean $has_user_started_course
Since
1.9.0
|
public static
array
|
#
get_subscription_types( )
Get all the valid subscription types.
Get all the valid subscription types.
Returns
array
Since
1.9.0
|
public static
boolean
|
#
was_user_added_without_subscription( $user_id, $product_id, $course_id )
Compare the user's subscriptions end date with the date
the user was added to the course. If the user was added after
the subscription ended they were manually added and this will return
true.
Compare the user's subscriptions end date with the date
the user was added to the course. If the user was added after
the subscription ended they were manually added and this will return
true.
Important to note that all subscriptions for the user is compared.
Parameters
- $user_id
- $product_id
- $course_id
Returns
boolean
Since
1.9.0
|
public static
array
|
#
get_user_product_orders( integer $user_id, $product_id )
Get all the orders for a specific user and product combination
Get all the orders for a specific user and product combination
Parameters
Returns
array $orders
|
public static
boolean
|
#
is_course_purchasable( integer $course_id = 0 )
Determine if a course can be purchased. Purchasable
courses have valid products attached. These can also be products
with price of Zero.
Determine if a course can be purchased. Purchasable
courses have valid products attached. These can also be products
with price of Zero.
Parameters
Returns
boolean
Since
1.9.0
|