How to format and read a text file for tag-linked dynamic promo messages in product page

How to format and read a text file for tag-linked dynamic promo messages in product page

David_Farkas
Shopify Partner
2 0 2

Alright, here is what we do now:

 

1) Populate a product metafield promotion.offer with text to display on product page under the item title. This method works but is tedious since every product with that promotional offer needs to be manually entered into the metafields editor.  And when the promotion is over, it needs to be deleted one by one for each product. It's also a pain if we want to edit the promotional message for multiple products. 

 

2) Hard code variables in product.liquid to look for a specific product tag, then display the promotional text. Changing the text is simple and the code can be commented out after expiring. But the tags still have to be deleted and the product.liquid page is junked up with extra code. 

 

What I'd like to do:

 

Have a text file or liquid file with all of our current promotions and valid dates by product tag name. Products would still have to be tagged but once the end date is hit, the message will no longer be displayed. The file could look something like this:

 

<--

promotionTag

promotionOffer

promotionStartDate

promotionEndDate

-->

 

Save750

Save $750 on select products through April 30, 2023. Read more <a href="some URL">here</a>, or <a href="mailto:[email protected]?subject=Save%20750%Promotion">Email us</a>

2023-04-01

2023-04-30

 

FreeCase

Get a free case, or carrying strap, when you buy a camera.<p><p>Read more <a href="some URL">here</a>, or <a href="mailto:[email protected]?subject=Free%20Case%Promotion">Email us</a>

2023-02-01

2023-06-30

 

A couple challenges.

 

1) We could have multiple promotions going on simultaneously, some current, some upcoming and some expired. I need to store multiple variables for each one based on the tag as the primary ID.

 

2) We use a lot of HTML and special characters in our promotion text. This makes using the split function a little tricky. The offer text is also usually long, which would make putting all the text in line hard to enter, read or edit. 

 

3) The file needs to be human readable by a non-programmer.

 

I've searched and searched and no one seems to have tried this before, or asked about it. Any ideas? 

Replies 0 (0)