Add a purchase condition to WooCommerce products
问题 I ma trying to add a purchase condition to my WooCommerce products with the following: {$current_user = wp_get_current_user(); if ( current_user_can('administrator') || wc_customer_bought_product($current_user->email, $current_user->ID, // return true return true;} But I don't know if this code is correct and an advise will be helpful. 回答1: The product Id argument is missing from wc_customer_bought_product() function, and you can get more easily the WP_User object. Here is a usage example: