Morocco has the best train in Africa. Tangier to Casablanca has high-speed train (TGV) service, and Casablanca has a shuttle train (French: Train Navette Rapide, "Fast Shuttle Train"in English, more commonly known as the "TNR" or "Aouita") to Kenitra (via Rabat), El Jadida, Settat and Mohammed V International Airport (it is renamed Al Bidaoui).
The first way is to buy a ticket at the train station.
The second way is buy ticket at on the official website, you'll need google translate if you don't understand French.
The third way is book by phone, When you're in Morocco, you can also book by phone on 0890 20 30 40, but this number is not accessible from overseas.
But one thing I must mention everyone is Supratours, the bus company, a subsidiary of Moroccan railways. You can buy combined train+bus tickets from any Moroccan railway station if your destination has no rail service.
Fares are pretty cheap by European standards.
Children aged 0-3 travel free, children aged 4-10 travel at half fare, children aged 11 and over pay the adult fare.
More details please visit https://www.oncf.ma and https://www.oncf-voyages.ma/
Morocco Train Transportation Africa
This tour is a private tour, and it starts in Marrakech city and ends in Fes city vis The Sahara Desert
Camel trekking , Private 4WD with A/C, Desert Camp, Pick up and drop to and from you hotel