Skip to content

Instantly share code, notes, and snippets.

View woogist's full-sized avatar

WooCommerce.com Documentation woogist

View GitHub Profile
add_filter( 'wc_session_expiring', create_function( '', 'return 10;' ) );
add_filter( 'wc_session_expiration', create_function( '', 'return 15;' ) );
add_filter( 'wc_photography_shop_loop_image_html', 'wc_photography_loop_image_link' );
function wc_photography_loop_image_link( $html ) {
global $product;
return preg_replace( '/href="([^"]*)"/', sprintf( 'href="%s"', get_permalink( $product->id ) ), $html );
}
add_filter( 'woocommerce_reports_get_order_report_query', 'wc_custom_limit_query' );
function wc_custom_limit_query( $query ) {
global $wpdb;
$wpdb->query( "SET OPTION SQL_BIG_SELECTS=1" );
return $query;
}
// Check the name of your addon field in the source. Example: addon-7934-test-addon
jQuery( 'input[name="addon-90-adventure-dates[check-in]"]' ).datepicker( {
minDate: 0,
"dateFormat": 'yy-mm-dd'
} );
// Check the name of your addon field in the source. Example: addon-7934-test-addon
jQuery( "input[name='addon-90-adventure-dates']" ).datepicker( {
minDate: 0,
"dateFormat": 'yy-mm-dd'
} );
// Check the name of your addon field in the source. Example: addon-7934-test-addon
jQuery( 'input[name="addon-90-adventure-dates[check-in]"]' ).datepicker( {
minDate: 0,
"dateFormat": 'yy-mm-dd'
} );
function jeherve_delete_jetpack_menu() {
if ( ! current_user_can( 'manage_options' ) ) {
remove_menu_page( 'jetpack' );
}
}
add_action ( 'admin_menu', 'jeherve_delete_jetpack_menu', 999 );
add_filter( 'woocommerce_countries_base_postcode', create_function( '', 'return "80903";' ) );
add_filter( 'woocommerce_countries_base_city', create_function( '', 'return "COLORADO SPRINGS";' ) );
add_action( 'subscription_expired', 'wc_custom_remove_subscription', 5, 2 );
function wc_custom_remove_subscription( $user_id, $subscription_key ) {
$subscription = WC_Subscriptions_Manager::get_subscription( $subscription_key );
$valid_ids = array( 100, 101, 102 );
if ( isset( $subscription['product_id'] ) && isset( $subscription['order_id'] ) ) {
$product_id = $subscription['product_id'];
if ( in_array( $product_id, $valid_ids ) ) {
remove_action( 'subscription_expired', array( 'Groups_WS_Handler', 'subscription_expired' ), 10, 2 );
}
add_action( 'subscription_expired', 'wc_custom_remove_subscription', 5, 2 );
function wc_custom_remove_subscription( $user_id, $subscription_key ) {
$subscription = WC_Subscriptions_Manager::get_subscription( $subscription_key );
if ( isset( $subscription['product_id'] ) && isset( $subscription['order_id'] ) ) {
$product_id = $subscription['product_id'];
if ( $product_id == 100 ) {
remove_action( 'subscription_expired', array( 'Groups_WS_Handler', 'subscription_expired' ), 10, 2 );
}
}