Shopify / ui-extensions

MIT License
249 stars 35 forks source link

Customer Account UI: Shop domain not accessible from Order action menu #1966

Closed marian37 closed 6 days ago

marian37 commented 1 month ago

Please list the related package(s)

@shopify/ui-extensions-react: "0.0.0-unstable" (Customer Account UI extensions)

If this related to specific APIs or components, please list them here

Is your feature request related to a problem? Please describe.

We want to provide a link in the Order action menu, where the customer can see/download the invoice generated for the order from our app. But using only order ID is not enough, we need also shop domain.

The useShop hook doesn't work as it is available only from Order status.

The Order action menu is shown on Order Index and Order Status pages and Shop data should be available on both of these pages, as I can see in the page source code the following div with the JSON:

<div data-serialized-id="shop-data" style="display: none">{"url":"...","myshopifyDomain":"...", etc.}</div>

Describe the changes you are looking for

Make shop data easily accessible from Order action menu target. Could be provided using useShop hook that is already available on Order Status targets.

Describe alternatives you’ve considered

Additional context

This is my first issue in this repo, please bear with me if I filled something wrong or haven't provided any important information :)

oluwatimio commented 1 month ago

Hello @marian37 thanks for reporting your issue, as pointed out the useShop hook is only accessible from an order status target as a result you cant use it for the order action menu. That being said, the shop data is also accessible from the customer api in development. Here's a link to a tutorial that uses the customer api and a link to customer api shop query. If you need more guidance dont hesitate to reach out again!

marian37 commented 1 month ago

Hello @oluwatimio, thank you for your response. I'll definitely try your suggestion. It would be much better to have such a hook (useShop) available, but at least it's possible to get that data :slightly_smiling_face: