Praise be to Allah.
It is permissible for the traveller to put prayers together according to the following conditions:
1. The distance [of his journey] should be the distance at which it becomes permissible to shorten prayers, which is approximately 80 km according to the majority of scholars. Some of the scholars are of the view that the distance that counts as travel is not defined by a specific distance; rather it is the matter of custom [and what is customarily regarded as travel].
Please see the answer to question 38079 .
2. According to the majority of scholars, it is stipulated that the travel should be for a permissible purpose. So if someone travels in order to rob people (banditry) or to commit immoral actions or other sins, it is not permissible for him to avail himself of the concession of the traveller. However, that was not stipulated by Abu Hanifah (may Allah have mercy on him).
See: al-Mawsoo‘ah al-Fiqhiyyah (27/276).
3. He should intend to stay for four days or less. If he intends to stay for longer than that, he cannot avail himself of the concessions of travel, such as not fasting in Ramadan and shortening prayers and putting them together.
The scholars of the Permanent Committee for Ifta’ said:
If he intends to stay for more than four days, then it is not permissible for him to avail himself of the concessions of travel, such as putting prayers together and shortening them, and the like. But if he intends to stay for four days or less than four days, or his journey depends on completing his errands, so when he has completed his errands he will leave, and he has not already decided on the length of stay that would allow him to avail himself of the concessions of travel, then it is permissible for him to avail himself of the concessions of travel."(Fatawa al-Lajnah ad-Da’imah 8/113-114).
4. He should not begin to avail himself of the concessions of travel until he has left his city.
See: al-Mawsoo‘ah al-Fiqhiyyah (27/279).
5. The majority of scholars stipulated that he should do the two prayers consecutively when he puts them together at the time of the earlier prayer, so he should not leave a long gap between the two prayers.
Shaykh al-Islam Ibn Taymiyah favoured the view that that is not a condition.
See: Majmu‘ al-Fatawa (24/54).
6. It is stipulated that the two prayers that are put together should be done in the correct order. This is the view of the majority.
The scholars of the Permanent Committee for Ifta’ said: When putting prayers together, it is obligatory to do them in the correct order, so that [the traveller] prays Zuhr first, then prays ‘Asr, and he prays Maghrib first, then prays ‘Isha’, whether he is putting them together at the time of the earlier or later prayer."(Fatawa al-Lajnah ad-Da’imah 8/139).
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) said:
It is stipulated that the prayers be done in the correct order, starting with the first one and then the second, because the Prophet (blessings and peace of Allah be upon him) said: “Pray as you have seen me pray.” And because Islamic teachings have explained the order of the times of prayer. But if the person forgets, or is unaware of the ruling, or comes to some people who are praying ‘Isha’, and he intended to put the prayers together at the time of the later prayer, then he prays ‘Isha’ with them, then he prays Maghrib, is the requirement to offer the prayers in the correct order waived in this case, or not?
The most well-known view among our jurists (may Allah have mercy on them) is that it is not waived. Based on that, if someone did the second prayer before the first prayer by mistake, or out of ignorance, or to join the congregation, or for other reasons, then his putting the prayers together is not valid. So what must he do in this case?
The answer is: the prayer that he offered first is not valid as an obligatory prayer, and he has to repeat it.
For example: a man was intending to put the prayers together at the time of the later prayer, then he entered the mosque and found some people praying ‘Isha’, so he joined them with the intention of praying ‘Isha’, then when he had finished ‘Isha’ he prayed Maghrib. We say: His ‘Isha’ prayer is not valid, because he offered it before Maghrib, and offering the prayers in the correct order is a condition [of prayer being valid]. So he has to pray ‘Isha’ again, but his Maghrib is valid. When we say that it is not valid, we mean that it is not valid as an obligatory prayer that would fulfil the obligation, but it is regarded as a supererogatory prayer for which he will be rewarded."(Ash-Sharh al-Mumti‘ 4/401-402).
And Allah knows best.