# Error when opening lightbox: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'widgetId')

**URL:** <https://forum.wixstudio.com/t/error-when-opening-lightbox-uncaught-in-promise-typeerror-cannot-read-properties-of-undefined-reading-widgetid/57699>\
**Category:** Ask the community\
**Tags:** cms, code, wix, question, wix-stores\
**Created:** [March 29, 2024, 6:09pm UTC](https://forum.wixstudio.com/t/error-when-opening-lightbox-uncaught-in-promise-typeerror-cannot-read-properties-of-undefined-reading-widgetid/57699 "2024-03-29T18:09:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luke\_E](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/luke_e/32/90306_2.png) [@Luke\_E](https://forum.wixstudio.com/u/Luke_E)\
**Post date:** [March 29, 2024, 6:09pm UTC](https://forum.wixstudio.com/t/error-when-opening-lightbox-uncaught-in-promise-typeerror-cannot-read-properties-of-undefined-reading-widgetid/57699/1 "2024-03-29T18:09:48Z")

</div>

**Question:**  
How can I make my code pass in and receive data from a lightbox correctly?

**Product:**  
Wix Editor

**What are you trying to achieve:**  
I would like to pass in data from a page to a lightbox, then take data back out.

**What have you already tried:**  
I tried to set up my code similar to [the docs](https://www.wix.com/velo/reference/wix-window-frontend/openlightbox), however, it doesn’t seem to be working. It works fine on preview, but as soon as I publish and try it on the live site, I get this console error:

**Additional information:**  
My code:

**Cart Page**

```javascript
import { currentCart } from 'wix-ecom-backend'
import wixWindowFrontend from 'wix-window-frontend';
import { getPaymentPlans } from 'backend/web-modules/paymentPlans.web.js'
import { cart } from 'wix-stores-frontend';

$w.onReady(async function () {
    const cartInfo = await currentCart.getCurrentCart()
    console.log('cart details:', cartInfo)
    const paymentPlans = await getPaymentPlans()

    const lineItems = cartInfo?.lineItems
    if (lineItems && lineItems.length > 0) {
        const registrations = lineItems.filter(item => item.catalogReference.appId === '13d21c63-b5ec-5912-8397-c3a5ddb27a97')
        if (registrations.length > 0) {
            $w('#needAPaymentPlanButton').show()
        } else {
            $w('#needAPaymentPlanButton').hide()
        }
    }

    $w('#needAPaymentPlanButton').onClick(() => {
        console.log('opening!!')
        wixWindowFrontend.openLightbox('Payment Plan Options', { 'paymentPlans': paymentPlans }).then(returnedData => {
            console.log('returnedData is: ', returnedData)
            if (returnedData && returnedData?.selectedPlanId) {
                const paymentPlansFiltered = paymentPlans.filter(plan => plan._id === returnedData.selectedPlanId)
                if (paymentPlansFiltered.length > 0) {
                    const couponCode = paymentPlansFiltered[0]?.couponCode
                    console.log('howdy, plans filtered: ', paymentPlansFiltered, '; plans: ', paymentPlans, '; couponCode: ', couponCode)
                    if (couponCode) {
                        console.log('about to apply coupon: ', couponCode)
                        cart.applyCoupon(couponCode).then(() => { console.log('applied!!!!!');
                            wixWindowFrontend.lightbox.close() }).catch((e) => { console.error('error handling coupon: ', e) })

                    }
                }

            }
        })
    })

});

```

**Payment Plan Options lightbox code**

```javascript
import { cart } from 'wix-stores-frontend';
import wixWindowFrontend from 'wix-window-frontend';

$w.onReady(function () {
    console.log('starting non-async function!')

    let received = wixWindowFrontend.lightbox.getContext();
    console.log('received: ', received)
    console.log('dropdown: ', $w('#paymentPlansDropdownElement'))

    const dropdownOptions = received.paymentPlans.map((plan) => {
        return {
            label: plan.title + ' - every ' + plan.monthsBetweenPayments + 'month' + (plan.monthsBetweenPayments > 1 ? 's' : ''),
            value: plan._id
        };
    });
    console.log('dropdown options: ', dropdownOptions)

    $w('#paymentPlansDropdownElement').options = dropdownOptions

    console.log('options: ', $w('#paymentPlansDropdownElement'), $w('#paymentPlansDropdownElement').options)
});

export function paymentPlanSubmitButton_click(event) {
    console.log('in event handler, button click event: ', event)
    console.log('payment plan is: ', $w('#paymentPlansDropdownElement').value)
    if ($w('#paymentPlansDropdownElement').value) {
        wixWindowFrontend.lightbox.close({selectedPlanId: $w('#paymentPlansDropdownElement').value})
    }
}

```

---

<div class="post-metadata">

**Author:** ![anthony](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/anthony/32/79536_2.png) [@anthony](https://forum.wixstudio.com/u/anthony)\
**Post date:** [April 3, 2024, 9:13pm UTC](https://forum.wixstudio.com/t/error-when-opening-lightbox-uncaught-in-promise-typeerror-cannot-read-properties-of-undefined-reading-widgetid/57699/2 "2024-04-03T21:13:40Z")

</div>

This error message is saying that an object is undefined and thus it doesn’t have a property `widgetId`. I don’t see it in this code but is your code at any point trying to access a `widgetId` property?

---

<div class="post-metadata">

**Author:** ![Luke\_E](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/luke_e/32/90306_2.png) [@Luke\_E](https://forum.wixstudio.com/u/Luke_E)\
**Post date:** [April 3, 2024, 10:40pm UTC](https://forum.wixstudio.com/t/error-when-opening-lightbox-uncaught-in-promise-typeerror-cannot-read-properties-of-undefined-reading-widgetid/57699/3 "2024-04-03T22:40:41Z")

</div>

@anthony, nothing in my code references “widgetId” at any point. I also ran a search just to see if it was in any of my custom code and it didn’t find anything.

![CleanShot 2024-04-03 at 18.39.55@2x](https://us1.discourse-cdn.com/wix/original/3X/3/f/3f06660d2b73f49c10f250f1fc2cb77bc1f85b8c.png)

---

<div class="post-metadata">

**Author:** ![anthony](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/anthony/32/79536_2.png) [@anthony](https://forum.wixstudio.com/u/anthony)\
**Post date:** [April 4, 2024, 7:03pm UTC](https://forum.wixstudio.com/t/error-when-opening-lightbox-uncaught-in-promise-typeerror-cannot-read-properties-of-undefined-reading-widgetid/57699/4 "2024-04-04T19:03:26Z")

</div>

Hrmm I’m unable to reproduce this error from opening a lightbox: [https://anthonyl5.wixstudio.io/lightbox-test](https://anthonyl5.wixstudio.io/lightbox-test)

Are you still experiencing the error?

---

<div class="post-metadata">

**Author:** ![Luke\_E](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/luke_e/32/90306_2.png) [@Luke\_E](https://forum.wixstudio.com/u/Luke_E)\
**Post date:** [April 4, 2024, 7:13pm UTC](https://forum.wixstudio.com/t/error-when-opening-lightbox-uncaught-in-promise-typeerror-cannot-read-properties-of-undefined-reading-widgetid/57699/5 "2024-04-04T19:13:01Z")

</div>

@anthony , yes, I’m still getting the error, but at this point I just put it on the page instead of in a lightbox (which is working fine) and am moving on because I have more pressing issues to attend to. Thanks for your help though.

If you’re able to comment on my other post below it would be greatly appreciated.

> [@Odd Collection Not Found Error (WDE0025)](https://forum.wixstudio.com/t/odd-collection-not-found-error-wde0025/57852):
>
> Question: When I load my site page, I get a strange error about 70% of the time stating ["WDE0025: The RegistrationCartItems collection does not exist. You cannot work with a collection using the Data API before it is created in the Editor."] I understand what this would mean normally, but I do have a RegistrationCartItems collection and it pulls from it perfectly fine about 30% of the time. Product: Wix Editor / Velo What are you trying to achieve: Have the page load without errors. What…

---

<div class="post-metadata">

**Author:** ![brian13531](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/brian13531/32/8257_2.png) [@brian13531](https://forum.wixstudio.com/u/brian13531)\
**Post date:** [November 9, 2024, 5:38am UTC](https://forum.wixstudio.com/t/error-when-opening-lightbox-uncaught-in-promise-typeerror-cannot-read-properties-of-undefined-reading-widgetid/57699/6 "2024-11-09T05:38:14Z")

</div>

Seems like no one ever solved this, huh? I’m getting this too. Cannot read properties of undefined (reading ‘widgetId’). Checked all the variables heading in from set Props(all good). Just not connecting. Is there way to check in the widget id on the site matches the id in the blocks?
