Skip to content

Instantly share code, notes, and snippets.

View lukecav's full-sized avatar
🪨
Words of GREAT encouragement!

Luke Cavanagh lukecav

🪨
Words of GREAT encouragement!
View GitHub Profile
@lukecav
lukecav / wordpress-varnish3.vcl
Created August 1, 2017 14:21
Varnish VCL for WP and W3 Total Cache
# This is a basic VCL configuration file for varnish. See the vcl(7)
# man page for details on VCL syntax and semantics.
#
# Default backend definition. Set this to point to your content
# server.
#
#
# BACKEND
backend default {
.host = "127.0.0.1";
@lukecav
lukecav / wordpress.vcl
Created August 2, 2017 01:36 — forked from matthewjackowski/wordpress.vcl
Varnish 4 VCL configuration for WordPress. Also allows purging
# A heavily customized VCL to support WordPress
# Some items of note:
# Supports https
# Supports admin cookies for wp-admin
# Caches everything
# Support for custom error html page
vcl 4.0;
import directors;
import std;
@lukecav
lukecav / fake-emails.php
Created September 5, 2017 16:25 — forked from kloon/fake-emails.php
WooCommerce prohibit account creation with fake emails, ie sharklashers.com
<?php
/**
* Do not allow account creation with temp email addresses
* @param Object $validation_errors
* @param string $username
* @param string $email
* @return WP_Error
*/
function do_not_allow_temp_email_addresses( $validation_errors, $username, $email ) {
$prohibitied_domains = array(
/**
* @desc Remove in all product type quantity fields
*/
function wc_remove_all_quantity_fields( $return, $product ) {
return true;
}
add_filter( 'woocommerce_is_sold_individually', 'wc_remove_all_quantity_fields', 10, 2 );
@lukecav
lukecav / functions.php
Last active September 8, 2017 13:27 — forked from claudiosanches/functions.php
WooCommerce - Increase AJAX variation threshold
function custom_wc_ajax_variation_threshold( $qty, $product ) {
return 50;
}
add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2 );
@lukecav
lukecav / woocommerce-custom-cart-item-data.php
Created September 8, 2017 21:13 — forked from RadGH/woocommerce-custom-cart-item-data.php
Get and set custom cart item/product information prior to WooCommerce checkout, and carry those values over to Order Item Metadata.
<?php
// UPDATE: Stefan from Stack Overflow has explained a better way to handle cart item data.
// See http://stackoverflow.com/a/32327810/470480
// ----------------------
/*
Instructions:
@lukecav
lukecav / functions.php
Last active September 22, 2017 14:51 — forked from tommyshellberg/functions.php
Change the WooCommerce Bookings display price to an amount per person
function WC_custom_booking_price( $price, $product ) {
$target_product_types = array(
'booking'
);
if ( in_array ( $product->product_type, $target_product_types ) ) {
// if variable product change price output
$price = '';
$price .= woocommerce_price($product->get_price()) . ' per person';
return $price;
}
@lukecav
lukecav / functions.php
Last active September 22, 2017 14:55 — forked from WillBrubaker/gist.php
Dynamically Change WooCommerce Order Date on Status Change
add_action( 'woocommerce_loaded', 'wc_custom_loaded' );
function wc_custom_loaded() {
$old_statuses = array(
'failed',
//uncomment any of the below statuses to include those statuses
//'pending',
//'processing',
//'on-hold',
//'cancelled',
@lukecav
lukecav / functions.php
Last active September 29, 2017 14:31 — forked from jessepearson/add_bcc_to_certain_emails.php
Add a BCC to certain defined emails sent from WooCommerce
/**
* Function adds a BCC header to emails that match our array
*
* @param string $headers The default headers being used
* @param string $object The email type/object that is being processed
*/
function add_bcc_to_certain_emails( $headers, $object ) {
// email types/objects to add bcc to
$add_bcc_to = array(
@lukecav
lukecav / wcs-product-removed-error-message.php
Created October 20, 2017 15:21 — forked from thenbrent/wcs-product-removed-error-message.php
Display a notice on checkout when a product was removed from the cart after a subscription was added.
<?php
/**
* Plugin Name: WooCommerce Subscriptions Product Removed Message
* Description: Display a notice on checkout when a product was removed from the cart after a subscription was added.
* Author: Gerhard Potgieter & Brent Shepherd
* Author URI:
* Version: 1.1
* License: GPL v2
*/