Skip to content

Instantly share code, notes, and snippets.

View woogist's full-sized avatar

WooCommerce.com Documentation woogist

View GitHub Profile
@woogist
woogist / prevent_registered_learners_from_starting_courses.php
Created February 10, 2017 13:44
This code prevents Sensei learners from starting a course unless they've been specifically added to that course by a site administrator or a teacher.
<?php
function sensei_display_start_course_form_when_admin_or_teacher( $should_display_start, $course_id ) {
global $current_user;
if ( empty( $current_user ) ) {
$current_user = wp_get_current_user();
}
if ( !( $current_user instanceof WP_User ) || 0 === $current_user->ID ) {
@woogist
woogist / fue-template.html
Created December 2, 2016 09:12
Follow-up emails template name
<!-- Template Name: Unique name of your choosing -->
@woogist
woogist / functions.php
Created October 26, 2016 14:04
Dynamic Pricing - Product Ineligible for Discounts
add_filter('woocommerce_dynamic_pricing_process_product_discounts', 'exclude_some_products', 10, 4);
function is_product_eligible( $eligible, $product, $discounter_name, $discounter_object ) {
if ($product->ID == 200){
$eligible = false;
}
return $eligible;
}
@woogist
woogist / functions.php
Created October 15, 2015 00:28
Remove the extra 'Quiz' on the single quiz page
add_filter( 'sensei_single_title', 'sensei_dl_custom_double_quiz_remove' );
function sensei_dl_custom_double_quiz_remove( $title ){
if( 'quiz' == get_post_type()
&& 1 < substr_count( strtoupper( $title ), 'QUIZ' ) ){
// remove all possible appearances of quiz
$title_with_no_quizzes = str_replace( 'quiz', '', $title );
$title_with_no_quizzes = str_replace( 'Quiz', '', $title_with_no_quizzes );
@woogist
woogist / gist:4f6f2532758d554075f6
Last active September 25, 2015 15:34
WooCommerce Australia Post: adjust tax rate
add_filter( 'woocommerce_shipping_australia_post_tax_rate' , 'woocommerce_shipping_australia_post_custom_tax_rate' );
/**
* Adjust tax rate
*
* @access public
* @since 1.0
* @return void
*/
function woocommerce_shipping_australia_post_custom_tax_rate() {
@woogist
woogist / gist:95623941598caadba795
Created September 23, 2015 14:32
Ninja forms addon: hide all sub prices
<?php
add_filter( 'wc_nf_addons_cart_option', 'wc_ninja_forms_price' );
function wc_ninja_forms_price( $display ) {
return '';
}
@woogist
woogist / gist:65dcb3ce250104936ab2
Created September 23, 2015 14:31
Ninja Forms hide addon costs equal to zero
<?php
add_filter( 'wc_nf_addons_format_cart_item_price' , 'wc_ninja_forms_hide_zero_price' );
function wc_ninja_forms_hide_zero_price( $value ) {
$hide_price = ' (' . wc_price( '0.00' ) . ')';
if ( $value == $hide_price ) {
return '';
function wcsdp_only_allow_paypal_for_subscriptions( $available_gateways ) {
global $wp;
if ( class_exists( 'WC_Subscriptions_Cart' ) ) {
if ( WC_Subscriptions_Cart::cart_contains_subscription() || WC_Subscriptions_Cart::cart_contains_subscription_renewal() || ( is_checkout_pay_page() && WC_Subscriptions_Order::order_contains_subscription( $wp->query_vars['order-pay'] ) ) ) {
if ( isset( $available_gateways['paypal'] ) ) {
return array( 'paypal' => $available_gateways['paypal'] );
}
}
}
add_action( 'wp', 'custom_hidden_comments' );
function custom_hidden_comments() {
if ( ! is_admin() ) {
$restrictions = wc_memberships()->restrictions;
remove_filter( 'wp', array( $restrictions, 'hide_restricted_content_comments' ) );
}
}
add_filter( 'wp', 'custom_hide_restricted_content_comments' );
function custom_hide_restricted_content_comments( $content ) {
function wc_subscriptions_custom_price_string( $pricestring ) {
$pricestring = str_replace( 'every 3 months', 'per season', $pricestring );
$pricestring = str_replace( 'sign-up fee', 'initial payment', $pricestring );
return $pricestring;
}
add_filter( 'woocommerce_subscriptions_product_price_string', 'wc_subscriptions_custom_price_string' );
add_filter( 'woocommerce_subscription_price_string', 'wc_subscriptions_custom_price_string' );