Shipping Discount Function Showing Errors

I have been attempting to set up a “ShippingDiscount” function for a client.

Each time I do so, it comes back with the following error: -

Build failed with 1 error: │> │ extensions/shipping-discount/src/run.js:2:9: ERROR: No matching export in │> │ “extensions/shipping-discount/generated/api.ts” for import “DiscountApplicationStrategy” │> │ │> │ To investigate the issue, examine this stack trace: │> │ at (extensions/shipping-discount/src/run.js:2) │> │ import { DiscountApplicationStrategy } from “../generated/api”; │> │ at failureErrorWithLog (esbuild/lib/main.js:1650) │> │ let error = new Error(text); │> │ at (esbuild/lib/main.js:1058) │> │ const error = failureErrorWithLog(“Build failed”, originalErrors.concat(onEndErrors), │> │ originalWarnings.concat(onEndWarnings)); │> │ at (esbuild/lib/main.js:1003) │> │ buildOrContextContinue(null, (result, done) => done(, ), () => { │> │ at buildResponseToResult (esbuild/lib/main.js:1056) │> │ runOnEndCallbacks(result, (onEndErrors, onEndWarnings) => { │> │ at (esbuild/lib/main.js:1085) │> │ return buildResponseToResult(response, (err, res) => { │> │ at

The problem seems to be the generated run.js is attempting to export a class named “DiscountApplicationStrategy” from the generated/api.ts file, which does not have it present.

I’ve tried adding it from a product function I had been working on but the api.ts file is reset each time the function is built.

Any advice on either a solution or workaround would be appreciated.

Rich

Hey @Richard_Peck

Thanks for flagging. Checking on this and will report back.

Hey @Richard_Peck

DiscountApplicationStrategy doesn’t appear to be part of the shipping discount API. The import line can be removed.

Thank you. This allowed me to build the function but it’s not showing any runs in the test store. Do I need to get a test store with “Developer Preview” enabled in order to trigger the Shipping Discount API?

Hey @Richard_Peck - could be a few things, here are the requirements: https://shopify.dev/docs/apps/functions

Just to highlight - this was the accepted solution as Shopify deprecated the discountApplicationStrategy input for API version 2024-01 and above: -

https://shopify.dev/changelog/general-availability-of-shipping-discount-function-api