Skip to content

Instantly share code, notes, and snippets.

@michaelgiles
michaelgiles / gist:af2d570d9e7932541c3f
Created October 13, 2014 18:39
AWS Bucket Policy - Open
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"AddPerm",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::example.com/*"
]
}
@michaelgiles
michaelgiles / gist:4c8cccad760af6f9816a
Created October 22, 2014 18:42
Jquery Randomize Array
$.extend({
shuffleArray: function(array) {
var currentIndex = array.length, temporaryValue, randomIndex ;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
@michaelgiles
michaelgiles / gist:885ce5f53933bb89d778
Created October 22, 2014 23:37
Email verification for Google
// Get email/domain
var email = r.email;
var domain = email.replace(/.*@/, "");
var result = domain.toLowerCase();
// If using 72 email
if (result === '72andsunny.com' ){
// console.log('72 email verified');
@michaelgiles
michaelgiles / gist:aab9b755354340ed0e53
Created February 18, 2015 22:40
S3 Bucket Policy - Public
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::72-whoswho-production/*"
}
add_action( 'woocommerce_before_cart', 'apply_matched_coupons' );
function apply_matched_coupons() {
global $woocommerce;
$get1 = 'getonech'; // your coupon code here
$get2 = 'gettwoch'; // your coupon code here
$get3 = 'getthreech'; // your coupon code here
$get4 = 'getfourch'; // your coupon code here
$get5 = 'getfivech'; // your coupon code here
@michaelgiles
michaelgiles / coupon_code.php
Created April 13, 2015 23:41
Woocommerce Apply Coupon Code Automatically
/* Mod: 10% Discount for weight greater than 100 lbs
Works with code added to child theme: woocommerce/cart/cart.php lines 13 - 14: which gets $total_weight of cart:
global $total_weight;
$total_weight = $woocommerce->cart->cart_contents_weight;
*/
add_action('woocommerce_before_cart_table', 'discount_when_weight_greater_than_100');
function discount_when_weight_greater_than_100( ) {
global $woocommerce;
global $total_weight;
if( $total_weight > 100 ) {
@michaelgiles
michaelgiles / another-coupon-code-snippet.php
Created April 13, 2015 23:43
Woo Another Coupon Code Snippet
add_action( 'woocommerce_before_cart', 'apply_matched_coupons' );
function apply_matched_coupons() {
global $woocommerce;
$coupon_code = '10percent'; // your coupon code here
if ( $woocommerce->cart->has_discount( $coupon_code ) ) return;
if ( $woocommerce->cart->cart_contents_total >= 500 ) {
<?php
/**
* Loop Add to Cart -- with quantity and AJAX
* requires associated JavaScript file qty-add-to-cart.js
*
* @ref: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
* @ref: https://gist.github.com/mikejolley/2793710/
*/
// add this file to folder "woocommerce/loop" inside theme
@michaelgiles
michaelgiles / hide-coupon.php
Created April 14, 2015 00:08
Woocommere Hide Coupon Amount when applied
add_filter( 'woocommerce_cart_totals_coupon_label', 'skyverge_change_coupon_label' );
function skyverge_change_coupon_label() {
echo 'Discount Applied';
}
@michaelgiles
michaelgiles / gist:f822fd2d664a11daf91c
Created June 23, 2015 08:22
Fade in elements in sequence
$('#foo').each(function(i, val){
setTimeout(function(){
$(val).animate({
'opacity': 1,
'top':0,
'duration':0.5
});
},i++ * 100);
});