I added this code and now the error has disappeared
Please check it out and let me know if I can use it.
add_filter('woocommerce_loop_add_to_cart_link', 'custom_add_to_cart_button', 10, 2);
function custom_add_to_cart_button($link, $product) {
// Check if the product type is 'simple'
if ($product->is_type('simple')) {
// Retrieve the product name
$product_name = esc_html($product->get_name());
// Modify the link to add custom attributes
$link = sprintf(
'%s',
esc_url($product->add_to_cart_url()),
esc_attr(isset($quantity) ? $quantity : 1),
esc_attr(isset($class) ? $class : 'button product_type_simple add_to_cart_button ajax_add_to_cart'),
$product_name,
esc_attr($product->get_id()),
esc_attr($product->get_sku()),
esc_html($product->add_to_cart_text())
);
}
return $link;
}