Skip to content

Instantly share code, notes, and snippets.

@asherrard
Last active December 9, 2022 19:34
Show Gist options
  • Save asherrard/618309537d8614c45340f6edcf971aca to your computer and use it in GitHub Desktop.
Save asherrard/618309537d8614c45340f6edcf971aca to your computer and use it in GitHub Desktop.
Salsify Variant name and option formula for shopify
## Because picklists have 2 values whether referencing the PATH_ID or the PATH_Name you can split them.
## The Id's will be the variant option names and the Names, will be salsify properties for pulling out values
## Salsify Picklist Property needs to be setup like the following -
ID: Color,Size,Number Of Items
Name: shirt_color,shirt_size,qty
##VALUE 2
let variantProperty = SPLIT(PATH_ID("Variant Selectors",1),',') in ##change to property of your variant selector as needed
IF(
LT(LENGTH(variantProperty),2), ##TEST to make sure only 2 options
null, ##IF only 2 options
Value(AT(variantProperty,2),1) ##Make sure to take only 1 value - change to 1,2,3 based on which variant option you are working with
)
##Option 2 Name
let variantProperty = SPLIT(PATH_NAME("Variant Selectors",1),',') in
IF(
LT(LENGTH(variantProperty),2), ##TEST to make sure 2 options exist
null, ##IF only 2 options
AT(variantProperty,2) ##change to 1,2,3 based on which variant option you are working with
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment