WooCommerce: Add links to Attribute Values

Hello
I would need a php syntax expert for a short question.

It’s in the WooCommerce Plugin. There are product attributes which all have an ATTRIBUTE NAME and a VALUE. Every value is divided by comma. Now, I want to just add Links to every by comma divided value.

This line is at the bottom in product-attributes.php:

echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );

Every Value should have a link to a glossar, for example the value “Game” should have a link like “http://xxx.com/glossar#game”:

echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( ''.implode( ', ', $values ).'' ) ), $attribute, $values );

How can I change it so that the word “game” in the link is always the actual value? It doesn’t work with something like $values or $values[0]

Would be great if someone could help

Why can’t you just iterate over the array values beforehand?

foreach( $values as $key => $val ){
  $values[$key] = ''.strtolower( $val ).'';
}

Though depending on the scenario/context of this code, you should probably be doing it all in a separate filter anyway.

Thanks. That helped :slight_smile:

You’re welcome :slight_smile: And I realized I forgot the important part

foreach( $values as $key => $val ){
  $values[$key] = ''.$val.'';
}

haha

wonderful. Solved my problem too. :slight_smile: