Solved

How do I test my shopify function?

cgonzaleztyb
Shopify Partner
5 1 2

I'm currently developing a shopify app that is composed of a checkout ui extension and a shopify function. These two are meant to interact with each other via cart attributes. I have not developed any admin dashboard for the app yet.

 

I've successfully tested my react-based checkout ui extension against a development store that has Checkout Extensibility enabled by running `yarn dev` in the app root folder and navigating to the provided url that goes through ngrok. I can see my UI extension and interact with it.

 

My expectation (based on https://community.shopify.com/c/shopify-functions/interaction-between-checkout-ui-extensions-and-fun...) is that by setting cart attributes via my ui extension (

useApplyAttributeChange) I can read that from my shopify function and apply discounts based on those attributes. This is not currently working for me (do not see any discounts applied), so I'm trying to debug the function itself.
 
I have run `yarn deploy` and `yarn dev` again. I can see my function in the partners' dashboard under my app. It says it's never been run, though its status is "Published" (the UI extension which works in my dev store says "Draft").
 
When running `yarn dev`, after the checkout UI extension ngrok url I see this message which is not helpful: 

 

 

order-discounts-function-rust
These extensions need to be deployed to be manually tested.
One testing option is to use a separate app dedicated to staging.

 

 

I would expect the function to be running on the same store as my UI Extension is. What am I missing? Thanks.

 

Accepted Solution (1)
cgonzaleztyb
Shopify Partner
5 1 2

This is an accepted solution.

ok. so, i managed to get this working. i was missing the step "configure the function" in the shopify function lifecycle mentioned here: https://shopify.dev/api/functions#lifecycle-of-a-shopify-function

 

this was an extra step for my use-case that i did not think i needed, since i had understood that a shopify function is meant to return the discount nodes applicable to the cart and the configuration to provide the function as input is coming from my api backend without the need for the merchant to do any "configuration".

 

currently still testing the functionality, but everything seems to work as documented now.

View solution in original post

Replies 3 (3)

cgonzaleztyb
Shopify Partner
5 1 2

I have installed the app into my development store and have modified the function for it to return discounts by default in an effort to see anything at all, but notice no change.

 

Total # of runs for my function is still at 0. Can someone assist?

cgonzaleztyb
Shopify Partner
5 1 2

This is an accepted solution.

ok. so, i managed to get this working. i was missing the step "configure the function" in the shopify function lifecycle mentioned here: https://shopify.dev/api/functions#lifecycle-of-a-shopify-function

 

this was an extra step for my use-case that i did not think i needed, since i had understood that a shopify function is meant to return the discount nodes applicable to the cart and the configuration to provide the function as input is coming from my api backend without the need for the merchant to do any "configuration".

 

currently still testing the functionality, but everything seems to work as documented now.

tontinedev
Shopify Partner
8 0 4

I'm running into the same issue with an app we're testing, could you expand on what you did to fix it? My understanding was also that we wouldn't need to add a configuration step if the configuration was already provided elsewhere, what did you do to get this working as intended?