How to add a age verification checkbox on product page

I need age verification checkbox on the product page https://www.theplannerexchange.com/product-page/gillio-slim-appunto-undyed The verification checkbox need to be show if a customer choose Rent from the Rent product option. And until check the age verification the add to cart button will disable. Please note it’s product page. @Yisrael (Wix) I need you help for this. Can you please take a look?

I added jquery code via custom code from Tracking Tools & Analytics. Here is my code

Here on the code the click function not working. Please someone help me.

Hi :raised_hand_with_fingers_splayed:

You need to set the product page element to be Collapsed on load first, add a strip with a checkbox (unchecked by default) that the visitor needs to check and click on a button to verify they’re in the legal age, add an error message Collapsed on load in case the user click “Verify” without checking the age checkbox.

$w('#verifyAge').onClick((event) => {
    if (!$w('#errMessage').collapsed) {
        $w('#errMessage').collapse();
    }
    if ($w('#ageCheckbox').checked) {
        $w('#verificationStrip').collapse().then(() => {
            $w('#productPage1').expand();
        })
    } else {
        $w('#errMessage').expand();
    }
})

You can also use storage API to save the user choice so that the user needs to verify his age once.

Hope this helps~!
Ahmad

Please note that this is a product page and the checkbox need to show if a customer choose Rent from the dropdown. I haven’t found any selector for the product option dropdown. Please check this product page https://www.theplannerexchange.com/product-page/gillio-slim-appunto-undyed

The product page doesn’t have an exposed API that allow you to set or get the selected options, therefore, it’s not possible.

However, you can achieve this by creating a custom dynamic product page, add a dropdown element and an add to cart button, then use the above code to check the age, and enable or disable the add to cart button accordingly.

So it’s not possible with Wix code. But is it possible via custom code. I added this jquery code

This #dropdown-options-container_1_option-1 is the selector for the Rent dropdown. But i don’t know why the click function not working. Is there any way to show the checkbox if a customer select the Rent from the dropdown.

It’s possible with wix code only if you created a a custom product page using Corvid APIs and SPIs, custom HTML code won’t work well.