As a rule, dogs will not relieve themselves where they eat and sleep, except those in a pet shop. They have been raised in cages and never saw the outdoors. They know no other place to pee and poop. He looks young enough, that he may be trainable, but don't count on it. Once a dog learns the wrong way, it is hard to break. Get a good book on crate training, this may be the only way you will be able to teach him. Keeping him confined to a very small space will make him "hold it", then when it is time to eat to do anything, the very first thing you will do is to pick him up, take him outside and place him on the grass. Let him sniff around, and he may relieve himself. If he does, lots of praise and fun and games are in order. Hopefully he will get the picture.
Pet shops are very bad places to buy a pet. These animals do not have the proper social interaction that you get when you buy from a breeder. They have no other choices other than to relieve themselves where they spend their time. They are poked at, sometimes hurt, and subjected to many things by customers of the pet shop.
I have bred and raised Shetland Sheep Dogs (Shelties)in the past, and every puppy I sold, I made sure the dog's personality matched the adoptive family. I would allow them to spend as much time with the pup as needed to make sure that both dog and person matched. When my pups where taken home, they were already halfway housebroken, and knew to hold it as long as possible and to go outside.
Raising a good dog starts at birth.