Skip to content

Instantly share code, notes, and snippets.

@jawinn
Created July 27, 2018 20:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jawinn/8a719153eca433825a198e2db1826307 to your computer and use it in GitHub Desktop.
Save jawinn/8a719153eca433825a198e2db1826307 to your computer and use it in GitHub Desktop.
Add download count to list of downloads (table) on the WooCommerce Customer's Order Email
<?php
/**
* Add additional 'download-count' column to the table of downloads on the customer's order email.
* @param Array $columns Associative array of key "column_id" and value with the display name https://goo.gl/TDxPLE
*/
function add_order_email_dl_cols($columns) {
return array(
'download-product' => __( 'Product', 'woocommerce' ),
'download-expires' => __( 'Expires', 'woocommerce' ),
'download-count' => __( 'Max # of Downloads', 'woocommerce' ),
'download-file' => __( 'Download', 'woocommerce' ),
);
}
add_filter( 'woocommerce_email_downloads_columns', 'add_order_email_dl_cols' );
/**
* Display custom column value on order email download column
* @param Array $download Single download info from $order->get_downloadable_items()
* @param Bool $plain_text If is plain text email
*/
function woo_email_downloads_count_col($download, $plain_text){
echo $download['downloads_remaining'];
}
add_action( 'woocommerce_email_downloads_column_download-count', 'woo_email_downloads_count_col', 10, 2);
@ajueket
Copy link

ajueket commented Oct 15, 2019

Thank you. Super helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment