Last active
November 23, 2017 11:26
-
-
Save fbmoises/f82e3b4a86f326c64ce44d9952011d1f to your computer and use it in GitHub Desktop.
Comprobar si el cliente ya ha comprado un producto. Muestra un mensaje al cliente debajo del producto que ya ha comprado anteriormente.
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
// Comprobar si el cliente ya ha comprado un producto. Muestra un mensaje al cliente debajo del producto que ya ha comprado anteriormente. | |
add_action ( 'woocommerce_after_shop_loop_item', 'wcfb_user_logged_in_product_already_bought', 30); | |
function wcfb_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">♥ Hola ' . $current_user->first_name . ', has comprado esto anteriormente. ¿Comprar otra vez?</div>'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment