Accessing order metafields in order status page

Solved

Accessing order metafields in order status page

JPastorOnestic
Shopify Partner
12 2 3

Hello, I'm just trying to create a brand new extension for adding some fields, these fields are stored in order metafields and I can show them in "Thank you page" through `storage` object, but this does not work in order status page.

JPastorOnestic_1-1701085324266.png

 

Order is already created and using the `useOrder` function in order status react component  i can get only order's `id` and `name`: https://shopify.dev/docs/api/checkout-ui-extensions/2023-04/apis/orderstatusapi#properties-propertyd... .

JPastorOnestic_0-1701085191474.png

I need to show this data just after the customer address, but Storefront API does not have a method for retrieving orders. I though that maybe i must retrieve customer with Storefront API, and inside customer trying to retrieve the order by ID, but don't know also how to obtain the customer access token: https://shopify.dev/docs/api/storefront/2023-04/queries/customer

I think it's a bit weird having only `id` and `name` inside order object data, i don't think it's about protect personal data, because the order status page also contains whole addresses and customer data. In reference talks about using Admin API, but I think that is not available inside checkout UI extensions.

If there is some way (or not) for obtain these metafields inside order status page, please tell me :). Thanks in advance.

Accepted Solution (1)
JPastorOnestic
Shopify Partner
12 2 3

This is an accepted solution.

Hello, i'm rechecking this post after a few time but seems there is not response from Shopify staff, but just checked the new API 2024-01 and seems that have great news and now we can access some more orders data: https://shopify.dev/docs/api/checkout-ui-extensions/2024-01/targets/block/customer-account-order-sta...

I will give a try to this, hope this helps you too 🙂

View solution in original post

Replies 8 (8)
JPastorOnestic
Shopify Partner
12 2 3

Thanks! If you need some more info just ask me.

FePixie
Shopify Partner
30 2 7

you could maybe try something liquid like this in the checkout scripts?

<script>
if ('{{order.fulfillment_status}}' == 'unfulfilled') {
var otext = '{{order.metafields.custom.delivery_date | date: "%a, %b %d, %Y"}}';
if (otext!='') {
Shopify.Checkout.OrderStatus.addContentBox('<h2>Current ETA for your order items:</h2>',otext);
}
}
</script>

 

JPastorOnestic
Shopify Partner
12 2 3

Thanks for your feedback :D, checkout liquid will be outdated soon (https://changelog.shopify.com/posts/the-checkout-liquid-theme-file-is-being-deprecated) i'm trying a pure extension app for doing the stuff.

Thank you page have the local storage trick for avoid querying by passing the info from checkout, but this trick won't work in status page. Help is appreciated, this can be a temporary solution 🙂 but I think it should exist a pure extension solution.

FePixie
Shopify Partner
30 2 7

not in the theme liquid file - put it in the checkout scripts admin place

under settings -> checkout

is that bit being deprecated too?

JPastorOnestic
Shopify Partner
12 2 3

I think you are talking about additional scripts input, it can be a good workaround, but won't be bundled when installing the public app.

If nobody have a better solution (integrated in app i mean) in a few days i will give a try to your idea. Thanks for your time! 🙂

obviousrequest
Shopify Partner
7 0 0

any news on this? i have almost the same issue (except for the placement)

I want to provide invoices and other (order-individual) files for the customer to download from th eorder details page.
alas i think the checkout script method does not work.

I know there are invoice apps but they all want to generate the invoice. i JUST want to attach a file to the order and enable the customer to download this file.

this does not seem to work:
https://help.shopify.com/en/manual/orders/status-tracking/customize-order-status/order-status-javasc...

JPastorOnestic
Shopify Partner
12 2 3

This is an accepted solution.

Hello, i'm rechecking this post after a few time but seems there is not response from Shopify staff, but just checked the new API 2024-01 and seems that have great news and now we can access some more orders data: https://shopify.dev/docs/api/checkout-ui-extensions/2024-01/targets/block/customer-account-order-sta...

I will give a try to this, hope this helps you too 🙂

OFB
Shopify Partner
3 0 0

I still don't have access to metafields in the Order Status Page.

Did you manage to get access to them?