Skip to content

Instantly share code, notes, and snippets.

Justin Stern justinstern

Block or report user

Report or block justinstern

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@justinstern
justinstern / functions.php
Last active Jul 22, 2016
Include featured images in WordPress RSS feed post entries
View functions.php
// add everything below this point to the bottom of your current theme's functions.php
function prepend_thumbnail_rss( $content ) {
global $post;
if ( has_post_thumbnail( $post->ID ) ) {
$content = get_the_post_thumbnail( $post->ID, 'full' ) . $content;
}
return $content;
}
add_filter( 'the_excerpt_rss', 'prepend_thumbnail_rss' );
add_filter( 'the_content_feed', 'prepend_thumbnail_rss' );
@justinstern
justinstern / functions.php
Last active Oct 15, 2016
This snippet will disable WooCommerce core emails based on the product category
View functions.php
<?php
// Add the below to the bottom of your theme's functions.php:
add_filter( 'woocommerce_email_enabled_customer_processing_order', 'disable_emails_for_fundraising', 10, 2 );
add_filter( 'woocommerce_email_enabled_customer_completed_order', 'disable_emails_for_fundraising', 10, 2 );
function disable_emails_for_fundraising( $enabled, $order ) {
if ( count( $order->get_items() ) > 0 ) {
View functions.php
<?php
// This sample code will add additional recipients to a WooCommerce email order type, based on the order email address
// Email id's for the various email types (i.e. customer_invoice) can be found here:
// https://github.com/woothemes/woocommerce/blob/5e09f15c91970d8bec4ab56abbfd5d3039a02a1b/includes/emails/class-wc-email-customer-invoice.php#L30https://github.com/woothemes/woocommerce/blob/5e09f15c91970d8bec4ab56abbfd5d3039a02a1b/includes/emails/class-wc-email-customer-invoice.php#L30
// Add the following to the bottom of your theme's functions.php:
add_filter( 'woocommerce_email_recipient_customer_invoice', 'woocommerce_email_customer_invoice_add_recipients' );
function woocommerce_email_customer_invoice_add_recipients( $recipient, $order ) {
if ( 'joe@acme.com' == $recipient ) {
@justinstern
justinstern / functions.php
Last active Aug 29, 2015
WooCommerce PDF Product Vouchers: Display any voucher numbers on the order emails
View functions.php
<?php
// Add the following to the end of your theme's functions.php
// Add the following to the end of your theme's functions.php
add_action( 'woocommerce_email_order_meta', 'wc_pdf_product_vouchers_email_voucher_numbers', 10, 3 );
function wc_pdf_product_vouchers_email_voucher_numbers( $order, $sent_to_admin, $plain_text ) {
if ( class_exists( 'WC_PDF_Product_Vouchers_Order' ) ) {
$vouchers = WC_PDF_Product_Vouchers_Order::get_vouchers( $order );
@justinstern
justinstern / functions.php
Created Jun 10, 2014
Snippet to automatically assign a invoice number to an order when payment is successfully completed http://www.woothemes.com/products/print-invoices-packing-lists/
View functions.php
<?php
// Add the following to the bottom of your theme's functions.php
add_action( 'woocommerce_payment_complete', 'set_pip_invoice_number' );
function set_pip_invoice_number( $order_id ) {
$order = new WC_Order( $order_id );
if ( in_array( $order->status, array( 'processing', 'completed' ) ) && function_exists( 'woocommerce_pip_invoice_number' ) ) {
woocommerce_pip_invoice_number( $order_id );
View functions.php
<?php
// add the following to the bottom of your functions.php
// assumes a copy of the core class-wc-shortcodes.php, customized, is available at path/to/custom/class-wc-shortcodes.php
add_action( 'woocommerce_loaded', 'use_custom_wc_shortcodes' );
function use_custom_wc_shortcodes() {
// load our custom shortcodes class
View wc-measurement-price-calculator-hide-prices.php
<?php
// Add the following to the bottom of your current theme's functions.php
add_filter( 'woocommerce_sale_price_html', 'remove_price_per_unit_html', 15, 2 );
add_filter( 'woocommerce_price_html', 'remove_price_per_unit_html', 15, 2 );
add_filter( 'woocommerce_empty_price_html', 'remove_price_per_unit_html', 15, 2 );
add_filter( 'woocommerce_variable_sale_price_html', 'remove_price_per_unit_html', 15, 2 );
add_filter( 'woocommerce_variable_price_html', 'remove_price_per_unit_html', 15, 2 );
add_filter( 'woocommerce_variable_empty_price_html', 'remove_price_per_unit_html', 15, 2 );
@justinstern
justinstern / wc-email-recipient-for-payment-type.php
Created Apr 23, 2014
WooCommerce New Order email alert based on payment type. This snippet will send a new order alert email to an additional email address, based on payment type. Reader question from http://www.skyverge.com/blog/how-to-add-a-custom-woocommerce-email/
View wc-email-recipient-for-payment-type.php
<?php
// Add everything below to your current theme's functions.php:
// The email to send can be changed by using a different filter in place of 'woocommerce_email_recipient_new_order'
// The payment method can be changed by using a different payment method id in place of 'cod'
add_filter( 'woocommerce_email_recipient_new_order', 'wc_new_order_cash_on_delivery_recipient', 10, 2 );
function wc_new_order_cash_on_delivery_recipient( $recipient, $order ) {
@justinstern
justinstern / wc-nested-category-layout-hide-cat-images.php
Created Apr 21, 2014
WooCommerce Nested Category Layout: hide the subcategory image in the nested categories layout.
View wc-nested-category-layout-hide-cat-images.php
<?php
// Add the code below to the bottom of your current theme's functions.php:
function woocommerce_nested_category_products_content_section( $categories, $product_category_ids ) {
global $wp_query, $wc_nested_category_layout;
$title = '';
$term = '';
@justinstern
justinstern / wc-tab-manager-global-tab-product-specific-content.php
Last active Aug 29, 2015
Sample code to demonstrate the display of product-specific content for a global tab with the WooCommerce Tab Manager plugin http://www.woothemes.com/products/woocommerce-tab-manager/ The content is taken from a Custom Field named 'product_specifications_tab_content' added to the product. This assumes that the product is using the Global Tab Layo…
View wc-tab-manager-global-tab-product-specific-content.php
<?php
// Add everything below to your current theme's functions.php file
add_filter( 'woocommerce_tab_manager_tab_panel_content', 'wc_tab_manager_global_tab_product_specific_content', 10, 3 );
function wc_tab_manager_global_tab_product_specific_content( $content, $tab, $product ) {
// tab by title slug
if ( 'product-specifications' == $tab['name'] ) {
You can’t perform that action at this time.