ERROR of “elements with non-unique id”
-
Hi Friends,
I have got some errors of “elements with non-unique id “,
Please see attached screen shot.
I’d like to know why this appeared and how to fix it?
Thanks.
Attachments:
You must be
logged in to view attached files.
Hello,
Sorry to hear about the inconvenience. Kindly, please share your Site WP-ADMIN Login details in the Private Content field so that we can check this concern on your Site and help you out accordingly.
Best Regards,
Hi,
That could be not my site’s issue, it’s the your theme’s programming bug. The woodmart \woocommerce\add to cart \variable.php, php echo esc_attr( sanitize_title( $attribute_name ), for the reason of ID duplication, so the explore console warning. When I use my own codesnippet —-
add_filter( ‘woocommerce_dropdown_variation_attribute_options_args’, function( $args ) {
if ( isset( $args[‘attribute’] ) && isset( $args[‘product’] ) ) {
static $count = 0;
$count++;
给 select 元素生成唯一id:属性名_产品ID_计数
$args[‘id’] = $args[‘attribute’] . ‘_’ . $args[‘product’]-get_id() . ‘_’ . $count;
}
return $args;
});
The explore warning disappeared. But this code will disable the AJAX action of add to cart button.
It’s a complicated problem for your theme, it’s believed I’m not the first guy to report this issue. The theme needs an update. That’s my point.
Hello,
I’ve double-checked this on our test site using the latest version of the WoodMart theme, and I’m not seeing any console warnings related to this: https://postimg.cc/RW3VTWRg
It’s possible that the warning on your site may be influenced by a customization or third-party plugin.
Best Regards,
OK, maybe you’re right, but I have tested it when I switch to woodmart father theme also disable my child theme, same issue. Please use my admin to check it, what’s the critical problem.
Thanks.
Hello,
We see the issue on our site, and we will fix it in our next update.
Thanks for your patience.
Best Regards,
OK,Thanks. Looking forward to your next update soon.
You can close this ticket now.
Hello,
You’re very welcome! If you need anything else, feel free to reach out!
Thanks for contacting us.
Have a great day.
Topic Closed.
Best Regards,
The topic ‘ERROR of “elements with non-unique id”’ is closed to new replies.