Skip to content

Instantly share code, notes, and snippets.

@bryceadams
bryceadams / gist:d6b853049e4b6ddc6365
Last active August 29, 2015 14:20
WooCommerce Drip - Handle subscription / adding custom fields when order set to completed. This does not take into account the user's subscribe selection during checkout, and actually should be used instead of the subscribe checkbox.
add_action( 'woocommerce_order_status_completed', 'drip_subscribe_user_to_campaign', 20, 1 );
add_action( 'woocommerce_order_status_completed', 'drip_add_user_fields', 30, 1 );
function drip_subscribe_user_to_campaign( $order_id ) {
$WC_Drip_Settings = new WC_Drip_Settings();
$wrapper = $WC_Drip_Settings->wrapper();
$order = wc_get_order( $order_id );
$email = $order->billing_email;
@cluppi
cluppi / after.sh
Created March 19, 2015 19:01
Turning SSL on for Homestead
#!/bin/sh
# Config for SSL.
echo "--- Making SSL Directory ---"
mkdir /etc/nginx/ssl
echo "--- Copying $i SSL crt and key ---"
openssl req -nodes -new -x509 -keyout /etc/nginx/ssl/server.key -out /etc/nginx/ssl/server.crt -subj "/C=US/ST=NY/L=NYC/O=Dis/CN=www.example.com"
echo "--- Turning SSL on in nginx.conf. ---"
@honkskillet
honkskillet / byte-sizetuts.md
Last active June 18, 2022 14:18
A series of golang tutorials with youtube videos.
@ChromeOrange
ChromeOrange / gist:9f0870cf034de287bbb4
Created November 14, 2014 07:17
Unset WooCommerce Free Shipping if certain products are in the cart
/**
* Check the cart for specific products, remove Free Shipping method if they are present
*
* Add the code to your theme functions.php file
*/
add_filter( 'woocommerce_package_rates', 'unset_free_shipping_method' , 10, 2 );
function unset_free_shipping_method( $rates, $package ) {
/**
* Setup an array or products
add_filter( 'wc360_image_size', 'wcs_360_image_name' );
function wcs_360_image_name() {
return 'shop_thumbnail';
}
@mathetos
mathetos / image-upload-field-custom-taxonomy
Created September 20, 2014 21:37
Add Image Upload Field to Custom Taxonomy
<?php
/* Add Image Upload to Series Taxonomy */
// Add Upload fields to "Add New Taxonomy" form
function add_series_image_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="series_image"><?php _e( 'Series Image:', 'journey' ); ?></label>
@thenbrent
thenbrent / wcs-remove-zero-recurring.php
Last active August 29, 2015 14:06
Remove $0.00 recurring discount coupon amount
<?php
/*
Plugin Name: WooCommerce Subscriptions Remove $0.00 Recurring Discount
Plugin URI:
Description: Do not include a $0.00 recurring discount amount when a coupon is displaying it. For example, instead of display a coupon discount as "$10.00 now then $0.00 / month", display it as "$10.00".
Author:
Author URI:
Version: 0.1
*/
@claudiosanches
claudiosanches / functions.php
Created September 12, 2014 13:49
WooCommerce 2.2 - Register new order statuses.
<?php
// My new order statuses.
function register_my_new_order_statuses() {
register_post_status( 'wc-status-name', array(
'label' => _x( 'Status Name', 'Order status', 'textdomain' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
@ChaseWiseman
ChaseWiseman / convert-post-meta.php
Last active December 27, 2015 09:50
A function for converting existing WordPress meta keys to new values.
/**
* Convert existing meta keys to new meta keys.
*
* @since x.x.x
*
* @global object $wpdb The current database.
*
* @param string $existing_key The existing meta key.
* @param string $new_key The new meta key.
* @param bool $remove_existing Optional. Whether to remove the old meta entries after conversion.
@claudiosanches
claudiosanches / functions.php
Created July 21, 2014 17:00
WooCommerce - Custom gateway icons
<?php
/**
* Add custom gateway icons
*
* @param string $icon Image HTML.
* @param string $gateway_id Gateway ID.
*
* @return string
*/
function custom_wc_gateway_icons( $icon, $gateway_id ) {