Praise be to Allah.
The sale transaction transfers ownership of the goods from the seller to the purchaser, but they remain the liability of the seller until the purchaser receives and takes possession of them.
When the purchaser himself, or his agent, receives the goods and takes possession of them, and removes them from the seller’s warehouses, it becomes permissible for him to sell them, even if they are still on board a ship or plane, because by receiving them and moving them, they become his liability. For that reason, it becomes permissible for him to sell them and make a profit on them, whereas it is not permissible for him to do that before they become his liability, because the Prophet (blessings and peace of Allah be upon him) forbade making a profit on an item for which you are not liable, and he (blessings and some of Allah be upon him) said: “Profit is connected to liability.”
So if the agreement is that the seller’s responsibility ends as soon as the goods are delivered to the shipping company that the purchaser chooses, or that the seller recommends, then as soon as the goods leave the seller’s warehouse and are transported to the shipping company, whether they are being shipped by sea or by air, and the documents proving the sale are handed over, this is regarded as being like receipt of goods and more.
Thus the goods become the liability of the purchaser, so if they are lost or damaged at sea or in the air, the purchaser is liable, because he took possession of them and moved them to the port, either by himself or through his agent.
Selling goods when they are on the ship or plane is a valid transaction, by means of which ownership is transferred.
So if the merchant sells his goods when they are still on the ship, before they reach him, and they had become his liability, as noted above in the previous paragraph, then the transaction is valid. The new purchaser has the option of cancelling the deal if any defect becomes apparent or if the goods differ from the description given in the contract.
If it so happens that the goods are damaged before they are received by the purchaser, the new purchaser is not liable for that, because the goods remain the liability of the seller until the purchaser receives them.
If the purchaser/importer had received the goods (the rice) himself, and he himself shipped them, or asked his agent to receive the goods from the seller/supplier, even if the agent is the shipping company itself, and the goods are damaged or destroyed before they reach the place where the purchaser wanted them to go, then the purchaser is liable for that, because he received the goods in a real sense and was the one who disposed of them by shipping them himself.
But if the seller/supplier is the one who shipped the goods himself, or his agent did that, or the transaction was done on board the ship, then the goods were destroyed before they were received by the purchaser, then the seller is liable for them.
Please see the answer to question no. 217314 .
And Allah knows best.