How to call a metafield value on the checkout page in shopify

898 Views Asked by At

I'm trying to display the item data from the metafield on the checkout page using this code-

{{ pages.package-urls.metafields.custom.checkout_message }} on checkout.liquid file.

We are using Shopify Plus and the metafields are displaying on other templates fine.

1

There are 1 best solutions below

2
On

As usual, you are falling victim to the documentation. Since you want to display a metafield, if you truly know it has a value, you have to express you want the value. I think your attempt at using the pages object is mis-guided, as checkout is not a page, but, you may be right there, and it may in fact be available in checkout. Anyway, tack on a value.

{{ pages.package-urls.metafields.custom.checkout_message.value }}

As you read your metafield out backwards though, you will see that you are breaking all kinds of rules. Specifically. A metafield resource has a value. It has a key (checkout_message), it has a namespace (custom) and it has a parent resource (metafields in Shop, or Product, or Page).

So what are you doing with package-urls and pages? Strange stuff. I think you might want to anchor this to the Shop. That will likely work a lot better.