扩展PHP函数以包含更多变量

I'm looking extend this PHP function to include more than one variable. This works but only when I've got one product id (8486) against the variable "non_purchasable".

function sv_disable_repeat_purchase( $purchasable, $product ) {
    $non_purchasable = 8486;

    $product_id = $product->is_type( 'variation' ) ? $product->variation_id : $product->id;

    if ( $non_purchasable != $product_id ) {
        return $purchasable;
    }

    if ( wc_customer_bought_product( wp_get_current_user()->user_email, get_current_user_id(), $product_id ) ) {
        $purchasable = false;
    }

    if ( $purchasable && $product->is_type( 'variation' ) ) {
        $purchasable = $product->parent->is_purchasable();
    }

    return $purchasable;
}

I've tried extending this by creating another variable:

$non_purchasable = 8486;
$non_purchasable1 = 8645;

and using two if statements:

if ( $non_purchasable != $product_id ) {
        return $purchasable;
    }
if ( $non_purchasable1 != $product_id ) {
        return $purchasable;
}

But the result is that the function no longer works.

I also tried using an array (leaving the rest of the code as is):

$non_purchasable=array("8486","8645");

But again this didnt work.

I think your array approach is best:

check using:

if (!in_array($product_id, $non_purchasable)) {
    return $purchasable;
}