It takes a lot of patience to handle such a situation. Potty training is "a must" when kids turn 2. But better late than never. Prolonged use of Diapers can lead to this problem.
1) Try giving her a mashed banana every night. Sure shot, He will be able to poop in the morning while you take him to brush his teeth. Try give him a bath as soon as he brushes his teeth.
2) Buy him a fancy Car model Potty trainer from the fancy stores. Tell him there is no diaper and he needs to poop only there. Sit in the bathroom with him and spend time while he is trying to poop.
3) Minimize or Stop the use of Mobile Laptop or Tablets since they take off their attention and they will lose their concentration of what they are doing.
Practice daily morning it'll take hoursafter that it'll be in pract