Skip to content

Instantly share code, notes, and snippets.

@WillBrubaker
WillBrubaker / gist:dc691d9df80aa63fc9ac
Created May 28, 2015 10:22
Change the WooCommerce Bookings "Persons" label to something else
add_filter( 'booking_form_fields', 'wooninja_booking_form_fields' );
function wooninja_booking_form_fields( $fields ) {
$fields['wc_bookings_field_persons']['label'] = 'SOMETHING ELSE';
return $fields;
}
@WillBrubaker
WillBrubaker / gist:448c55887c7a92624b4f
Created June 1, 2015 02:40
Allow WooCommerce users to access their profile and the WordPress dashboard
add_filter( 'woocommerce_prevent_admin_access', '__return_false' );
@WillBrubaker
WillBrubaker / gist:4d9f1cd122513e9eb0bc
Created June 3, 2015 03:37
Restrict WooCommerce order notes field to a number of characters
add_filter( 'woocommerce_checkout_fields', 'filter_checkout_fields' );
function filter_checkout_fields( $fields ) {
$fields['order']['order_comments']['maxlength'] = 200;
return $fields;
}
@WillBrubaker
WillBrubaker / gist:0fef5891ce92a551538f
Created June 9, 2015 17:05
Localize WooCommerce Bookings Date Format
/**
* See Documentation on Date/Time formatting here:
* https://codex.wordpress.org/Formatting_Date_and_Time
*/
add_filter( 'woocommerce_bookings_time_format', 'localize_bookings_time_format' );
function localize_bookings_time_format( $format ) {
return get_option( 'time_format', $format );
}
@WillBrubaker
WillBrubaker / gist:0e66c7a53cfcfecb16bd
Created June 10, 2015 13:17
Change WooCommerce Subscriptions "Change Payment Method" text
add_filter( 'woocommerce_change_payment_button_text', 'wooninja_change_payment_button_text' );
function wooninja_change_payment_button_text() {
return 'MY BUTTON TEXT';
}
add_filter( 'woocommerce_my_account_my_subscriptions_actions', 'wooninja_filter_subscriptions_actions', 99 );
function wooninja_filter_subscriptions_actions( $actions ) {
foreach ( $actions as $key => $value ) {
@WillBrubaker
WillBrubaker / gist:509ea81f636132e03feb
Created June 12, 2015 12:02
Increase WooCommerce product prices by 20%
add_filter( 'woocommerce_get_price', 'wooninja_price_increase' );
function wooninja_price_increase( $price ) {
return $price + ( $price * .2 );
}
@WillBrubaker
WillBrubaker / css-snippet.css
Last active February 13, 2017 22:23
Allow Variable Selection on the Shop Page - WooCommerce
li.product-type-variable td {
float: left;
}
#main li.product input {
float: none;
}
@WillBrubaker
WillBrubaker / content-product.php
Last active August 29, 2015 14:23
Add Quantity Inputs to Simple Products on the WooCommerce Shop Page
<?php
/**
* The template for displaying product content within loops.
*
* Override this template by copying it to yourtheme/woocommerce/content-product.php
* Adapted from work originally authored by WooThemes
* @license [<http://fsf.org/>] [GPL 3]
* @version 1.6.4
*/
@WillBrubaker
WillBrubaker / gist:a44d620be7c0795b928c
Last active March 13, 2018 09:41
Add Quantity Input to the WooCommerce Shop Page (simple products only) Without A Template Override
add_action( 'woocommerce_before_shop_loop_item', 'beardedguy_add_quantity_input' );
function beardedguy_add_quantity_input() {
global $product;
$product_type = ( version_compare( WC_VERSION, '3.0', '<' ) ) ? $product->product_type : $product->get_type();
if ( 'simple' == $product_type ) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_single_add_to_cart', 10 );
} else {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_single_add_to_cart', 10 );
@WillBrubaker
WillBrubaker / gist:16aed85339534dc98bad
Created June 16, 2015 23:19
Force Resource Selection for WooCommerce Bookings Resources
add_filter( 'booking_form_fields', 'handsomebeardedguy_booking_form_fields' );
function handsomebeardedguy_booking_form_fields( $fields ) {
if ( isset( $fields['wc_bookings_field_resource'] ) ) {
$fields['wc_bookings_field_resource']['options'][0] = 'Make a selection...';
ksort( $fields['wc_bookings_field_resource']['options'] );
}
return $fields;
}