How to return an array of product ID strings with liquid variables?

Hi!

I’m in the midst of setting up retargeting tags for the purchase conversions. Part of a tag I need to set up requires me to list strings of all product ID’s of products in the cart.

As an example, say I have 3 products with the following ID’s:

123

456

789

I’d need to return these in an array of strings like so: ‘123’,‘456’,‘789’ .

I stumbled upon a stackoverflow thread that helped me get part of this done: https://stackoverflow.com/questions/46922316/get-an-array-of-product-id-that-are-in-the-cart

This setup allows me to get an array of product id’s (so just “123,456,789”) and I can of course simply add apostrophes to the beginning and end of this list of product id’s, but unfortunately this an incorrect syntax in this instance. How could I return these ID’s joined by commas and wrapped in apostrophes (each ID separately)?