Customer Reference Type Metafield

Hey all!

I have noticed in the Shopify admin settings there is a new field type Customer which can be singular or a list. However, when I look at the .dev documentation there seems to be nothing at all about this data type, such as its usage and the data returned. The only thing I can find is the list limitations.

I brought this up in the Partner slack, and someone had mentioned that trying to reference these fields in a theme return null values, which to make makes sense as you could unintentionally leak customer data. I could see this field type as being useful for “two way” references, for example membership application metaobjects that are referenced by a customer via metafield, and then the metaobject itself having a direct reference to the customer related. On the theme side, I don’t really know how it would reasonable work other than “you are not his associated customer, so you need to leave now” gating.

While I do not know the best use case for this metafield type (maybe associating custom generate products to the customer that made it?), I am hoping this slowly opens us up to a customer_segment reference type, which would be extremely helpful for Online Store content gating.

Is anyone using this data type yet?

I was trying to use it to link collection visibility to customers via a 1:1 match with the logged in customers.

Now I cannot remember but I believe it was working in a way of checking customer.id != to the customer ID from the metafield.

The setup was adding the collection links to the menu if in the metafield on the customer and then checking the matching customer ID within collection code to show the products if match or a “you need to login” message if not a match.

The client did switch to the new customer accounts the other day and now when I login I cannot even tell I’m logged in on the storefront. Using Dawn, the link still says “Login” when I have logged in and the collection products do not show (not linked to metafield on collection), and the products should show unless there is no customer logged-in or the metafield has a value and the value does not match the logged-in customer ID.

I’ll try again on a development store later to see if I can get it to work and report back.

Maybe this could be used for customized pricing or discounts? A B2B hack for non-plus shops.

I could see storing a customer reference to a product for some kind of promotional / discount / allowed to buy scenario, but I feel like wouldn’t we just use customer tags or something for that?

Customer lists, like all except Metaobjects, have a limit of 128 references. Seems like a lot of lists to manage, but I don’t know.

In my case I am seeing the customer reference value with .value | json and so I can get the ID from something like this:

assign customer_id = collection.metafields.custom.customer.value | json | split: '/' | last | plus: 0

Then compare that to the logged-in customer in my case.

I needed to adjust the code a tad but it’s sufficient for my use case.

1 Like