Soldato
And is that illegal after being given permission? Please answer yes or no.
You can't ask a loaded question and get away with it here
You are bleating about the sale of goods act but as far as I can see you don't understand that or any form of contract law.
Generally speaking, title of goods passes when both parties intend it to pass. I don't have my copy of the Costco T&Cs to hand but I suspect that a condition of the completion of the contract will be once you have passed through that last step where they check you have everything you are supposed to have (and nothing more).
Contractuals aside, they of course cannot 'detain' you unless they suspect you are committing a criminal act by leaving - which they were as you had a trolley full of goods with no proof you had paid for them. If you had protested your right to leave, the Police would have been called and again if you had no proof you had purchased those goods you may have been arrested.
As it happens, the other member of your party had the proof and when it was shown you were allowed to leave. I do not see the problem, at all - other than you being an internet whingebag of course.