Created
July 27, 2018 20:16
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you. Super helpful