Woocommerce for variation selection error message display in category and archive pages
Always use child theme any wordpress website and copy below code and add this code in your header.php and in woocommerce shop page.Use this below jQuery for variation selection error message show in page and do change classes according used in theme shop page-
jQuery( function($){
$( '<p id="show_error">select variation options</p>' ).insertBefore( ".single_variation_wrap" );
$('#show_error').hide();
$('.single_add_to_cart_button').on('click',function(e){
if ( $( this ).is('.disabled') ) {
e.preventDefault();
if ( $( this ).is('.wc-variation-selection-needed') ) {
$('#show_error').show();
setTimeout(function () {
$('#show_error').hide();
}, 5000);
return false;
} if ( $( this ).is('.wc-variation-is-unavailable') ) {
e.preventDefault();
return false;
}
} });
});
</script>
0 Comments