Let’s imagine that our client wants to see the stock availability of an item in a faster and simpler way. He asks us to show on the Item page a red, green, or yellow sign if the stock is negative, positive or zero. With the Media type issue, we couldn’t help him, but with the Unicode Characters we can go around it, inclusive with a more performant solution.
First, we have created an extension of the Item table adding a new text field that will receive our Unicode Characters.
Then we have created an Enum that has the colors that we want.
After this we created a function that returns the Unicode Characters as text.
To finish we did a comparison to turn our positive, negative or zero stock into the colors that we wanted to show.
As a result, we get our Item page showing the signal colors depending on the stock inventory.