Restrict customers from booking certain service catagories

Good Morning,

I am setting up a website for a charity where customers can rent wheelchairs and adapted bikes or trikes. Anyone can book a wheelchair, but only members with an annual subscription can book a bike or trike. That’s all working.

I would like to introduce additional functionality where if the customer hasn’t attended an induction session they can’t book a bike or trike, but can book a wheelchair. My plan was to either have a label, a badge, a custom field, or a site role to add to customers once they attend induction.

When trying to create a checkout validation procedure the AI complains that it can’t read any of the customer details to see if they have attended induction.

When trying to use Velo AI to create the code for a page, the code doesn’t do anything no matter which page I insert it to:

import { checkout } from 'wix-stores-backend';
import { currentUser } from 'wix-users-backend';

export async function blockCheckoutIfNoInductionLabel() {
    const user = currentUser;
    const labels = await user.getLabels();
    const hasInductionLabel = labels.some(label => label.name === 'Induction');

    if (!hasInductionLabel) {
        throw new Error('Checkout blocked: You need to attend an induction session before renting equipment. Please contact us to arrange.');
    }

    // Proceed with checkout if the label is present
    return checkout();
}

I did a workaround where I created a site role called Induction and created two separate services pages for wheelchairs and bikes/trikes. Then set the permissions so only people in the Induction role can view the bikes/trikes. However, the charity would like everyone to be able to see what is available before buying a membership and attending induction.

I’m new to Wix and my coding knowledge is limited, but I feel like there must be a way to crack this. Does anyone have any suggestions?

Thank you.

Wix users backend died a noble death many a moon ago.

What you are looking to push into the “AI” is wix members backend. There you can possibly get the details of the user you are looking for

. Velo Wix Members Backend Introduction | Velo

This thread should help you with more info on how to achieve it.