Skip to content

Instantly share code, notes, and snippets.

Will Brubaker WillBrubaker

Block or report user

Report or block WillBrubaker

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
@WillBrubaker
WillBrubaker / file.php
Created Apr 30, 2020
Override default stock message by product id
View file.php
//not sure what to do with this code snippet? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/
//BTC Donations to: 1C1Prwo4PmKhpoh1He2HG61eX78gu9v3kY
add_filter( 'woocommerce_get_availability_text', 'handsome_bearded_guy_availability_text', 10, 2 );
function handsome_bearded_guy_availability_text( $availability, $product ) {
$oos_replacement_messages = array(//the product id is the array key and the value is the replacement message
3871 => 'Here on Thursday',
3870 => 'on back order',
);
@WillBrubaker
WillBrubaker / file.php
Last active Feb 14, 2020
Prevent WooCommerce guest checkout from repeat purchase of a particular product
View file.php
//not sure what to do with this code snippet? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/
//BTC Donations to: 1C1Prwo4PmKhpoh1He2HG61eX78gu9v3kY
//Hook into the after checkout validation action, add a callback function named 'validate_no_repeat_purchase' with a priority of 10 and pass two arguments.
add_action( 'woocommerce_after_checkout_validation', 'validate_no_repeat_purchase', 10, 2 );
//The callback function accepts the array of posted checkout data and an array of errors
function validate_no_repeat_purchase( $data, $errors ) {
//extract the posted 'billing_email' and use that as an argument for querying orders.
@WillBrubaker
WillBrubaker / song-liker.js
Created Nov 1, 2019
like a song on spotify
View song-liker.js
#!/usr/local/bin/node
//https://www.thathandsomebeardedguy.com/i'd-love-to-❤️-you-more
var args = process.argv.slice( 2 )[ 2 ];
var trackId;
songURI = args.match( '^.*track:([a-zA-Z0-9]+)' )[ 1 ];
//npm install fs
var fs = require( "fs" );
var file = "token.txt";
//npm install scp
var scp = require( 'scp' );
View token-refresher.js
//https://www.thathandsomebeardedguy.com/i'd-love-to-❤️-you-more
var credentials = {
clientId: 'someclientid',
clientSecret: 'someclientsecret',
redirectUri: 'http://localhost:8888/callback'
};
//npm install spotify-web-api-node --save
var SpotifyWebApi = require('spotify-web-api-node');
var spotifyApi = new SpotifyWebApi(credentials);
//npm install fs
@WillBrubaker
WillBrubaker / file.php
Created Jul 12, 2019
Prevent adding the tax rate to WooCommerce Xero tax label
View file.php
//not sure what to do with this code snippet? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/
add_filter( 'woocommerce_xero_create_unique_tax_label', '__return_false' );
@WillBrubaker
WillBrubaker / file.php
Created Jun 12, 2019
Default to checked "Update the Billing Address used for all of my active subscriptions (optional)" - WooCommerce Subscriptions
View file.php
//not sure what to do with this code snippet? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/
add_filter( 'wcs_update_all_subscriptions_addresses_checked', '__return_true' );
@WillBrubaker
WillBrubaker / file.php
Created Dec 19, 2018
WooCommerce default variation manage stock checked
View file.php
//not sure what to do with this code snippet? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/
if ( is_admin() ) {
add_filter( 'woocommerce_product_variation_get_manage_stock', '__return_true' );
}
@WillBrubaker
WillBrubaker / file.php
Created Dec 16, 2018
Remove 'via WooCommerce' from Stripe Payment Request
View file.php
//not sure what to do with this code snippet? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/
add_filter( 'wc_stripe_payment_request_total_label_suffix', '__return_empty_string' );
@WillBrubaker
WillBrubaker / file.php
Created Dec 12, 2018
WooCommerce redirect to cart if trying to add a 'sold individually' item that is already in the cart
View file.php
//not sure what to do with this code snippet? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/
add_filter( 'woocommerce_add_to_cart_sold_individually_found_in_cart', 'handsome_bearded_guy_maybe_redirect_to_cart' );
function handsome_bearded_guy_maybe_redirect_to_cart( $found_in_cart ) {
if ( $found_in_cart ) {
wp_safe_redirect( wc_get_page_permalink( 'cart' ) );
exit;
}
@WillBrubaker
WillBrubaker / file.php
Last active Dec 12, 2018
WooCommerce Stripe data-locale="auto"
View file.php
//not sure what to do with this code snippet? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/
add_filter( 'wc_stripe_checkout_locale', 'handsome_bearded_guy_stripe_checkout_locale' );
function handsome_bearded_guy_stripe_checkout_locale() {
return 'auto';
}
You can’t perform that action at this time.