Home › Forums › WoodMart support forum › Elements with visible text labels do not have matching accessible names. › Reply To: Elements with visible text labels do not have matching accessible names.
spnutratea
Do you think the following code will do the job without breaking anything?
add_filter(‘woocommerce_loop_add_to_cart_link’, ‘sp_add_to_cart_button’, 10, 2);
function sp_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;
}