Ok I did the debug thing on the browser as per your request and giot this
Uncaught ReferenceError: size is not defined
at Object.<anonymous> ((index):37157:52)
at Function.each (jquery.min.js?ver=3.7.0:2:3129)
at aws_results_html ((index):37138:22)
at common.min.js?ver=2.87:1:844
at Array.forEach (<anonymous>)
at common.min.js?ver=2.87:1:811
at Array.forEach (<anonymous>)
at AwsHooks.apply_filters (common.min.js?ver=2.87:1:775)
at Object.showResults (common.min.js?ver=2.87:1:5402)
at Object.success (common.min.js?ver=2.87:1:2429)
(index):37157 Uncaught ReferenceError: size is not defined
at Object.<anonymous> ((index):37157:52)
at Function.each (jquery.min.js?ver=3.7.0:2:3129)
at aws_results_html ((index):37138:22)
at common.min.js?ver=2.87:1:844
at Array.forEach (<anonymous>)
at common.min.js?ver=2.87:1:811
at Array.forEach (<anonymous>)
at AwsHooks.apply_filters (common.min.js?ver=2.87:1:775)
at Object.showResults (common.min.js?ver=2.87:1:5402)
at Object.onKeyup (common.min.js?ver=2.87:1:1665)
one thing that I do not anderstand is why it stats only size as I have changed it to be the following
add_action( 'wp_enqueue_scripts', 'aws_wp_enqueue_scripts', 999 );
function aws_wp_enqueue_scripts() {
$script = '
function aws_results_html( html, options ) {
html = "";
if ( ( typeof options.response.products !== "undefined" ) && options.response.products.length > 0 ) {
html += "<div class=\"aws-results-table-container\" style=\"max-height:400px; overflow-y: auto;\">"; // Wrap the table in a div
html += "<table>";
html += "<thead>";
html += "<tr><th bgcolor=\"#1b75bb\" style=\"color:#FFFFFF;\">Part No</th><th bgcolor=\"#1b75bb\" style=\"color:#FFFFFF;\">Image</th><th bgcolor=\"#1b75bb\" style=\"color:#FFFFFF;\">Name</th><th bgcolor=\"#1b75bb\" style=\"color:#FFFFFF;\">Dia/Size</th><th bgcolor=\"#1b75bb\" style=\"color:#FFFFFF;\">Lenght</th></tr>";
html += "</thead>";
html += "<tbody>";
jQuery.each(options.response.products, function (i, result) {
html += "<tr class=\"aws_result_item\">";
html += "<td>";
if ( result.sku ) {
html += result.sku;
}
html += "</td>";
html += "<td>";
if ( result.image ) {
html += "<span class=\"aws_result_image\"><img src=\'" + result.image + "\'></span>";
}
html += "</td>";
html += "<td><a href=\'" + result.link + "\'>" + result.title + "</a></td>";
html += "<td>";
<!-- Dia/Size here-->
if ( typeof result.pa_diameter-size !== "undefined") {
html += result.pa_diameter-size;
}
html += "</td>";
html += "<td>";
<!-- Lenght here -->
if ( typeof result.pa_lenght !== "undefined") {
html += result.pa_lenght;
}
html += "</td>";
html += "</tr>";
});
html += "</tbody>";
html += "</table>";
html += "</div>"; // Close the table container div
if ( options.data.showMore && options.data.showPage ) {
html += "<ul><li class=\"aws_result_item aws_search_more\"><a href=\"#\">Show More</a></li></ul>";
}
} else {
html += "<ul><li class=\"aws_result_item aws_no_result\">No results</li></ul>";
}
return html;
}
AwsHooks.add_filter( "aws_results_html", aws_results_html );
';
wp_add_inline_script( 'aws-script', $script);
wp_add_inline_script( 'aws-pro-script', $script);
}
add_filter( 'aws_search_pre_filter_single_product', 'my_aws_search_pre_filter_single_product', 10, 3 );
function my_aws_search_pre_filter_single_product( $result, $post_id, $product ) {
$attributes_to_show = array( 'pa_diameter-size' => 'Diameter/Size', 'pa_length' => 'Length' );
$attributes = $product->get_attributes();
$attrs = array();
if ( $product->is_type( 'simple' ) || $product->is_type( 'external' ) || $product->is_type( 'variation' ) ) {
if ( $attributes ) {
foreach ( $attributes as $attribute_slug => $attribute_values ) {
foreach ( $attributes_to_show as $attribute_to_show_slug => $attribute_to_show_name ) {
if ( $attribute_to_show_slug === $attribute_slug ) {
$attr_name = $attribute_slug;
if ( is_object( $attribute_values ) ) {
$terms = $attribute_values->get_terms();
if ( $terms ) {
foreach( $terms as $term ) {
$attrs[$attr_name][] = $term->name;
}
}
} else {
$attrs[$attr_name][] = $attribute_values;
}
}
}
}
}
}
if ( ! empty( $attrs ) ) {
foreach( $attrs as $attr_name => $attr_terms ) {
$result[$attr_name] = '';
foreach ( $attr_terms as $attr_term ) {
$result[$attr_name] .= '<span style="display: inline-block;padding: 0 5px;border: 1px solid #ccc;margin: 5px 5px 2px 0;">' . $attr_term . '</span>';
}
}
}
return $result;
}