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:
Best way to do that is to use arrays. Because they have map and unique.> > This code will return array of unique product IDs> >
> *{% assign uniqueProductIdsArray= cart.items | map: 'product_id'| uniq %}*>> > This code will return concatenated string of unique product IDs> >> *{% assign uniqueProductIdsString= cart.items | map: 'product_id'| uniq | join: ', ' %}*>
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)?