Prince Charming vows that he will become King of Far, Far Away and avenge the death of his mother, the Fairy Godmother. Meanwhile, King Harold is dying and his ogre son-in-law Shrek and daughter Princess Fiona are to succeed him. Shrek's attempts at trying to serve as the Regent during the King's medical leave end in disaster, and insists that an ogre as king is a bad idea and that there must be someone else to rule the kingdom. Before dying, Harold tells Shrek of another heir: his nephew, Arthur Pendragon. Prince Charming goes to the Poison Apple tavern and persuades fairy tale villains to fight for their "happily ever after" by appealing to the defeats given in their stories.
Shrek, Donkey and Puss in Boots set out to retrieve Arthur; as they are sailing away, Fiona yells to Shrek that she is pregnant. The trio journey to Worcestershire Academy, an elite magical boarding school, where they discover Arthur or "Artie" is a scrawny 16-year-old underachiever picked on by everyone. At the school pep rally, Shrek tells Artie he is going to be king of Far Far Away. Artie is excited until Donkey and Puss inadvertently frighten him by discussing the responsibilities of being king. Artie tries taking control of the ship and crashes it on a remote island, where they meet Artie's retired wizard teacher, Merlin.
Meanwhile, Charming and the other villains attack the castle, but Wolfie, Pinocchio, Gingy, the Three Little Pigs and the Blind Mice stall them long enough for Fiona and her mother Queen Lilian to escape along with Snow White, Rapunzel, Cinderella, Sleeping Beauty and Doris the Ugly Stepsister. One of the Pigs accidentally blurts out that Shrek has gone to retrieve Arthur, and Prince Charming sends Captain Hook and his pirates to track down Shrek. The ladies are put in a tower when Rapunzel betrays them because she loves Charming.
Captain Hook and his pirates track Shrek and his friends to Merlin's island, where they attempt to capture Shrek alive and defeat the others. Shrek and Artie defeat the villains, and Hook mentions Charming and the takeover of Far Far Away. Concerned for his wife and future child, Shrek urges Artie to return to Worcestershire. Instead, Artie cons Merlin into using his magic to send them to Far Far Away. The spell works, but causes Puss and Donkey to accidentally switch bodies. They find Pinocchio and learn that Charming plans to kill Shrek as part of a play. Charming's men arrive, but Artie tricks the knights into not taking them into custody and they break into the castle during rehearsals for the play. Caught in Charming's dressing room, the four are taken captive.
Charming prepares to kill Artie, believing he is the next king. To save Artie's life, Shrek tells Charming that Artie was a pawn to take his place as King of Far Far Away. Charming believes Shrek and allows Artie to leave. Donkey and Puss are imprisoned with Fiona and the ladies, where Fiona grows frustrated with their lack of initiative. Queen Lilian smashes the stone wall of the prison by head butting the walls. While the princesses launch a rescue mission for Shrek, Donkey and Puss free Gingy, Pinocchio, the wolf and pigs, Dragon and Donkey's children. They encounter Artie, and Puss and Donkey explain that Shrek lied to save him.
By nightfall, Charming stages a musical in front of the kingdom. Just as Charming is about to defeat Shrek, Fiona, along with Puss, Donkey, the princesses and the fairy tale characters confront the villains. Artie convinces the villains that just because they are being treated like losers does not mean that they have to be losers.
Infuriated, Charming lunges at Artie with his sword, but Shrek blocks the blow, so Charming attacks him instead. Shrek, who seems fatally injured, informs Charming that he needs to work on his aim and that the Prince needs to keep looking for his own happily ever after. As Shrek pushes him aside, Dragon knocks Rapunzel's tower on Charming presumably killing him. Artie is then crowned king, and takes the throne. While the kingdom celebrates, Merlin restores Puss and Donkey to their proper bodies, accidentally switching their tails temporarily. Shrek returns home to the swamp with Fiona, becoming the parents of ogre triplets.

Question: What happens to Puss and Donkey when Merlin magically transports them to Far, Far Away?
Answer: they switch bodies