Skip to content

Instantly share code, notes, and snippets.

@justinstern
justinstern / sample-orders-metadata.json
Last active June 27, 2020 03:40
taken from: select properties from orders where properties is not null and platform_name != 'edd' limit 100;
{"tracking": [{"tracking_id": "2ba66a14505f97de0e5a2b1672186aa7", "date_shipped": "1593129600", "tracking_number": "40417300001301", "tracking_provider": "dhl-parcel-uk", "formatted_tracking_link": "https://track.dhlparcel.co.uk/?con=40417300001301", "formatted_tracking_provider": "DHL Parcel UK"}], "tracking_code": "40417300001301"}
{"tracking_code": "9400136205309524568071"}
{"time": "14:30", "datum": "04.06.2020"}
{"notes": ["Glock 23 Drop In Ultra Match Barrel (G23-Thread-TiN) x 1 shipped via USPS on June 16, 2020 with tracking number 9405511899563517863014."]}
EDD:
@justinstern
justinstern / sample-orders-metadata.json
Created June 27, 2020 03:40
taken from: select properties from orders where properties is not null and platform_name != 'edd' limit 100;
{"tracking": [{"tracking_id": "2ba66a14505f97de0e5a2b1672186aa7", "date_shipped": "1593129600", "tracking_number": "40417300001301", "tracking_provider": "dhl-parcel-uk", "formatted_tracking_link": "https://track.dhlparcel.co.uk/?con=40417300001301", "formatted_tracking_provider": "DHL Parcel UK"}], "tracking_code": "40417300001301"}
{"tracking_code": "9400136205309524568071"}
{"time": "14:30", "datum": "04.06.2020"}
{"notes": ["Glock 23 Drop In Ultra Match Barrel (G23-Thread-TiN) x 1 shipped via USPS on June 16, 2020 with tracking number 9405511899563517863014."]}
@justinstern
justinstern / functions.php
Last active July 22, 2016 18:03
Include featured images in WordPress RSS feed post entries
// 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 July 14, 2021 17:22
This snippet will disable WooCommerce core emails based on the product category
<?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 ( isset( $order ) && count( $order->get_items() ) > 0 ) {
<?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 August 29, 2015 14:05
WooCommerce PDF Product Vouchers: Display any voucher numbers on the order emails
<?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 June 10, 2014 04:04
Snippet to automatically assign a invoice number to an order when payment is successfully completed http://www.woothemes.com/products/print-invoices-packing-lists/
<?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 );
<?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
@justinstern
justinstern / wc-measurement-price-calculator-hide-prices.php
Created May 23, 2014 16:17
WC Measurement Price Calculator customization to hide the product price per unit http://www.woothemes.com/products/measurement-price-calculator/
<?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 April 23, 2014 16:38
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/
<?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 ) {