mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-04 12:22:24 +08:00
8 lines
351 B
Text
8 lines
351 B
Text
add_filter( 'woocommerce_is_purchasable', 'wc_deny_purchase_if_already_purchased', 9999, 2 );
|
|
|
|
function wc_deny_purchase_if_already_purchased( $is_purchasable, $product ) {
|
|
if ( is_user_logged_in() && wc_customer_bought_product( '', get_current_user_id(), $product->get_id() ) ) {
|
|
$is_purchasable = false;
|
|
}
|
|
return $is_purchasable;
|
|
}
|