Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Collection discounts - API not returning value

Collection discounts - API not returning value

ma_craig
Shopify Partner
1 0 0
Hey guys,
 
Our client is having issues around shipping rates not relating to collection discounts. From our review, 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.
 
Scenario: 

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)

 

Shopify Scripts API reference

 

.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.

Replies 0 (0)