First of all, is no valid HTML element and should be
Second, did you declare card_product as a variable before? If not, this is not an object you have access to and should be changed to product.
Third, if has_only_default_variant is true, then I think product.variants is empty. That means product.variants[0] won’t return anything. (But not 100% sure)