Depending on how the store is set up, it could mean any of the following.
Can I buy two cupcakes?
Will you pass me two cupcakes so that I can buy them?
I would like to buy two cupcakes.
but also your examples, especially take and give me.
The better way and slightly more formal way would be to say "Can I have two cupcakes, please".
Hope that helps.