Skip to content

Instantly share code, notes, and snippets.

@mrcave
mrcave / clear_cache_when_stock_changes.php
Last active October 25, 2023 12:12
Clear NGINX page cache when WooCommerce product inventory levels are changed (only tested on GridPane with Redis page caching enabled)
//clear entire cache when stock is reduced or replenished
function clear_cache_when_stock_changes( $order ) {
if(class_exists('PhpRedis_Purger') || class_exists('Predis_Purger')){
global $nginx_purger;
$nginx_purger->purge_all();
}
}
@MurtzaM
MurtzaM / preventNonBusinessEmailSubmission.js
Created September 9, 2014 23:49
This script will prevent Marketo form submission if a user enters a non-business email (Gmail, Hotmail, etc.)
//This script prevents Marketo form submission if a user enters non-business email (Gmail, Hotmail, Yahoo, etc.)
//It will work on any page with a Marketo form, and runs when the form is ready
//For further info, please see Marketo form documentation, http://developers.marketo.com/documentation/websites/forms-2-0/
//Prepared by Ian Taylor and Murtza Manzur on 9/9/2014
<script>
(function (){
// Please include the email domains you would like to block in this list
var invalidDomains = ["@gmail.","@yahoo.","@hotmail.","@live.","@aol.","@outlook."];
@thenbrent
thenbrent / extend-subscription-intervals.php
Last active May 14, 2024 21:04
Add a new billing interval to WooCommerce Subscriptions. Specifically a "every 10 weeks" billing interval to selling a subscription to something and be charged every 10 weeks.
<?php
/**
* Plugin Name: Extend WooCommerce Subscription Intervals
* Description: Add a "every 10 weeks" billing interval to WooCommerce Subscriptions
* Author: Brent Shepherd
* Author URI: http://brent.io
* Version: 1.0
* License: GPL v2
*/
@carwin
carwin / weathergist.php
Created September 6, 2012 01:46
PHP: Use Yahoo's Weather API, cURL, and SimpleXML to get current weather conditions given a WOEID.
<?php
/*
* This gist utilizes Yahoo's Weather API to snag the current
* weather conditions for any country given it's WOEID.
*
* - by Carwin Young
*/
/* Set up some location WOEIDs */
$Cambodia = 1020985; /* Phnom Pneh */