Skip to content

Instantly share code, notes, and snippets.

View BFTrick's full-sized avatar

Patrick Rauland BFTrick

View GitHub Profile
@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 / 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 / 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 / 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 / woocommerce-patricks-disable-freight.php
Last active August 29, 2015 14:01
Disable Freight Table Rate Shipping Costs for BR
<?php
/**
* Plugin Name: WooCommerce Disable Freight when UPS Rates are Present
* Plugin URI: https://gist.github.com/BFTrick/34e8b82d068ac7e15886
* Description: A simple plugin that disables the freight Table Rate Shipping methods when UPS rates are available. It leaves the Local Delivery TRS methods.
* 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 / find-user-meta-box-order.sql
Last active August 29, 2015 14:01
Find users meta box order in the WordPress admin
SELECT *
FROM `wp_usermeta`
WHERE `meta_key` LIKE 'meta-box%'
@BFTrick
BFTrick / delete-user-meta-box-order-by-post-type.sql
Created May 20, 2014 16:20
Delete users meta box custom order for the product post type in the WordPress admin
DELETE
FROM `wp_usermeta`
WHERE `meta_key` = 'meta-box-order_product'
@BFTrick
BFTrick / wc-settings-tab.php
Last active August 29, 2015 14:03
Adds a new WooCommerce Settings Tab
<?php
class WC_Settings_Tab_Demo {
public static function init() {
add_filter( 'woocommerce_settings_tabs_array', __CLASS__ . '::add_settings_tab', 50 );
}
public static function add_settings_tab( $settings_tabs ) {
$settings_tabs['settings_tab_demo'] = __( 'Settings Demo Tab', 'woocommerce-settings-tab-demo' );
return $settings_tabs;
@BFTrick
BFTrick / woocommerce-save-settings-tab-settings.php
Created July 12, 2014 02:57
Functions to Save Settings on a WooCommerce Settings Tab
<?php
add_action( 'woocommerce_update_options_settings_tab_demo', 'update_settings' );
function update_settings() {
woocommerce_update_options( get_settings() );
}
@BFTrick
BFTrick / wc-format-decimal-tester.php
Created July 28, 2014 21:13
Format the decimals according to wc_format_decimal()
<?php
/**
* Plugin Name: WooCommerce Format Decimal Tester
* Plugin URI: https://gist.github.com/BFTrick/02653b97fc3351fc3606
* Description: Test the wc_format_decimal() function.
* Author: Patrick Rauland
* Author URI: http://speakinginbytes.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify