Skip to content

Instantly share code, notes, and snippets.

View monecchi's full-sized avatar

Adriano Monecchi monecchi

View GitHub Profile
@monecchi
monecchi / wiredep.js
Created April 21, 2016 09:44 — forked from tjFogarty/wiredep.js
Gulp + Wiredep + Timber + Twig
var gulp = require('gulp');
var config = require('../config');
var wiredep = require('wiredep').stream;
gulp.task('wiredep', function () {
gulp.src(config.wiredep_file)
.pipe(wiredep({
directory: 'assets/lib',
ignorePath: '..',
fileTypes: {
@monecchi
monecchi / gist:6391d0e011f33e1087b4eeda60344238
Created April 19, 2016 10:48 — forked from thegdshop/gist:3171026
WooCommerce - Add checkbox field to the checkout
<?php
/**
* Add checkbox field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my-new-field"><h3>'.__('My Checkbox: ').'</h3>';
@monecchi
monecchi / woocommerce_emails_attach_downloadables.php
Created April 19, 2016 07:50 — forked from garretthyder/woocommerce_emails_attach_downloadables.php
Add Downloadable Products to Woocommerce Completed Order & Invoice Emails as Attachments
<?php
// Add Downloadable Products to Woocommerce Completed Order & Invoice Emails as Attachments
function woocommerce_emails_attach_downloadables($attachments, $status, $order) {
if ( ! is_object( $order ) || ! isset( $status ) ) {
return $attachments;
}
if ( empty( $order ) ) {
return $attachments;
@monecchi
monecchi / gist:947917256e670ccd3c7d27cddd631675
Created April 19, 2016 06:25 — forked from corsonr/gist:093cf4c57262b271fdef
WooCommerce a dd recipient email on completed order
/**
* WooCommerce Extra Feature
* --------------------------
*
* Add another email recipient when an order is completed
*
*/
function woo_extra_email_recipient($recipient, $object) {
$recipient = $recipient . ', [email protected]';
return $recipient;
@monecchi
monecchi / bcc-emails-woocommerce.php
Created April 19, 2016 06:20
BCC all emails sent by WooCommerce
add_filter( 'woocommerce_email_headers', 'add_bcc_all_emails', 10, 2);
function add_bcc_all_emails($headers, $object) {
$headers = array();
$headers[] = 'Bcc: Name <[email protected]>';
$headers[] = 'Content-Type: text/html';
return $headers;
}
@monecchi
monecchi / functions.php
Created April 19, 2016 06:19 — forked from kloon/functions.php
WooCommerce add payment type to emails
<?php
// Place the following code in your theme's functions.php file to add the payment type to all emails
add_action( 'woocommerce_email_after_order_table', 'wc_add_payment_type_to_emails', 15, 2 );
function wc_add_payment_type_to_emails( $order, $is_admin_email ) {
echo '<p><strong>Payment Type:</strong> ' . $order->payment_method_title . '</p>';
}
// Place the following code in your theme's functions.php file to add the payment type to admin emails only
add_action( 'woocommerce_email_after_order_table', 'wc_add_payment_type_to_admin_emails', 15, 2 );
function wc_add_payment_type_to_admin_emails( $order, $is_admin_email ) {
@monecchi
monecchi / gist:b6cec3d09d0ac8562be39d95fd7f50b6
Created April 19, 2016 06:18 — forked from mikejolley/gist:1926284
WooCommerce - Change WooCommerce email subject lines
/*
* goes in theme functions.php or a custom plugin
*
* Subject filters:
* woocommerce_email_subject_new_order
* woocommerce_email_subject_customer_processing_order
* woocommerce_email_subject_customer_completed_order
* woocommerce_email_subject_customer_invoice
* woocommerce_email_subject_customer_note
* woocommerce_email_subject_low_stock
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( 'WC_Process_Order_Email' ) ) :
/**
* Factory Completed Order Email
*
* An email sent to the factory when a new order is completed.
*
@monecchi
monecchi / gist:dd57320a089d00ac667461b34c6fa653
Created April 19, 2016 05:25 — forked from mikejolley/gist:3097073
WooCommerce - Unhook/Disable emails
/**
* Code goes in functions.php or a custom plugin.
*/
add_action( 'woocommerce_email', 'unhook_those_pesky_emails' );
function unhook_those_pesky_emails( $email_class ) {
/**
* Hooks for sending emails during store events
**/
@monecchi
monecchi / gist:56a61a12dbef3d7ce0d6c846c963a550
Created April 18, 2016 06:38 — forked from corsonr/gist:c2781c9e0cc086c5047f
WooCommerce: Add customer username to edit/view order admin page
<?php
// Add WooCommerce customer username to edit/view order admin page
add_action( 'woocommerce_admin_order_data_after_billing_address', 'woo_display_order_username', 10, 1 );
function woo_display_order_username( $order ){
global $post;
$customer_user = get_post_meta( $post->ID, '_customer_user', true );
echo '<p><strong style="display: block;">'.__('Customer Username').':</strong> <a href="user-edit.php?user_id=' . $customer_user . '">' . get_user_meta( $customer_user, 'nickname', true ) . '</a></p>';