Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save travislima/59b79fea233fada112209e454591cce5 to your computer and use it in GitHub Desktop.

Select an option

Save travislima/59b79fea233fada112209e454591cce5 to your computer and use it in GitHub Desktop.
Add the group code column to the Order CSV export
<?php //Do not copy this PHP tag into your code.
/**
* Adds an extra colum to your Memberships > Orders > Export to CSV file. Displays the group discount code used.
*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
* Requires the Paid Memberships Pro Group Discount code Add On to be installed and activated in order to work:
* https://www.paidmembershipspro.com/add-ons/group-discount-codes/
*/
//Set up the column header and callback function
function my_pmpro_orders_csv_extra_columns($columns)
{
$columns["group_code"] = "my_extra_order_column_notes";
return $columns;
}
//The actual call back for the column
function my_extra_order_column_notes($order)
{
global $wpdb;
$group_code = pmpro_getMatches("/{GROUPCODE:([^}]*)}/", $order->notes, true);
if(!empty($group_code))
return $group_code;
else
return "";
}
add_filter("pmpro_orders_csv_extra_columns", "my_pmpro_orders_csv_extra_columns");
@laurenhagan0306

Copy link
Copy Markdown

This recipe is included in the blog post "Include the used and claimed Group Discount Codes in your Membership Orders export file" at Paid Memberships Pro here: https://www.paidmembershipspro.com/include-the-used-and-claimed-group-discount-codes-in-your-membership-orders-export-file/

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