Hi everyone! I am officially stumped, I have been working with code for about two weeks, so it does not say much that I am stumped, so I would appreciate any input on my issue. I want paid-plan members to receive a discount (dollar amount) that applies across all booking services. As of right now the Paid Plan app only lets you include a limited or unlimited number of offerings for free, which is not ideal. In order to still mobilize a discount to our Paid-Plan members, I have created two coupon codes (one for each Paid Plan available on the website). On my Booking's Checkout Page, I have added a Multi-State Box.
The box name and states are as follows:
Box: #statebox8
State 1: #introbox
Other state IDs: #studentbox , #tutorbox , #lsignupbox
The first state contains a button that onClicks to reveal one of the other three states depending on whether the logged in user is also a Paid Plan Member.
If they are on the Student Paid Plan and logged in, clicking the button should transition to state ID #studentbox, in which contains the coupon code they would enter to receive their discount.
If they are on the Tutor Paid Plan and logged in, click the button should transition to state ID #tutorbox, in which contains the coupon code for their discount.
And finally, if the user is a) not logged in or b) not a member, clicking the button should transition to state ID #lsignupbox, which contains a link to the paid plan membership display or the log-in lightbox depending on which link you click.
As far as I have been able to figure out, an async function is necessary to search the dataset that connects userIDs to PaidPlan Membership IDs and then use the following to call the appropriate box:
$w("#button5").onClick(() => { $w('#statebox8').changeState("#whateverboxisassociatedwiththeiraccount");
Right now I have members that are not on a paid plan returning value.src because their values will be undefined when referencing my paid plan membership collection. But I am not sure my application is as flawless as my imaginary concept of how all of this should work haha seriously, please help.
PlanEnrollment is my dataset. I've tried a variety of different options like .then() statements to return the correct box, I tried creating a lightbox that would expand when the user input their email address. But every time I go to Preview, clicking the button does nothing, no transition occurs from the first state. I think I enjoy the layout of this method best, which is perhaps why I am reaching for help now, in a reluctance to move on and find other ways. This is what the full code looks like right now; any help in figuring out what I've done wrong or a more effective way of achieving the above would be greatly appreciated.
![](https://static.wixstatic.com/media/a27d24_9d7b65c2f54c4e989c6948deea42eb51~mv2.png/v1/fill/w_49,h_23,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/a27d24_9d7b65c2f54c4e989c6948deea42eb51~mv2.png)
Thank you all in advance!