Tonight being bothered by a Shopify attribute weird syntax.
Having a Gift Card product page, I want to show different UI vs normal product. I user product.gift_card
and try to obtain the boolean value for the different UI. But I keep receive nothing.
Normally I try look up the product.json by adding .js
at the end of the product URL. And I find there isn’t.
I have use line_item.gift_card
for similar purpose, which give me expected value, so I am surprised I cannot get the expected value upon calling product.gift_card.
I connect with Shopify Plus support, and they typically say it should be my theme related rather than any regression in the system. Fair-enough~
Until a moment, I spot the product.gift_card
in the developer doc has a Questionmark, i.e. product.gift_card?
where that questionmark sounds to me to be a typo. But honestly not! It is the killer character that cause me fail to get the expected boolean. I cannot find another attribute has such un-usual suffix character. And I hope you didn’t struggle too long like me.
Related links:
https://shopify.dev/api/liquid/objects/product#product-gift_card
https://shopify.dev/api/liquid/objects/line_item#line_item-gift_card