Yes, there certainly foreign volunteers fighting in both World Wars. Examples include the Lafayette Escadrille of American Fighter pilots in World War One and the Flying Tigers and Eagle Squadrons flying for the Chinese and Royal Air Forces respectively during World War Two.
Article 1 of the Annex to the Hague Convention (II) on the Laws and Customs of War on Land:
The laws, rights, and duties of war apply not only to armies, but also to militia and volunteer corps, fulfilling the following conditions:
To be commanded by a person responsible for his subordinates;
To have a fixed distinctive emblem recognizable at a distance;
To carry arms openly; and
To conduct their operations in accordance with the laws and customs of war.
In countries where militia or volunteer corps constitute the army, or form part of it, they are included under the denomination "army."
The Hague Convention (1899) II - With Respect to the Laws and Customs of War on Land and its Annex, largely based on the Lieber Code adopted by the Union Army in 1863, was the equivalent to today's Geneva Conventon in effect during World War One. The difficulty that volunteer mercenaries encountered in attempting to , and proving compliance with, the requirements of Article 1 above had the effect of forcing these militias to seek and obtain commissioning from appropriate authorities for nations involved in the conflict.
My answer to the question on the Customs/Consensus Regarding Irregular Combatants in the 19th Century provides additional background.