Vinnovera

Shopify - Adding meta data to a product

Alexandra Bjelkholm | | Shopify, Hacks

While developing a Shopify site we encountered the issue of wanting to add custom content or meta data to a product page. There weren't any options in the product settings that matched what we wanted to achieve - adding product specific pdf-files and movies.

The option we found to be suggested was to use metafields, a module for Shopify, but we didn't want to make a big hassle of poking around in the Shopify API.

Our solution? We decided to use the product tags. If we wanted to add a pdf-file to a product we added the tag file:filename.pdf or if we wanted to add a video we wrote video:youtubeID. By doing this we could with ease control what was added to each product.

Code example for tags containing video:

{% for tag in product.tags %}
    {% if tag contains 'video:'%}
        <div>
            <iframe src="http://www.youtube.com/embed/\{\{ tag | replace: 'video:', ''\}\}"></iframe>
        </div>
    {% endif %}
{% endfor %}
Alexandra Bjelkholm

Alexandra Bjelkholm

(alexandra@vinnovera.se)

Alexandra Bjelkholm jobbar som front-end utvecklare på Vinnovera.

Vi är specialister på front-end och ser gränssnitt för desktop, surfplattor och mobiltelefoner som vårt hantverk. Vi vill jobba med kunder som tycker att kvalitet är viktigt, tänker långsiktigt och vill skapa webbupplevelser med det där lilla extra.

Tillbaka till bloggen | Mer om Vinnovera

Kommentera