Last active
July 12, 2016 21:19
-
-
Save eighty20results/a214c6ec267bc155e701 to your computer and use it in GitHub Desktop.
Add discount code column to order list
This file contains 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
function my_pmpro_add_cols_header($order_ids) { | |
ob_start(); ?> | |
<th>Discount Code</th><?php | |
return ob_get_clean(); | |
} | |
add_filter('pmpro_orders_extra_cols_header', 'my_pmpro_add_cols_header'); | |
function my_pmpro_add_cols_body($order) { | |
global $wpdb; | |
$sql = "SELECT code from bbwp_pmpro_discount_codes as dc INNER JOIN bbwp_pmpro_discount_codes_uses as dcu ON (dcu.code_id = dc.id) WHERE dcu.order_id=%s"; | |
$discount_code = $wpdb->get_var($wpdb->prepare($sql, $order->id)); | |
ob_start(); ?> | |
<td><?php echo $discount_code; ?></td> | |
<?php | |
return ob_get_clean(); | |
} | |
add_filter('pmpro_orders_extra_cols_body', 'my_pmpro_add_cols_body'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment