Re: Debugging in shopify function

Solved

Debugging in shopify function

hoannguyen02
Shopify Partner
23 2 2

Hi team, 

 

We are implementing delivery customization - function, seems we don't know how/where to see the console or how to debug it? could you help us? thank you very much

hoannguyen02_0-1692620477323.png

 

Accepted Solutions (2)

lizk
Shopify Staff
246 58 79

This is an accepted solution.

Hi there 👋

If you would like to have logging inside your Shopify Function in javascript you will need to use console.error("your message");

 

    if (!targets.length) {
      // You can use STDERR for debug logs in your function
      console.error("No cart lines qualify for volume discount.");
      return EMPTY_DISCOUNT;
    }

 



To view the output you will view the extension runs inside your Shopify Partner Dashboard, they can be found Your App > Extensions > Your Function Name > See Details of a specific run of the function. 

In the Logs (STDERR) section you should see your error logging.

Shopify Partners 2023-08-22 12-08-49.png

You can review the documentation for more information on debugging.

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

ndt_ts
Shopify Partner
27 3 7

This is an accepted solution.

do a 
npm run build
npm run deploy

and now check , it should work!

View solution in original post

Replies 6 (6)

lizk
Shopify Staff
246 58 79

This is an accepted solution.

Hi there 👋

If you would like to have logging inside your Shopify Function in javascript you will need to use console.error("your message");

 

    if (!targets.length) {
      // You can use STDERR for debug logs in your function
      console.error("No cart lines qualify for volume discount.");
      return EMPTY_DISCOUNT;
    }

 



To view the output you will view the extension runs inside your Shopify Partner Dashboard, they can be found Your App > Extensions > Your Function Name > See Details of a specific run of the function. 

In the Logs (STDERR) section you should see your error logging.

Shopify Partners 2023-08-22 12-08-49.png

You can review the documentation for more information on debugging.

To learn more visit the Shopify Help Center or the Community Blog.

hoannguyen02
Shopify Partner
23 2 2

Thank you very much for the support

hoannguyen02
Shopify Partner
23 2 2

Hi @lizk could you tell me how to make the See Details button appear? (lots of error don't have this button) and how to log error with data variable like 

console.error("deliveryGroups", deliveryGroups);
 

hoannguyen02_0-1692869639345.png

Thank you very much.

sebastiandev
Shopify Partner
69 1 22

Do you found solution with "See details" button?

sameed123
Shopify Partner
1 0 0

I am still unable to see the logs in payment function. Refer to the screenshots attached.

sameed123_0-1698784171256.png

sameed123_1-1698784260679.png

sameed123_2-1698784326884.png

 

ndt_ts
Shopify Partner
27 3 7

This is an accepted solution.

do a 
npm run build
npm run deploy

and now check , it should work!