Discussing Shopify Functions development, deployment, and usage in Shopify apps.
I have a Typescript Shipping Discount function which runs successfully with no errors. The discount message appears beside the shipping cost but the discount is not being applied.
Here are screenshots of the shipping options and discount message:
This is the code for my function result:
{ discountApplicationStrategy: DiscountApplicationStrategy.Maximum, discounts: [ { message: 'Shipping Discount', targets: input.cart.deliveryGroups.map(group => ({ deliveryGroup: { id: group.id, }, })), value: { percentage: { value: '100.0', }, }, }, ], }
Here is the logged Input from the partner dashboard:
{ "cart": { "buyerIdentity": { "customer": { "isPro": true } }, "cost": { "subtotalAmount": { "amount": "24.9" } }, "deliveryGroups": [ { "deliveryAddress": { "zip": "3214" }, "deliveryOptions": [ { "cost": { "amount": "0.0" }, "title": "Standard Delivery" }, { "cost": { "amount": "5.95" }, "title": "Standard Delivery (Signature Required)" }, { "cost": { "amount": "9.99" }, "title": "Same Day Delivery" }, { "cost": { "amount": "10.99" }, "title": "Same Day Delivery (Signature Required)" } ], "id": "gid://shopify/CartDeliveryGroup/0" } ] } }
Here is the logged Output of the function from the partner dashboard:
{ "discountApplicationStrategy": "MAXIMUM", "discounts": [ { "message": "Shipping Discount", "targets": [ { "deliveryGroup": { "id": "gid://shopify/CartDeliveryGroup/0" } } ], "value": { "percentage": { "value": "100.0" } } } ] }
I'm using api version 2023-07. I've also tried using 2023-01, and I've tried applying different percentages, `fixedAmount` discounts rather than percentages, and also using `FIRST` for `discountApplicationStrategy` to no avail.
Any thoughts would be much appreciated!
The discount has been applied
You can see that the total price is 24.9 not 30.85
But it is not clearly shown
I encountered the same problem. Did you find a solution?
@shoshana I think you're right. Hopefully this will be updated to make the discount obvious. Unfortunately I can't test it because as of last week my shipping discount function stopped working and both the checkout page and partners dashboard extension logs page just display errors.
My function also stopped working from last week,
On my partners dashboard everything seems to be fine. Success status is displayed
But on the checkout page I get an error every time my function returns a discount
@shoshana I've just heard back from support and they are apparently working on this issue where shipping discount functions are crashing the checkout
@shoshana Shopify has fixed the shipping discounts and it appears to be working.
The only thing I can't do now is successfully create a discount within the app using "discountAutomaticAppCreate" mutation. I get "Function not found.". It works fine in the GraphiQL app.