mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/65486828/a-notice-message-to-users-who-have-bought-a-product-on-woocommerce
9 lines
423 B
Text
9 lines
423 B
Text
function wc_bought_before_woocommerce_add_to_cart_validation( $is_purchasable, $instance ){
|
|
|
|
$current_user = wp_get_current_user();
|
|
if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $instance->get_id()) ) {
|
|
$is_purchasable = false;
|
|
}
|
|
return $is_purchasable;
|
|
}
|
|
add_filter( 'woocommerce_is_purchasable', 'wc_bought_before_woocommerce_add_to_cart_validation', 10, 2 );
|