Shipping discount functions is not running

Shipping discount functions is not running

Bayarmagnai1
Shopify Partner
1 0 1

Hello,

I've set up a shipping discount function, but it seems like it's not working at all. There are no logs or error messages available in the partner dashboard -> app -> extension page, and there's no indication that the function has been invoked. Also, the discount is not being applied to my test orders and I didn't see any error messages when I deploy it.
Screenshot 2024-04-29 at 15.18.13.png
I'm testing this on fresh new app and store.

Here are the steps I followed to set up a new function:

1. Initialized a new Shopify app with the command: `npm init @Shopify/app@latest`.
2. Generated a shipping discount function extension by running: `npm run shopify app generate extension` and selecting 'shipping discount function' for version 2024-01.
3. Deployed the app using: `npm run deploy`.

I think if there's an issue with the code, it should be logging something. For now, I just want to see if this function is even running. Help please !

Replies 3 (3)

tobebuilds
Shopify Partner
415 28 110

Have you entered a shipping address at checkout when testing the discount?

 

If no shipping address is entered, then shipping rates can't be calculated, so discount functions aren't executed. 

Founder, Regios Discounts app (4.9 stars)
- Custom discounts made simple
- "Just about any discount you'll ever need"
- Built by an ex-Google software engineer

minichimi
Shopify Partner
4 1 1

I'm having the same issue, same steps, not able to get running.

minichimi
Shopify Partner
4 1 1

FYI @Bayarmagnai1 I got this running finally - make sure activate the discount using a GraphQL mutation with the GraphiQL app, here's mine as an example:

mutation ActivateDiscount {
  discountAutomaticAppCreate(
    automaticAppDiscount: {title: "Shipping Function Discount", functionId: “YOUR-FUNCTION-ID-FOUND-IN-YOUR-ENV-FILE”, startsAt: "2022-06-22", combinesWith: {productDiscounts: true, orderDiscounts: true}}
  ) {
    automaticAppDiscount {
      discountId
    }
    userErrors {
      message
      field
      extraInfo
    }
  }
}