Skip to content

Instantly share code, notes, and snippets.

WooCommerce.com Documentation woogist

Block or report user

Report or block woogist

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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' );
View functions.php
add_action( 'wp', 'custom_hidden_comments' );
function custom_hidden_comments() {
$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 ) {
if ( is_singular() ) {
@woogist
woogist / functions.php
Created Jul 31, 2015
Change the "Add to Cart" text on the single product page based on the product ID
View functions.php
/**
* Change the "Add to Cart" text on the single product page based on the product ID
*
* @param string $text
* @param object $product
* @return string
*/
function wc_custom_single_addtocart_text( $text, $product ) {
$products = array( 1, 2, 3 );
View functions.php
add_filter( 'wc_session_expiring', create_function( '', 'return "2 * 60";' ) );
add_filter( 'wc_session_expiration', create_function( '', 'return "3 * 60";' ) );
View style.css
.wc-bookings-date-picker .ui-datepicker td.ui-datepicker-current-day + td a,
.wc-bookings-date-picker .ui-datepicker td.ui-datepicker-current-day + td + td a,
.wc-bookings-date-picker .ui-datepicker td.ui-datepicker-current-day + td + td + td a,
.wc-bookings-date-picker .ui-datepicker td.ui-datepicker-current-day + td + td + td + td a,
.wc-bookings-date-picker .ui-datepicker td.ui-datepicker-current-day + td + td + td + td + td a,
.wc-bookings-date-picker .ui-datepicker td.ui-datepicker-current-day + td + td + td + td + td + td a {
background-color: #239e57 !important;
}
View functions.php
function eg_do_not_activate_subscription_on_processing(){
remove_action( 'woocommerce_order_status_processing', 'WC_Subscriptions_Manager::activate_subscriptions_for_order' );
remove_action( 'woocommerce_order_status_processing', 'WC_Subscriptions_Order::maybe_record_order_payment' );
}
add_action( 'woocommerce_order_status_processing', 'eg_do_not_activate_subscription_on_processing', 0 ); // run on priority 0 to trigger before Subscriptions
You can’t perform that action at this time.