- "Yes" (slug: yes) into a checkmark like checkmark.svg or <i class="fa fa-check-square-o"> - "No" (slug: no) into a x-cross like xmark.svgor <i class="fa-solid fa-circle-xmark">
I know the plugin doesn't provide this option, but maybe you can provide me a snippet or point me the right way to achieve this.
Hi,
Is there a way to change an attribute called:
- "Yes" (slug: yes) into a checkmark like checkmark.svg or <i class="fa fa-check-square-o">
- "No" (slug: no) into a x-cross like xmark.svg or <i class="fa-solid fa-circle-xmark">
I know the plugin doesn't provide this option, but maybe you can provide me a snippet or point me the right way to achieve this.
Thanks in advance for your answer.
SB
Hi Scholto,
Please explain it more with screenshots, so I can check if I can help you.
Best regards,
Dustin
Hi Dustin,
Please see the screenshot with the current situation and the screenshot with the desired situation. Yes is "Ja" in Dutch and No is "Nee".
I tried a snippet like this, but this one doesn't work:
// Replace "Yes" en "No" in attribute output
add_filter('woocommerce_product_get_attribute', 'finler_replace_yes_no_in_attributes', 10, 3);
function finler_replace_yes_no_in_attributes($value, $attribute_name, $product) {
if (!is_product()) {
return $value;
}
$value_clean = strtolower(trim($value));
if ($value_clean === 'ja') {
return '<img src="' . get_stylesheet_directory_uri() . '/checkmark.svg" alt="Ja" style="height:16px;vertical-align:middle;">';
}
if ($value_clean === 'nee') {
return '<img src="' . get_stylesheet_directory_uri() . '/xmark.svg" alt="Nee" style="height:16px;vertical-align:middle;">';
}
return $value;
}
I totally understand when this is beyond the scope of your support, but maybe you can point me the right way.
Thanks in advance.
SB
Attached files: current.png
desired.png