Skip to content

Instantly share code, notes, and snippets.

@WillBrubaker
WillBrubaker / token-refresher.js
Last active November 1, 2019 05:45
token refresher
//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 July 12, 2019 00:49
Prevent adding the tax rate to WooCommerce Xero tax label
//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 June 12, 2019 22:44
Default to checked "Update the Billing Address used for all of my active subscriptions (optional)" - WooCommerce Subscriptions
//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 December 19, 2018 18:30
WooCommerce default variation manage stock checked
//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 December 16, 2018 11:48
Remove 'via WooCommerce' from Stripe Payment Request
//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 December 12, 2018 11:35
WooCommerce redirect to cart if trying to add a 'sold individually' item that is already in the cart
//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 December 12, 2018 11:19
WooCommerce Stripe data-locale="auto"
//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';
}
@WillBrubaker
WillBrubaker / file.php
Created December 6, 2018 14:19
Remove add to cart button from products that do not have stock
//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_loop_add_to_cart_link', 'handsome_bearded_guy_maybe_remove_add_to_cart_button' );
function handsome_bearded_guy_maybe_remove_add_to_cart_button( $html ) {
global $product;
if ( 'simple' === $product->get_type() && ! $product->get_stock_quantity() ) {
return null;
}
return $html;
}
@WillBrubaker
WillBrubaker / file.php
Last active February 6, 2021 07:35
Add UAE Emirates to WooCommerce
//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_states', 'add_uae_emirates' );
function add_uae_emirates( $states ) {
$states['AE'] = array(
'AZ' => __( 'Abu Dhabi', 'woocommerce' ),
'AJ' => __( 'Ajman', 'woocommerce' ),
'FU' => __( 'Fujairah', 'woocommerce' ),
'SH' => __( 'Sharjah', 'woocommerce' ),
'DU' => __( 'Dubai', 'woocommerce' ),
@WillBrubaker
WillBrubaker / oncefiller.user.js
Last active June 27, 2018 11:47 — forked from corsonr/oncefiller.user.js
A8C - Once key field auto-filler
// ==UserScript==
// @name A8C - Once key field auto-filler
// @namespace http://automattic.com/
// @version 0.1
// @description Pre-fill Once fields
// @author Remi Corson
// @match https://mc.a8c.com/once/*
// @require http://code.jquery.com/jquery-latest.js
// @grant none
// ==/UserScript==