For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
Hello everyone, I tried to call a hook in a checkout UI extension and it returned this:
Uncaught CheckoutUIExtensionError: You can only call this hook when running as a UI extension.
Can anyone tell me what is going on? because I'm already in a checkout UI extension so I don't know why this happen
Hi TuanDangA,
If you're certain that you're using the hook in the correct context (ie: as a UI extension) then there's a couple other things you could try for troubleshooting this error message:
Try these and let us know if you're still seeing issues.
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Thank you Liam for replying, here is my code:
the version:
What would you say is the difference between a parent hook and a child hook?
I have encountered the same issue as well, and I believe this might be a bug that was left behind during the development process.
I am getting the same error, but only with my app deployment, not in the development store. Of course, when it's deployed, I don't have access to any debugging information. I get the following:
CheckoutUIExtensionError: You can only call this hook when running as a UI extension.
sl @ extensions.shopifycd…<name>-4:7
The above error occurred in the <Ti> component:
at Ti (https://extensions.shopifycdn.com/partners-extensions-scripts-bucket/ui_extension/112245932033/versi...<name>-4:12:12035)
at mi (https://extensions.shopifycdn.com/partners-extensions-scripts-bucket/ui_extension/112245932033/versi...<name>-4:11:14233)
componentDidCatch @ extensions.shopifycd…tvape-checkout-4:11
extensions.shopifycdn.com/partners-extensions-scripts-bucket/ui_extension/112245932033/version/<name>-4:12 Uncaught CheckoutUIExtensionError: You can only call this hook when running as a UI extension.
CheckoutUIExtensionError: You can only call this hook when running as a UI extension.
sl @ extensions.shopifycd…<name>-4:7
The above error occurred in the <Ti> component:
at Ti (https://extensions.shopifycdn.com/partners-extensions-scripts-bucket/ui_extension/112245932033/versi...<name>-4:12:12035)
at mi (https://extensions.shopifycdn.com/partners-extensions-scripts-bucket/ui_extension/112245932033/versi...<name>-4:11:14233)
componentDidCatch @ extensions.shopifycd…<name>-4:11
extensions.shopifycdn.com/partners-extensions-scripts-bucket/ui_extension/112245932033/version/<name>-4:12 Uncaught CheckoutUIExtensionError: You can only call this hook when running as a UI extension.
What is going on? And how can I debug this? I can't even tell which hook it is.
I am having the same issue. I am using api version 2024.4.1. It does not make much sense as an error since the hook could not really be imported and used anywhere other than a UI extension...