Skip to content

Instantly share code, notes, and snippets.

@eighty20results
Last active July 12, 2016 21:19
Show Gist options
  • Save eighty20results/a214c6ec267bc155e701 to your computer and use it in GitHub Desktop.
Save eighty20results/a214c6ec267bc155e701 to your computer and use it in GitHub Desktop.
Add discount code column to order list
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