Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Add variable attributes to search description › Reply To: Add variable attributes to search description
April 11, 2019 at 9:44 am
#22120
Keymaster
Hi,
Yes, sure. Well, I had to google around, and maybe there is a way to list those attributes for variations via a custom code. Try adding this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!
add_filter('asp_results', 'asp_get_prod_atts_table', 10, 1);
function asp_get_prod_atts_table($results) {
foreach ($results as $k => &$r) {
if ( !isset($r->post_type) || $r->post_type != 'product_variation' )
continue;
$product = wc_get_product($r->id);
$r->content = wc_get_formatted_variation( $product->get_variation_attributes(), true ) . '<br>' . $r->content;
}
return $results;
}
This might not be the best possible solution, but this is the only way to simply list the attributes according to the WooCommerce API.