Adding a Tax Order modifier throws SQL error, missing sort column #196

NobrainerWeb opened this Issue Nov 13, 2013 · 3 comments


None yet

2 participants


So i just added GlobalTax to OrderModifiers:
GlobalTaxModifier::set_for_country('DK', 0.25, 'VAT', 'exclusive');

This gives me the following error, but the tax does show up in the template below the error message:
(Also described here, but i see no solution:

[User Error] Couldn't run query: SELECT DISTINCT "OrderAttribute"."ClassName", "OrderAttribute"."Created", "OrderAttribute"."LastEdited", "TaxModifier"."Rate", "OrderAttribute"."ID", CASE WHEN "OrderAttribute"."ClassName" IS NOT NULL THEN "OrderAttribute"."ClassName" ELSE 'OrderAttribute' END AS "RecordClassName", "Sort" FROM "OrderAttribute" LEFT JOIN "TaxModifier" ON "TaxModifier"."ID" = "OrderAttribute"."ID" WHERE ("TaxModifier"."ID" = 15) AND ("OrderAttribute"."ClassName" IN ('TaxModifier','FlatTaxModifier','GlobalTaxModifier')) ORDER BY "Sort" ASC, "OrderAttribute"."Created" ASC LIMIT 1 Unknown column 'Sort' in 'field list'

Any fix for this?
I see the demo can show tax and does not throw the error?


I got rid of the error message by changing line 52 of OrderModifier.php into:
public static $default_sort = ""Created" ASC"; //"Sort" ASC, throws a mysql error, see:

(Removing the part about Sort)

No idea what other problems this might bring

Hey, Thomas, I ran into this as well. I think this one is also a Silverstripe bug (silverstripe/silverstripe-framework#1682?source=cc) that doesn't show signs of getting fixed either. I used pretty much the same solution as you but if you do it via yml you don't have to change any core files:

  default_sort: '"Created" ASC'
  default_sort: '"Created" ASC'
  default_sort: '"Created" ASC'
  default_sort: '"Created" ASC'

Hey Mark, thanks for getting back on this - i think you are right, this is a SilverStripe bug.
I will use your solution, better than changing core files :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment