Skip to content

Instantly share code, notes, and snippets.

@JumboLove
Created September 5, 2013 18:10
Show Gist options
  • Save JumboLove/6453874 to your computer and use it in GitHub Desktop.
Save JumboLove/6453874 to your computer and use it in GitHub Desktop.
Iterate Upward Through Categories
var sizeChartID = null;
var category = pdict.Product.primaryCategory;
while (category !== null && sizeChartID === null) {
if (('sizeChartID' in category.custom) && !empty(category.custom.sizeChartID)) {
sizeChartID = category.custom.sizeChartID;
}
else {
category = category.parent;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment