Discussing Shopify Functions development, deployment, and usage in Shopify apps.
I scaffolded a new product-discount extension function today and the shopify.app.toml file reflects api-version 2024-01 and the shopify.extension.toml file shows api_version 2023-10. The product-discount package.json shows app and cli versions 3.53.0.
I would like to use the new discountApplicationStrategy of All per https://shopify.dev/changelog/new-discountapplicationstrategy-option-for-product-discount-function-a... which states: EFFECTIVE JANUARY 01, 2024 The Product Discount Function API now supports setting discountApplicationStrategy to "ALL" in the FunctionRunResult.
Unfortunately, All is not a recognized discountApplicationStrategy option. I tested in my actual function code on a test store which confirms that upon running the app, All is not a recognized discountApplicationStrategy option.
InvalidOutputError
[
{
"path": [
"discountApplicationStrategy"
],
"explanation": "Expected value to not be null"
}
]
I attempted to manually modify the shopify.extension.toml file to use api_version 2024-01, re-ran the dev command and tested, but the same behavior occurred. How do I update my function to use the new discountApplicationStrategy of All?
Solved! Go to the solution
This is an accepted solution.
If you are upgrading an extension to a new API version, be sure you've followed all the steps here, including pulling the latest schema:
https://shopify.dev/docs/apps/functions/input-output#api-versions
Nick Wesselman | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
This is an accepted solution.
If you are upgrading an extension to a new API version, be sure you've followed all the steps here, including pulling the latest schema:
https://shopify.dev/docs/apps/functions/input-output#api-versions
Nick Wesselman | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hello!
I am experiencing an issue similar to the one described in this post regarding the use of the DiscountApplicationStrategy.All in Shopify Functions. Despite updating to the 2024-07 version as suggested in the solution, the problem persists.
The error message I'm encountering is:
[ { "path": [ "discountApplicationStrategy" ],
"explanation": "Expected value to not be null"
}
]
It appears that DiscountApplicationStrategy.All is still not recognized or correctly implemented. Shopify only seems to accept FIRST and MAXIMUM as valid options, not ALL.
have ensured that all dependencies are up-to-date and that I am indeed using the 2024-07 API version. Despite these efforts, the error persists, preventing the application of multiple discounts.
Any guidance or suggestions on resolving this issue would be greatly appreciated.
DiscountApplicationStrategy.All has worked for me as of the April release. Below is a snippet of my return code if it helps.
return {
discounts: [
{
targets: targets0, // Apply the discount to the collected targets
value: {percentage: {value: discount0}} // Define a percentage-based discount
},
{
targets: targets1,
value: {percentage: {value: discount1}}
},
],
discountApplicationStrategy: DiscountApplicationStrategy.All
};