Hi there,
I am trying t display some text depending on whether a user has something bookmarked.
This is what I have:
$bookmarked = \MyListing\Src\Bookmarks::exists( (int)$post_id , get_current_user_id() );
if($bookmarked){
$classes = 'bookmarked';
$bmText = "Remove Bookmark";
$fontClass = "fa fa-regular fa-heart";
}
else{
$bmText = "Add Bookmark";
}
if ( $is_caching ) {
$classes = '<var #saved></var>';
}
I am then trying to echo it out using:
$HTML .= '<div class="listing-details actions c27-footer-section">
<div > <ul> <li tooltip=" ' . $bmText . '">text</li></ul></div>';
However, I am only getting the “Bookmarked” version of text appearing.
Can anyone see what I have wrong with my if/else? I think it may be because the bookmark button AJAX/dynamic so changes when you click the button without the page loading.
Many thanks!