Created
January 13, 2015 03:02
-
-
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
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
/** | |
* 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