Advertisement
fahimmurshed

Disable purchase for non-logged-in users

Feb 3rd, 2021
1,026
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.30 KB | None | 0 0
  1. // Disable purchase for non-logged-in users.
  2. function m3wc_woocommerce_is_purchasable( $is_purchasable, $product ) {
  3.     if ( ! is_user_logged_in() ) {
  4.         return false;
  5.     }
  6.  
  7.     return $is_purchasable;
  8. }
  9. add_filter( 'woocommerce_is_purchasable', 'm3wc_woocommerce_is_purchasable', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement