In most programs, it does not matter whether the customer buys as a guest or is logged in to their account for the affiliate purchase to count. As long as the customer clicks on the affiliate link and makes a purchase, the affiliate will receive credit for the sale.
However, it is worth noting that some affiliate programs may have different rules and requirements for tracking sales, so it is always a good idea to review the terms and conditions of the affiliate program to ensure that you are aware of any specific requirements.
Additionally, it is generally a good idea for customers to create an account on the merchant's website, even if they are just making a one-time purchase as a guest. This can make it easier for the customer to track their orders and access any order history or account information that may be useful in the future.