Forked from greathmaster/pmpro-group-discount-order-csv-export.php
Last active
April 8, 2021 20:42
-
-
Save travislima/59b79fea233fada112209e454591cce5 to your computer and use it in GitHub Desktop.
Add the group code column to the Order CSV export
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 //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"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/