Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Abd-Ur-Rehman/39944b94da5b67e0f762ffebf4ae1bb5 to your computer and use it in GitHub Desktop.
Save Abd-Ur-Rehman/39944b94da5b67e0f762ffebf4ae1bb5 to your computer and use it in GitHub Desktop.
View full post here: http://www.abdurrehman.net/blog
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">&hearts; 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