Skip to content

Instantly share code, notes, and snippets.

View BFTrick's full-sized avatar

Patrick Rauland BFTrick

View GitHub Profile
@BFTrick
BFTrick / woocommerce-disable-table-rate-shipping-when-ups-rates-present.php
Last active August 29, 2015 14:01
WooCommerce Disable Table Rate Shipping when UPS Rates are Present
<?php
/**
* Plugin Name: WooCommerce Disable Table Rate Shipping when UPS Rates are Present
* Plugin URI: https://gist.github.com/BFTrick/ab2841ca0daaca413379/
* Description: A simple plugin that disables the Table Rate Shipping methods when UPS rates are available.
* Author: Patrick Rauland
* Author URI: http://patrickrauland.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
@BFTrick
BFTrick / doge-home-page.php
Last active August 29, 2015 14:01
Doge Home Page WordPress Plugin
<?php
/**
* Plugin Name: Doge Home Page
* Plugin URI: https://gist.github.com/BFTrick/e73cfa53cf64182d02ae
* Description: Dogeify the front page of your site
* Author: Patrick Rauland
* Author URI: http://patrickrauland.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
@BFTrick
BFTrick / install-wp.sh
Last active March 18, 2026 07:20
Download & Install WordPress via Curl
curl -O https://wordpress.org/latest.zip
unzip latest.zip
mv wordpress site
rm latest.zip
@BFTrick
BFTrick / woocommerce-display-country-code-in-currency.php
Last active December 14, 2023 00:01
Display the currency symbol with the currency code first
<?php
/**
* Plugin Name: WooCommerce Display Currency Code in Currency Symbol
* Plugin URI: https://gist.github.com/BFTrick/10681832
* Description: Add the currency code to the currency symbol in WooCommerce. Ex. USD $.
* Author: Patrick Rauland
* Author URI: http://patrickrauland.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
@BFTrick
BFTrick / wc-get-products-weight.php
Created March 29, 2014 18:44
This little snippet works when you have an array of packages and you want to get the weight of individual packages in WooCommerce. Usually used in the calculate shipping method. http://docs.woothemes.com/document/shipping-method-api/
<?php
foreach ( $package['contents'] as $item_id => $values ) {
// skip products that dont need shipping
if ( $values['data']->needs_shipping() ) {
// make sure a weight is set
if ( $values['data']->get_weight() ) {
$item_weight = $values['data']->get_weight();
// do something with the weight here
// ...
@BFTrick
BFTrick / shopping-redirect.php
Last active June 21, 2019 21:40
Change the Continue Shopping link on the WooCommerce Cart page
<?php
/**
* Return the permalink of the shop page for the continue shopping redirect filter
*
* @param string $return_to
* @return string
*/
function my_woocommerce_continue_shopping_redirect( $return_to ) {
return get_permalink( wc_get_page_id( 'shop' ) );
}
@BFTrick
BFTrick / publish-woocommerce-coupons
Created February 21, 2014 14:43
Publish all WooCommerce coupons.
UPDATE wp_posts
SET post_status="publish"
WHERE post_type="shop_coupon"
@BFTrick
BFTrick / cancel-subscription-hook.php
Last active May 9, 2016 05:04
Hooking into the cancelled subscription hook.
<?php
/*
Plugin Name: Cancelled Subscriptions Hook
Plugin URI: https://gist.github.com/BFTrick/8696222
Description: Hook into the WooCommerce Cancelled Subscriptions hook and print the data.
Version: 1.0.0
Author: Patrick Rauland
Author URI: http://www.patrickrauland.com
*/
@BFTrick
BFTrick / ninja-forms-get-ua-fields.php
Created January 10, 2014 14:55
Get the fields from the User Analytics Ninja Forms extension
<?php
/*
Plugin Name: Ninja Forms - Get User Analytics Fields
Plugin URI: https://gist.github.com/BFTrick/8355697
Description: Get the fields from the User Analytics Ninja Forms extension
Version: 1.0.0
Author: Patrick Rauland
Author URI: http://www.patrickrauland.com
*/
@BFTrick
BFTrick / ninja-forms-hide-unchecked-fields.php
Created December 30, 2013 03:35
Hide all unchecked frields in emails.
<?php
function my_ninja_forms_hide_unchecked( ) {
global $ninja_forms_processing;
// get all the user submitted values
$all_fields = $ninja_forms_processing->get_all_fields();
if ( is_array( $all_fields ) ) {
// loop through each of our submitted values.
foreach ( $all_fields as $key => $value ) {