Flow Workflow - LineItem.totalDiscountSet returns 0 when discountAllocations has discounts

Hello @Shopify_Community ,

We want to report LineItem level order price info through a Flow workflow. Price can be obtained from LineItem.variant.price. Compare at Price can be obtained from LineItem.variant.compareAtPrice.

GraphQL lists: LineItem.totalDiscountSet MoneyBag! non-null

“The sum of all AppliedDiscounts on this line item, in shop and presentment currencies.”

  • The problem is that this does not report all discounts applied.

This example order based on a current workflow has a 15% off discount code applied with the following details:

quantity = 1

variant.compareAtPrice = 58.0

variant.price = 37.7

discount code = somediscountcode

The example order results in the following:

discountedTotal****Set = {“presentmentMoney”=>{“amount”=>37.7, “currencyCode”=>“CAD”}, “shopMoney”=>{“amount”=>37.7, “currencyCode”=>“CAD”}}

discountedUnitPriceSet = {“presentmentMoney”=>{“amount”=>37.7, “currencyCode”=>“CAD”}, “shopMoney”=>{“amount”=>37.7, “currencyCode”=>“CAD”}}

originalTotalSet = {“presentmentMoney”=>{“amount”=>37.7, “currencyCode”=>“CAD”}, “shopMoney”=>{“amount”=>37.7, “currencyCode”=>“CAD”}}

originalUnitPriceSet = {“presentmentMoney”=>{“amount”=>37.7}}

discountAllocations: {“allocatedAmount”=>{“amount”=>5.65, “currencyCode”=>“CAD”}, “allocatedAmountSet”=>{“presentmentMoney”=>{“amount”=>5.65, “currencyCode”=>“CAD”}, “shopMoney”=>{“amount”=>5.65, “currencyCode”=>“CAD”}}, “discountApplication”=>{“allocationMethod”=>“ACROSS”, “index”=>0, “targetSelection”=>“ALL”, “targetType”=>“LINE_ITEM”}}

totalDiscountSet = {“presentmentMoney”=>{“amount”=>0.0}} <— ??

The expected result of totalDiscountSet is the sum of all **LineItem.**discountAllocations however in this case it returns 0.

If this is by design and since we cannot use assign to create custom variables to loop/sum discountAllocations, how can we reliably obtain the total sum of all discountAllocations for each LineItem to correctly report the pre-tax price of an item post application of all discount reductions?

Thanks,

1 Like

You might have better luck getting this answered in a forum about discounts. Based on your findings and the description for totalDiscountSet (https://shopify.dev/api/admin-graphql/2022-04/objects/LineItem#field-lineitem-totaldiscountset), which says, “The sum of all AppliedDiscounts on this line item, in shop and presentment currencies,” I think that those lineItem discounts wouldn’t show up in that field but in discountedTotalSet.

Hi @paul_n ,

Would you be able to kindly direct us to the appropriate place? We have already been through Shopify Plus Support who directed us here for the answer. Regarding ‘discountedTotalSet’, we included it in the example results to show that it only returned the same value as LineItem.variant.price.

Thanks,

Hi, I think in the community Technical Q&A discussion is the most likely to find your answer.