A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Currently, applying a “collection-specific” discount to an order isn’t working as it applies the discount to an entire order. This is causing an issue around free-shipping thresholds as calculations are being based upon the order’s sub-total (before discount is applied).
The Shopify API doesn’t seem to allow the developers to retrieve order totals and be able to then apply the necessary shipping rate to that.
What our client is trying to do: Update the existing shipping function within the middleware to enable accurate calculation of order totals and apply the necessary shipping rate.
Example scenario
1 (qty) x product A @ $30 (line_price)
1 (qty) x product B @ $10 (line_price)
Sub-total $40 (sub-total price)
Discount scenario on collection (product A) = 50%
1 x product A = $15 (discounted = true) (API flag is not working)
1 x product B = $10
Sub-total $25 (CartDiscount::Percentage= 50%)
Shipping Threshold (Free Shipping when order total exceeds $25)
Expected result = Free Shipping as the 50% discount was applied to product A and the order total was $25 (or greater)
Actual result = Shipping being charged due to the 50% discount being applied to both product A & B.
Reference (if we need to reference the relevant hooks in the Shopify API docs)
.discounted? (LineItem)
Boolean
Returns whether the price of a line item has been discounted by a script or a manually applied discount. The use of discount codes doesn't affect the return value.