Skip to content

Instantly share code, notes, and snippets.

View BurlesonBrad's full-sized avatar
🎯
Focusing

Brad Griffin BurlesonBrad

🎯
Focusing
View GitHub Profile
@BurlesonBrad
BurlesonBrad / DNS Prefetching
Created July 15, 2015 21:47
DNS Prefetching
/*
* Let's see if I can do dns prefetching correctly
*/
add_action('wp_head', 'dns_prefetch');
function dns_prefetch() {
echo '<link rel="dns-prefetch" href="//fonts.gstatic.com" />';
echo '<link rel="dns-prefetch" href="//google-analytics.com" />';
echo '<link rel="dns-prefetch" href="//google.com" />';
echo '<link rel="dns-prefetch" href="//stats.g.doubleclick.net" />';
@BurlesonBrad
BurlesonBrad / Here 'ya go
Created July 16, 2015 18:08
For WarFarePlugins
/**
* Redirect user to checkout page directly after adding to cart
*
* @return string
*/
function wc_redirect_to_checkout() {
$checkout_url = WC()->cart->get_checkout_url();
return $checkout_url;
}
@BurlesonBrad
BurlesonBrad / functions.php
Last active October 16, 2016 22:34
Yvan's functions.php file for the child theme
<?php
/**
* Yvan's child theme functions.php file. You can "move" this child function.php into ANY (<---pretty cool, right?) child theme that you want.
*
* @package storefront-child
*/
// DO NOT REMOVE THIS FUNCTION AS IT LOADS THE PARENT THEME STYLESHEET
add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
function enqueue_parent_theme_style() {
// Custom CSS to change Variation Dropdown //
.woocommerce div.product form.cart .variations select {
width: 190px;
float: left;
background: -webkit-linear-gradient(top, rgb(255, 255, 255) 0%,rgb(194, 204, 228) 100%);
border-radius: 5px;
border: 1px solid rgba(0,0,0,0.3);
box-shadow: 0 0 5px 1px rgba(0,0,0,0.2), inset 0 1px 0 0px rgba(255,255,255,0.3);
margin: 50px;
}
@BurlesonBrad
BurlesonBrad / Two Emails for Low Stock
Created August 30, 2015 02:37
Two Emails for Low Stock
<?php
function woo_extra_email_recipient($recipient, $object) {
$recipient = $recipient . ', your@email.com';
return $recipient;
}
add_filter( 'woocommerce_low_stock', 'woo_extra_email_recipient', 10, 2);
@BurlesonBrad
BurlesonBrad / Sensei Points
Last active October 10, 2015 19:17
Attempt to connect Completing a Sensei LESSON to points and rewards
<?php
// THIS IS THE FILE FROM https://gist.github.com/woogist/5692886#file-gistfile1-php//
// ...and, believe it or not, I understand about 50% of this.//
// While that's better than the average Joe, it' still not enough to actually CONNECT the points //
// Anyone want to jump in here? //
// Add the action setting
add_filter( 'wc_points_rewards_action_settings', 'bkg_sensei_points' );
function points_rewards_newsletter_action_settings( $settings ) {
@BurlesonBrad
BurlesonBrad / Add To Cart Text
Created September 16, 2015 15:26
Add to Cart Text
<?php
//=======================================================
// Custom Add to Cart Buttons
//=======================================================
// Display Fields
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
// Save Fields
add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' );
@BurlesonBrad
BurlesonBrad / custom-add-to-cart-button
Created September 16, 2015 15:32
Add To Cart Button | Text Field in General Tab | Appears on Single Product Page
<?php
//=======================================================
// Custom Add to Cart Buttons
//=======================================================
// Display Fields
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
// Save Fields
add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' );
@BurlesonBrad
BurlesonBrad / postcode_shipping.php
Created September 23, 2015 02:06 — forked from KZeni/postcode_shipping.php
Updated Postcode Shipping plugin for WordPress that supports Shipping Multiple Addresses in one cart.
<?php
/**
* Plugin Name: Postcode Shipping
* Description: This plugin allows you to set a flat shipping rate per country or state or postcode per Quantity/Order on WooCommerce.
* Version: 2.1.2
@BurlesonBrad
BurlesonBrad / modification
Created September 27, 2015 23:35
GOAL = Remove flat rate when quantity is OVER 12
add_filter('woocommerce_available_shipping_methods','remove_flat_over_twelve',10,1);
function remove_flat_over_twelve( $available_methods ) {
global $woocommerce;
$minimum_flat_rate_quantity = 12;
if ( $woocommerce->cart->get_cart_contents_count() >= $minimum_flat_rate_quantity ) {
// remove flat_rate shipping
unset($available_methods['flat_rate']);
}
return $available_methods;