Created
January 10, 2017 21:57
-
-
Save Abd-Ur-Rehman/39944b94da5b67e0f762ffebf4ae1bb5 to your computer and use it in GitHub Desktop.
View full post here: http://www.abdurrehman.net/blog
This file contains 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_action ( 'woocommerce_after_shop_loop_item', 'user_logged_in_product_already_bought', 30); | |
function user_logged_in_product_already_bought() { | |
if ( is_user_logged_in() ) { | |
global $product; | |
$current_user = wp_get_current_user(); | |
if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product->id ) ) echo '<div class="user-bought">♥ Hey ' . $current_user->first_name . ', you\'ve purchased this in the past. Buy again?</div>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment