Add Checkbox to Toggle Between One-Time Purchase and Subscription in Funnelish Checkout

Hello,

I asked this question on Funnelish live chat support and they redirected me here.

I’d like to add a checkbox on my checkout page that allows users to choose between a one-time purchase or a recurring subscription (Stripe subscription). If the checkbox is checked, it becomes a subscription; if unchecked, it stays a one-time payment.

On my funnel, I currently have 3 offers — please see attached screenshot for reference:

  1. (1 Jar) 49,95€ (rebill after 1 month)
  2. (2 Jars + 1 Free) 99,95€ (rebill after 2 months)
  3. (3 Jars + 2 Free) 149,95€ (rebill after 3 months)

I would like the subscription logic to apply to whichever pack is selected, based on the checkbox state.

Can you provide me the code or exact steps to implement this behavior in my Funnelish checkout?

Thanks a lot in advance!

Hey @fkl36817 :waving_hand:

Great question! Yes, what you’re trying to do is definitely possible inside Funnelish using custom code.

You’ll need a bit of JavaScript to detect the checkbox state and then switch between the one-time purchase product and the subscription product dynamically at checkout.

Here’s what to keep in mind:

:white_check_mark: You’ll need:

  • Two versions of each offer (one-time and subscription) set up in your funnel
  • A checkbox added via a custom HTML block
  • Custom JS to switch product IDs based on the checkbox

:warning: Since this involves dynamic product swapping, it does require custom coding and is best handled by a developer.

:backhand_index_pointing_right: If you’re on the Advanced Plan, you can also reach out to the Funnelish support team for help implementing the custom code.

Let me know if you’d like a basic example to get started — happy to help! :blush:

Thank you for your answer @anwerashif !

Yes i would love a basic example for my funnel offer example i sent you :slight_smile:

Give your customers a choice between one-time purchase and subscription by adding a toggleable checkbox that updates the visible products dynamically.


:white_check_mark: Step 1: Create Your Products

Start by creating 6 products inside your Funnelish funnel.

  • First 3 products = Subscription
  • Last 3 products = One-Time Purchase

You can name them clearly like:

Product 1 – Sub
Product 2 – Sub
Product 3 – Sub
Product 4 – One-Time
Product 5 – One-Time
Product 6 – One-Time


:white_check_mark: Step 2: Add Subscription Offer Section

Now let’s add a container that promotes the subscription offer and contains the checkbox.

  1. Add a container element and give it the class: .offerBox
  2. Inside this container, insert the following promotional text:
Dr J. Recommends subscribing today!

Save an additional 10% on your order and get Advanced Crepe Fix delivered to your door every month!

This is the lowest price you will see!

Get 30% off our store at all times!

Cancel anytime by reaching out to our customer service.
  1. Add a Checkbox element from the form section:

    • Give it the class: .kh_check
    • Assign it the ID: #checkbox_subscription


:white_check_mark: Step 3: Add the Product List

Next, add the Product List element to your funnel. This is where your products will appear and dynamically show/hide based on the checkbox.

  • Set the Product List element’s ID to: #product-list


:white_check_mark: Step 4: Add Custom CSS Styling

To make everything look clean and responsive, go to:

More actions > Custom Codes > CSS

Paste the following CSS code:

.product-list .pl-item .top-tag {
    font-size: 12px !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    pointer-events: none !important;
    position: absolute !important;
    left: 0 !important;
    top: -52px !important;
    white-space: nowrap !important;
    background-color: #E32D2C !important;
    padding: 3px !important;
    border-radius: 15px !important;
    padding-right: 15px !important;
    padding-left: 15px !important;
    margin-left: -100px !important;
    animation: pulse 1.5s infinite, echo 1.5s infinite !important;
}

.kh_check { padding: 0 !important; }

.kh_check label::before, .my_order_bump .ob-header::before {
    content: url(https://img.funnelish.com/4224/20304/1643364132-arrow-flash-small.gif);
    transform: translateY(1px);
}

.kh_check input {
    width: 17px;
    height: 17px;
    margin: -1px 10px 0px 8px;
}

.hidden { display: none !important; }

.offerBox {
    cursor: pointer;
}


:white_check_mark: Step 5: Add Custom JavaScript Logic

Finally, go to:

Custom Codes > Body HTML

Paste the following script to enable the interactive toggle behavior:

<script>
    window.addEventListener('DOMContentLoaded', () => {
        const offerBox = document.querySelector(".offerBox");
        const checkbox = document.querySelector(".kh_check input");

        if (offerBox && checkbox) {
            offerBox.addEventListener("click", function () {
                checkbox.checked = !checkbox.checked;
            });
        }

        const productList = document.getElementById('product-list');
        const input = document.querySelector('#checkbox_subscription input');
        
        const updateProducts = () => {
            const items = productList.querySelectorAll('.pl-item');
            items.forEach((item, i) => {
                item.style.order = item.classList.contains('selected') ? '-1' : i + 1;
                const isSub = i < 3;
                const show = input.checked ? isSub : !isSub;
                item.classList.toggle('hidden', !show);
            });

            const firstVisible = [...items].find(item => !item.classList.contains('hidden'));
            firstVisible?.querySelector('input.pl-radio')?.click();
        };

        input.checked = true; // ensure checkbox is checked on load
        updateProducts();
        
        input.addEventListener('change', updateProducts);
    });
</script>

What This Does:

  • Toggling .offerBox checks/unchecks the checkbox

  • Based on the checkbox state:

    • Shows Subscription products (first 3) or One-Time products (last 3)
  • Automatically selects the first visible product


:tada: You’re Done!

Now when users click the offer box or checkbox, the product list will update in real-time, showing either subscriptions or one-time purchase options.