Why is the 几次 in 你这个星期买东西几次了 incorrect? When trying to translate this sentence:

How many times have you gone shopping this week?

I would assume that it is:

你这个星期买东西几次了？

But apparently I put the 几次 at the wrong place? Can somebody help me understand why?
My teacher told me (if I remember correctly) it has to be:

你这个星期买几次东西了？
买 is a transitive verb; 买东西 is a separable Verb-Object structure, so the number + measure  goes between.
Examples:
to eat/ to have eaten a meal
吃飯/ 吃了一頓飯
to sing/ to have sung two songs
唱歌/ 唱了兩首歌
to shop/ to have shopped three times
買東西/ 買了三次東西
to tell a story/ to have told several stories
講故事/ 講了幾個故事
With intransitive, multi-syllabic verbs that cannot be separated, the number + measure goes after.
Examples:
to perform/ to have performed one show
表演/ 表演了一場
to complain/ to have complained quite a few times
投訴/ 投訴了好幾次