Skip to content

Instantly share code, notes, and snippets.

@amdrew
Created January 13, 2015 03:02
Show Gist options
  • Save amdrew/d0a9ef90b723b771f01b to your computer and use it in GitHub Desktop.
Save amdrew/d0a9ef90b723b771f01b to your computer and use it in GitHub Desktop.
AffiliateWP + WooCommerce. Show the customer's first and name last in the reference column on the referrals screen
/**
* Add link through to user's profile screen from the reference column of the referrals page
*/
function affwp_custom_wc_referrals_user_link( $reference, $referral ) {
if ( ! ( 'woocommerce' == $referral->context || class_exists( 'WC_Order' ) ) ) {
return $reference;
}
$order = new WC_Order( $referral->reference );
$customer_first_name = isset( $order->billing_first_name ) ? $order->billing_first_name : '';
$customer_last_name = isset( $order->billing_last_name ) ? $order->billing_last_name : '';
if ( $customer_first_name ) {
return $reference . ' - ' . $customer_first_name . ' ' . $customer_last_name;
}
return $reference;
}
add_filter( 'affwp_referral_reference_column', 'affwp_custom_wc_referrals_user_link', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment