custom liquid to extract first and last name from product.title of sports card

Solved

custom liquid to extract first and last name from product.title of sports card

maxwaxpax
Tourist
3 1 0
2017 Patrick Mahomes National Treasures Rookie Signatures #RS2PM 4/99 BGS 9.5 10 0011671993

 

Assume this is the title. I have used the following to pull the year and place it in the metafield custom.year which works without issue in the Flow I created. 

What I would like to do next is pull the player name Patrick Mahomes and place this in another metafield such as custom.playername This will help to automate the population of this data and save a ton of time. I cannot seem to figure out who to make this work. 

 

This is what I put in to pull the year and had no issues. 

{%- assign prodyear = product.title | split: " " | first -%}

{{- prodyear -}}

 

No matter what I try, I cannot seem to figure out how to modify this to skip the first word and then pull the second and third words while leaving a space between them. Just when I think I can do it, I get this

 

The rendered liquid was too large or had too many assignments

Accepted Solution (1)
maxwaxpax
Tourist
3 1 0

This is an accepted solution.

I GOT IT!! HOPE THIS HELPS SOMEONE ELSE

 

{%- assign plyrname = product.title | split: " " -%}
{{- plyrname | slice: 1, 2 | join: " " -}}

 

BOOM!

View solution in original post

Replies 2 (2)

maxwaxpax
Tourist
3 1 0

ok let me say that I made some progress...with the following:

 

{%- assign plyrname = product.title | split: " " -%}
{{- plyrname | slice: 1, 2 -}}

 

The only problem now is that the result is PatrickMahomes and there is no space..I know I am missing something that is probably so simple..but my brain hurts!

maxwaxpax
Tourist
3 1 0

This is an accepted solution.

I GOT IT!! HOPE THIS HELPS SOMEONE ELSE

 

{%- assign plyrname = product.title | split: " " -%}
{{- plyrname | slice: 1, 2 | join: " " -}}

 

BOOM!