This code is assigning a blank string to cart if no cart is found.
cart = ''
for c in product.find_all('strong',class_='css-1c9g7b0'):
cart = c.get_text().strip()
It might not have been your intention, but that is what the code accomplishes. I would try to make the purpose more obvious.
cart = product.find('strong', class_='css-1c9g7b0')
cart = cart.get_text().strip() if cart else ''
If you are doing this for cart, why don't you do the same for name?
You are doing something similar for price, but this is really confusing.
for price in product.find_all('span',class_='sr-only'):
prices = [
p.get_text().strip().replace('\n', '').replace(' ', '').replace('dollars', '.').replace('cents', '')
for p in product.find_all('span', class_='sr-only', limit=2)
]
This says "For every price I find I am going to load all the prices into a list." If there were 100 prices you would remake the list of 100 prices 100 times. This accomplishes the same thing without needlessly banging away on the poor website.
prices = [
p.get_text().strip().replace('\n', '').replace(' ', '').replace('dollars', '.').replace('cents', '')
for p in product.find_all('span', class_='sr-only', limit=2)
]
productdetails.append(name, prices if prices else None, cart]