ID == 0 ) {
// User is not logged in, display login prompt
echo ‘
‘;
return array(); // Return an empty array
} else {
$where .= ” AND product_id IN (SELECT product_id FROM {$wpdb->prefix}woocommerce_order_items oi LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta oim ON oi.order_item_id = oim.order_item_id WHERE oim.meta_key = ‘_product_id’ AND oi.order_id IN (SELECT ID FROM {$wpdb->prefix}posts WHERE post_type = ‘shop_order’ AND post_status = ‘wc-completed’ AND post_author = {$current_user->ID}))”;
}
}
$sql = “SELECT * FROM $table_name WHERE $where”;
$sessions = $wpdb->get_results($sql);
return $sessions;
}
function is_session_purchased($product_id) {
if ( ! function_exists( ‘wc_customer_bought_product’ ) ) {
return false; // WooCommerce function not available
}
$current_user = wp_get_current_user();
if ( $current_user->ID == 0 ) {
return false; // User is not logged in
}
return wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id );
}
// Get search parameters
$year = isset($_GET[‘year’]) ? $_GET[‘year’] : null;
$category = isset($_GET[‘category’]) ? $_GET[‘category’] : null;
$purchased_only = isset($_GET[‘purchased_only’]) ? $_GET[‘purchased_only’] : false;
// Fetch sessions
$sessions = get_sessions($year, $category, $purchased_only);
// Get unique years and categories from the fetched sessions
$years = array_unique(array_map(function($session) { return $session->year; }, $sessions));
$categories = array_unique(array_map(function($session) { return $session->category; }, $sessions));
?>
});
?>
0) : ?>

