Skip to content

Instantly share code, notes, and snippets.

View BurlesonBrad's full-sized avatar
🎯
Focusing

Brad Griffin BurlesonBrad

🎯
Focusing
View GitHub Profile
<?php
// Add Variation Settings
add_action( 'woocommerce_product_after_variable_attributes', 'variation_settings_fields', 10, 3 );
// Save Variation Settings
add_action( 'woocommerce_save_product_variation', 'save_variation_settings_fields', 10, 2 );
/**
* Create new fields for variations
@BurlesonBrad
BurlesonBrad / Cristina:Only show products from within the current category.
Created November 20, 2015 15:20
Cristina:Only show products from within the current category.
//Christina's function for showing ONLY related items in the SAME category//
// Christina, drop this into your CHILD functions.php file //
function get_related_custom( $id, $limit = 5 ) {
global $woocommerce;
$cats_array = array(0);
$terms = wp_get_post_terms($id, 'product_cat');
foreach ( $terms as $term ) $cats_array[] = $term->term_id;
add_filter( 'woocommerce_add_cart_item_data', 'rodolpho_is_a_sexy_beast_empty_cart', 10, 3);
function rodolpho_is_a_sexy_beast_empty_cart( $cart_item_data, $product_id, $variation_id )
{
global $woocommerce;
if ( $product_id == 851 ) {
$woocommerce->cart->empty_cart();
}
return $cart_item_data;
}
@BurlesonBrad
BurlesonBrad / big-fux-bug-fix.php
Created December 13, 2015 22:08
lines 1931 - 1936 in Woo 2.5 beta
public function email_order_items_table( $args = array(), $deprecated1 = null, $deprecated2 = null, $deprecated3 = null, $deprecated4 = null, $deprecated5 = null ) {
ob_start();
if ( ! is_null( $deprecated1 ) || ! is_null( $deprecated2 ) || ! is_null( $deprecated3 ) || ! is_null( $deprecated4 ) || ! is_null( $deprecated5 ) ) {
_deprecated_argument( __FUNCTION__, '2.5.0' );
}
@BurlesonBrad
BurlesonBrad / functions.php
Created December 28, 2015 04:42
For Darryn
/* Use a custom image for PayPal on WooCommerce checkout page. */
/* Be sure to change line 6 to point to your new image */
function my_new_paypal_icon() {
// picture of accepted credit card icons for PayPal payments
return get_stylesheet_directory_uri() . 'somefolder/images/your-new-image.jpg';
}
add_filter( 'woocommerce_paypal_icon', 'my_new_paypal_icon' );
@BurlesonBrad
BurlesonBrad / clayton.php
Last active December 31, 2015 16:57
Remove WooCommerce Sidebars ONLY on Product Pages
/* Clayton, you MUST add the code below to your CHILD THEME's functions.php file. */
/* This will remove the sidebar on the product page */
/* BEGIN No sidebar */
function clayton_has_no_more_sidebar() {
if( is_product() )
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
}
add_action( 'template_redirect', 'clayton_has_no_more_sidebar' );
/* End No sidebar */
@BurlesonBrad
BurlesonBrad / jonathans-speed.php
Last active January 6, 2016 05:42
for Jonathan
<?php
/**
* Plugin Name: Jonathan's Speed Plugin
* Plugin URI: https://bradgriffin.me
* Description:
* Version: 1
* Author: Brad
* Author URI: https://bradgriffin.me
* Requires at least: 4.5
* Tested up to: 4.5
@BurlesonBrad
BurlesonBrad / text-changes.php
Last active January 14, 2016 14:36
For Nikki ~ Change Text in WooCommerce
<?php
/**
* Plugin Name: Nikki Gets to Change Her Text
* Plugin URI: https://bradgriffin.me
* Description:
* Version: 1
* Author: Brad
* Author URI: https://bradgriffin.me
* Requires at least: 4.5
* Tested up to: 4.5
@BurlesonBrad
BurlesonBrad / .htaccess
Last active January 14, 2016 19:22
For Jason: stop traffic to the mirror from accessing the site?
# Jason: First, open this image --> http://i.imgur.com/i7METNn.png #
# Now, assuming that there is already an .htaccess file in place, simply add the code below to that file #
AuthUserFile .htpasswd
AuthName "Staged Login Area"
AuthType Basic
require user dave
@BurlesonBrad
BurlesonBrad / errorlog
Last active January 21, 2016 18:03
jason
[14-Jan-2016 20:47:29 UTC] PHP Fatal error: Uncaught TypeError: Argument 1 passed to Prompt_Wp_Mailer::__construct() must be an instance of Prompt_Interface_Http_Client, instance of Prompt_Comment_Email_Batch given, called in /home/bradgrif/public_html/wp-content/plugins/postmatic/core/mailers/comment-wp-mailer.php on line 25 and defined in /home/bradgrif/public_html/wp-content/plugins/postmatic/core/wp-mailer.php:10
Stack trace:
#0 /home/bradgrif/public_html/wp-content/plugins/postmatic/core/mailers/comment-wp-mailer.php(25): Prompt_Wp_Mailer->__construct(Object(Prompt_Comment_Email_Batch), NULL, NULL, 0)
#1 /home/bradgrif/public_html/wp-content/plugins/postmatic/core/factory.php(92): Prompt_Comment_Wp_Mailer->__construct(Object(Prompt_Comment_Email_Batch))
#2 /home/bradgrif/public_html/wp-content/plugins/postmatic/core/factory.php(26): Prompt_Factory::make_local_mailer(Object(Prompt_Comment_Email_Batch), '')
#3 /home/bradgrif/public_html/wp-content/plugins/postmatic/core/comment-mailing.php(26): Prompt_Fac