Skip to content

Instantly share code, notes, and snippets.

Avatar

WooCommerce.com Documentation woogist

View GitHub Profile
@woogist
woogist / functions.php
Created Oct 26, 2016
Dynamic Pricing - Product Ineligible for Discounts
View functions.php
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 Oct 15, 2015
Remove the extra 'Quiz' on the single quiz page
View functions.php
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 Sep 25, 2015
WooCommerce Australia Post: adjust tax rate
View gist:4f6f2532758d554075f6
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 Sep 23, 2015
Ninja forms addon: hide all sub prices
View gist:95623941598caadba795
<?php
add_filter( 'wc_nf_addons_cart_option', 'wc_ninja_forms_price' );
function wc_ninja_forms_price( $display ) {
return '';
}
@woogist
woogist / gist:65dcb3ce250104936ab2
Created Sep 23, 2015
Ninja Forms hide addon costs equal to zero
View gist:65dcb3ce250104936ab2
<?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 '';
View functions.php
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'] );
}
}
}
View functions.php
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 ) {
View functions.php
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' );
View functions.php
function wc_subscriptions_custom_price_string( $pricestring ) {
global $product;
$products_to_change = array( 45, 90, 238 );
if ( in_array( $product->id, $products_to_change ) ) {
$pricestring = str_replace( 'every 3 months', 'per season', $pricestring );
}
return $pricestring;
View functions.php
function wc_subscriptions_custom_price_string( $pricestring ) {
$newprice = str_replace( 'every 3 months', 'per season', $pricestring );
return $newprice;
}
add_filter( 'woocommerce_subscriptions_product_price_string', 'wc_subscriptions_custom_price_string' );
add_filter( 'woocommerce_subscription_price_string', 'wc_subscriptions_custom_price_string' );