Hi Mateo,
You can assign an affiliate to any order containing a product via the Order Details screen. For more information please see: https://docs.whmcs.com/clients/the-affiliate-system/managing-affiliates/#assigning-affiliates-to-orders