I am trying to have it so for specific product attribute that contain "agave" text is displayed in the short description.
I have tried a few snippets of code but none seem to work. I have no problem getting them to work with Categories but I just want it for certain attributes of the products - Agave
function filter_woocommerce_short_description( $post_excerpt ) {
global $post;
if ( has_term( "agave", "categories", $post->ID ) ) {
$post_excerpt .= "<br/>" . "Text Here";
}
return $post_excerpt;
};
add_filter('woocommerce_short_description', 'filter_woocommerce_short_description',10, 1 );
I expect the text to show up under the certain attributes (Agave) but they do not
I have tried to use this
add_filter('woocommerce_short_description',
'filter_woocommerce_short_description',10, 1 );
function filter_woocommerce_short_description( $short_description ) {
global $product;
$string_values = $product->get_attribute('agave');
if ( strpos($string_values, 'agave') !== false ) {
$short_description .= '<br>' . __("Testing This Out - AGAVE");
}
return $short_description;
}