order.id at "purchase.thank-you.block.render"

order.id at "purchase.thank-you.block.render"

fbritop
Shopify Partner
8 0 2

We have been trying to get the order ID from the thank.you page but it seems that it does not accept the useOrder() API.

We have notice that this is available at the order.status.

Is there a way that we can have the order id?, we need to place a button for the customer to either choose Receipt or Invoice. This button with the order ID is needed because the button will redirect to our platform for connecting with our kind of IRS (Here it is called SII), so the invoice or receipt is legaly valid.

Or at least a button that can route the customer to the status.page, where the order ID is available

 

Thanks

Replies 5 (5)

Huptech-Web
Shopify Partner
939 188 197

Hello @fbritop 

You can obtain the order ID by using the useApi() hook in the purchase.thank-you.block.render.

 

const data= useApi();
const orderId=data?.orderConfirmation?.curren?.order?.id

Screenshot (35).png

 

If the solution presented meets your needs and addresses your query effectively, I encourage you to accept it as the chosen answer. This will acknowledge the support you received and aid fellow community members in identifying reliable and effective solutions for their similar concerns.
Thank you.

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at [email protected] or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required
fbritop
Shopify Partner
8 0 2

It may be working for Javascript, but for react, the component is not found, and the selector is invalid, thats what I explain in the first post

fbritop_0-1717679329318.png

 

Huptech-Web
Shopify Partner
939 188 197

Hello @fbritop 

 

You can use optional chaining in js. it's an editor issue. 

const orderId=data?.orderConfirmation?.curren?.order?.id

I have rendered this component in the purchase.thank-you.block.render. it's work for me 

 

 

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at [email protected] or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required
Kaskalito
Shopify Partner
3 0 0

Thanks, this set me on the right path. There was one thing missing for me to make it work, adding the string argument to the useApi call

 

 

const data = useApi("purchase.thank-you.block.render");
const orderId = data?.orderConfirmation?.current?.order?.id

 

 

abhimanyu0405
Shopify Partner
3 0 1

Hi @Huptech-Web ,

Hope you are doing well.

 

I have started working on making the public app for that I have already created the partners account however I am stuck into getting the Api Scope Access, would you please help me how we can get these and how we have to upload the app on to the shopify store.scope_access (1).png

Abhimanyu Arora