Show/Hide Button on Dynamic page depending on if data field is empty

Hi, (novice coder here). I followed this tutorial
and it doesn’t work for my situation, I guess.

I have a Dynamic page with movie listings. I want to hide the BUY TICKETS buttons (ticketUrl1 and ticketUrl2) if there is no ticketUrl in the database for that item.

Here is my code:

$w . onReady (() => {
$w ( “#dynamicDataset” ). onReady (() => {
const item = $w ( “#dynamicDataset” ). getCurrentItem ();
if (! item . ticketUrl ) {
$w ( “#ticketUrl1” ). collapse ();

        $w . onReady (() => { 
$w ( "#dynamicDataset" ). onReady (() => { 
    const  item  =  $w ( "#dynamicDataset" ). getCurrentItem (); 
    if  (! item . ticketUrl ) { 
        $w ( "#ticketUrl2" ). collapse (); 
} 

});

$w . onReady (() => {
$w ( “#dataset1” ). onReady (() => {
const item = $w ( “#dataset1” ). getCurrentItem ();
if (! item . ticketUrl ) {
$w ( “#ticketUrl1” ). collapse ();

        $w . onReady (() => { 
$w ( "#dataset1" ). onReady (() => { 
    const  item  =  $w ( "#dataset1" ). getCurrentItem (); 
    if  (! item . ticketUrl ) { 
        $w ( "#ticketUrl2" ). collapse (); 

            } 

});

What am I doing wrong? I have no idea what I’m doing, btw.