Skip to content

Instantly share code, notes, and snippets.

@WillBrubaker
WillBrubaker / key.md
Created February 4, 2023 08:23
Twitter (un)official Consumer Key

Twitter Official Consumer Key

Twitter for Android

type:            PIN
Consumer key:    3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPhone

type:            PIN

Consumer key: IQKbtAYlXLripLGPWd0HUA

@WillBrubaker
WillBrubaker / file.php
Last active April 9, 2024 18:44
WooCommerce Colorado Retail Delivery Fee
// 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: bc1q0cwjuxxqqmwnxxc0m2xkkyf4kes9e0gejc9u0l
/**
* Add a .27 surcharge to orders shipping to Colorado
*/
add_action('woocommerce_cart_calculate_fees', 'handsome_bearded_guy_custom_surcharge');
function handsome_bearded_guy_custom_surcharge() {
global $woocommerce;
@WillBrubaker
WillBrubaker / snippet.php
Created September 7, 2021 03:57
Send custom price to WooCommerce Google Listings and Ads
// 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: bc1qc2s60yct2aqza4r7ryweheepd8xa8wqpfgdhg3
/**
* Send Custom Price to WooCommerce Google Listings and Ads
*/
add_filter( 'woocommerce_gla_product_attribute_value_price', 'handsome_bearded_guy_custom_gla_price' );
function handsome_bearded_guy_custom_gla_price( $price ) {
return ( $price * .9 );
}
@WillBrubaker
WillBrubaker / file.php
Created March 29, 2021 04:30
Conditionally hide shipping methods if payment request button is used for payment
// 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: bc1qc2s60yct2aqza4r7ryweheepd8xa8wqpfgdhg3
//hook into wc_ajax_wc_stripe_get_shipping_options
add_action( 'wc_ajax_wc_stripe_get_shipping_options', 'handsome_bearded_guy_filter_shipping_methods' );
function handsome_bearded_guy_filter_shipping_methods() {
//hook into woocommerce_shipping_methods
add_filter( 'woocommerce_shipping_methods', 'handsome_bearded_guy_remove_shipping_methods' );
}
@WillBrubaker
WillBrubaker / file.php
Created March 23, 2021 22:51
use one coupon code for both recurring % discount and sign-up fee % discount for WooCommerce Subscriptions
// 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: bc1qc2s60yct2aqza4r7ryweheepd8xa8wqpfgdhg3
add_filter( 'woocommerce_coupon_get_discount_amount', 'handsome_bearded_guy_coupon_maybe_discount_sign_up_fee_too', 20, 5 );
function handsome_bearded_guy_coupon_maybe_discount_sign_up_fee_too( $discount, $discounting_amount, $item, $single, $coupon ) {
if ( 'recurringandsignupdiscount' === $coupon->get_code() && is_callable( array( 'WC_Subscriptions_Product', 'get_sign_up_fee' ) ) ) {
$discounting_amount = WC_Subscriptions_Product::get_sign_up_fee( $item['data'] );
$discount_percent = $coupon->get_amount() / 100;
$discount = $discounting_amount * $discount_percent;
@WillBrubaker
WillBrubaker / WooTaxSubtotal.txt
Created January 14, 2021 01:53 — forked from fylgjur/WooTaxSubtotal.txt
Apply tax based on subtotal
add_filter( 'woocommerce_product_get_tax_class', 'big_apple_get_tax_class', 1, 2 );
function big_apple_get_tax_class( $tax_class, $product ) {
if ( WC()->cart->subtotal <= 110 )
$tax_class = 'Zero Rate';
return $tax_class;
}
@WillBrubaker
WillBrubaker / file.php
Last active June 17, 2020 01:13
Adds a Jetpack SSO button to enable login with WordPress on the WooCommerce my account page
//not sure what to do with this code snippet? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/
add_action( 'woocommerce_before_customer_login_form', 'handsome_bearded_guy_jetpack_sso' );
function handsome_bearded_guy_jetpack_sso() {
if ( class_exists( 'Jetpack_SSO' ) ) {
add_filter( 'jetpack_remove_login_form', '__return_true' );
Jetpack_SSO::get_instance()->login_form();
remove_filter( 'jetpack_remove_login_form', '__return_true' );
}
}
@WillBrubaker
WillBrubaker / file.php
Last active March 23, 2021 22:44
Override default stock message by product id
//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: bc1qc2s60yct2aqza4r7ryweheepd8xa8wqpfgdhg3
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 March 23, 2021 22:45
Prevent WooCommerce guest checkout from repeat purchase of a particular product
//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: bc1qc2s60yct2aqza4r7ryweheepd8xa8wqpfgdhg3
//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 November 1, 2019 05:35
like a song on spotify
#!/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' );