I want to do something similar but can't get mine to work. Basically, some of my books have downloadable excerpts and some do not.
I have created a custom field in the ps4_products database called ProductExcerpt. If the book has an excerpt, then the name of the excerpt is in the ProductExcerpt field. If there is no excerpt for a specific book, there is nothing in that field.
I want to make it so that if there is an excerpt, there will be a link to the the pdf showing "Read excerpt". If there is not an excerpt, I don't want anything to show.
if ($ProductExcerpt['ProductExcerpt'] = !"")
echo '<a href="https://mywebsite.com/excerpts/'.$ProductExcerpt['ProductExcerpt'].'.pdf">Read excerpt</a>';
It seems simple but I just can't get it to work.
Thanks for any responses.