Shopify / function-examples

MIT License
186 stars 53 forks source link

discountApplicationStrategy with `All` Type not working when using with multiple variants #494

Closed chesterwu closed 6 months ago

chesterwu commented 6 months ago

Discussed in https://github.com/Shopify/function-examples/discussions/490

Originally posted by **jacknavynicy** April 25, 2024 I have a app that with a function that will have a output of below: ``` { "discountApplicationStrategy": "ALL", "discounts": [ { "value": { "percentage": { "value": 20 } }, "targets": [ { "productVariant": { "id": "gid://shopify/ProductVariant/46960668311869", "quantity": 5 } } ], "message": "Volume discount" }, { "value": { "percentage": { "value": 10 } }, "targets": [ { "productVariant": { "id": "gid://shopify/ProductVariant/46960668311869", "quantity": 3 } } ], "message": "Volume discount" } ] } ``` This do working as expected, the two discounts is applied correctly, the following is the result ![image](https://github.com/Shopify/function-examples/assets/133320093/8cec1f3b-9ac1-47c7-94a2-4e6cd00cf75e) but when it involved with multiple variants, the second's discount is not applied correctly, the following is the output and result ``` { "discountApplicationStrategy": "ALL", "discounts": [ { "value": { "percentage": { "value": 20 } }, "targets": [ { "productVariant": { "id": "gid://shopify/ProductVariant/46960668311869", "quantity": 3 } }, { "productVariant": { "id": "gid://shopify/ProductVariant/46960668377405", "quantity": 2 } } ], "message": "Volume discount" }, { "value": { "percentage": { "value": 10 } }, "targets": [ { "productVariant": { "id": "gid://shopify/ProductVariant/46960668311869", "quantity": 3 } } ], "message": "Volume discount" } ] } ``` ![image](https://github.com/Shopify/function-examples/assets/133320093/f9b138d7-8265-4ec3-baf4-6dc521aecac6) Do anyone faced the same issue? I did tried with couple different structure(eg: each variants in different discount individually, and each discounts have same type of variants but put zero if no discount, but zero is not allowed in quantity) Do let me know if I am doing something wrong on the output or if there is a bug here.
nickwesselman commented 6 months ago

Hi @chesterwu! Please report bugs with Function APIs on Community. Issues on these OSS repos should be directly related to the code within.

meandillar commented 3 months ago

@nickwesselman I found that this bug was reported on the community forum here as you proposed but has zero responses. What do you suggest? I am experiencing the same issue.

EDIT: link to community post added