With the ShopFields app you can capture information in Shopify Point of sale and apply it to the customer as a tag or metafield. This could be data like a referral code to track how a customer found out about you or run an affiliate program.
With ShopFields and Shopify Flow, tags can easily be added to a customer’s profile when a new point of sale order has been created. Using an extra step we can also update any existing tags so that the customer’s referral code is kept up to date with their most recent in store purchase.
In this example we’re using customer tags, but you might find metafields better to work with.
Here’s our list field we’ve created by opening the ShopFields app in the Shopify admin:
The main things to note are:
Using Shopify Flow we can create an automation that will:
We use Shopify’s Liquid template language to filter out the tags we need.
For removing the tag we just want to see if any of the customer’s existing tags contain ‘referral’:
{% for tag in order.customer.tags %} {% if tag contains 'referral' %} {{ tag }} {% endif %} {% endfor %}
For adding the tag we want to find the right attribute based on the ‘referral’ key we set when creating our field in the ShopFields app, and then create our final referral:code tag:
{% capture referralCode %}
{% for attribute in order.customAttributes %}
{% if attribute.key == 'referral' %}
{{ attribute.value }}
{% endif %}
{% endfor %}
{% endcapture %}
referral:{{ referralCode | strip}}
Switch on the Flow and you’re good to go. You can open up point of sale, add a customer and products to your cart and then add the custom field.
If you’re running into issues, the first thing to check is the Flow run history. Make sure it’s firing as expected. ChatGPT is useful for generating liquid snippets, but I found it hallucinated with liquid a bit so I would use version >4.0.