woo add to cart – display price in button with text according to category

add_filter( 'woocommerce_product_add_to_cart_text', 'custom_add_to_cart_price', 20, 2 ); // Shop and other archives pages
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_add_to_cart_price', 20, 2 ); // Single product pages

function custom_add_to_cart_price( $button_text, $product ) {
    // Check if the product belongs to a specific category (e.g., 'tickets' or 'camping')
    $categories = array( 'tickets', 'camping' );

    if ( has_term( $categories, 'product_cat', $product->get_id() ) ) {
        $product_price = wc_price( wc_get_price_to_display( $product ) );
        return  strip_tags( $product_price ) . ' Per Person';
    } elseif( $product->is_type('variable') ) {
        // For variable products
        if( ! is_product() ){
            $product_price = wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_variation_price() ) ) );
            return $button_text . ' - From ' . strip_tags( $product_price );
        } 
        // Single product pages
        else {
            return $button_text;
        }
    } else {
        // For all other product types
        $product_price = wc_price( wc_get_price_to_display( $product ) );
        return  strip_tags( $product_price );
    }
}