Skip to content

Instantly share code, notes, and snippets.

@resistorsoftware
Created July 3, 2015 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save resistorsoftware/b974409af75703542bf3 to your computer and use it in GitHub Desktop.
Save resistorsoftware/b974409af75703542bf3 to your computer and use it in GitHub Desktop.
Problems with Shopify Discount Reporting
Raw Data From a Sale
[{
"gift_card"=>false,
"id"=>1646486209,
"price"=>"439.00",
"product_id"=>417517185,
"quantity"=>1,
"taxable"=>true,
"title"=>"something",
"variant_id"=>1094405469,
"vendor"=>"Scooby Doo",
"name"=>"Something",
"total_discount"=>"0.00",
"tax_lines"=>[
{"price"=>"65.22", "rate"=>0.2, "title"=>"VAT"}],
},{
"gift_card"=>false,
"id"=>1646486273,
"price"=>"30.00",
"product_id"=>150695799,
"quantity"=>9,
"taxable"=>true,
"title"=>"Another thing",
"variant_id"=>4275725505,
"vendor"=>"Voodoo",
"name"=>"Whatchamacallit",
"total_discount"=>"0.00",
"tax_lines"=>[
{"price"=>"40.11", "rate"=>0.2, "title"=>"VAT"}]
},{
"gift_card"=>false,
"id"=>1646486337,
"price"=>"212.00",
"product_id"=>239131205,
"quantity"=>1,
"taxable"=>true,
"title"=>"Last in the Pipe",
"variant_id"=>543395261,
"vendor"=>"Smoking",
"name"=>"Fire in here",
"total_discount"=>"0.00",
"tax_lines"=>[
{"price"=>"31.50", "rate"=>0.2, "title"=>"VAT"}]
}]
"total_discounts" = "100.00"
"total_line_items_price" = "921.00"
"total_price" = "869.00"
"total_price_usd" = "1356.46"
"total_tax" = "144.83"
So in this case, the 100 discount was applied how? Inside magic. It was spread across the three line items, and each was discounted. Why is this not reported? The taxes provide a clue, but we all know messing with taxes will only buy us grief as we lose pennies in rounding and going backwards, ensuring the math never adds up.
Item 1. Instead of 86.60 in tax, shows 65.22, meaning a selling price of 391.32 and NOT 439.
Item 2. Instead of 45.00 in tax, shows 40.11, meaning a selling price of 240.66 and NOT 270.
Item 3. Instead of 35.33 in tax, shows 31.50, meaning a selling price of 189.00 and NOT 212.
So now we can see where the $100 went, but why is this not evident in the total_discount per line item field!!! They are all ZERO. Which is wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment