Reputation: 3
I have a custom field named "mekos" on my product pages product attributes. I would like to show some additional custom text, for example "centimeters", after the value is displayed. The spot that I want the custom text "centimeters" to be displayed.
This is the code I have so far:
function yourprefix_woocommerce_display_product_attributes($product_attributes, $product){
$mekos = get_post_meta($product->get_ID(), 'mekos', true);
if( get_field('mekos') ) {
$product_attributes['mekos'] = [
'label' => 'Μήκος',
'value' => $mekos ,
];
}
return $product_attributes;
}
add_filter('woocommerce_display_product_attributes', 'yourprefix_woocommerce_display_product_attributes', 10, 2);
Upvotes: 0
Views: 68
Reputation: 1333
Change the if
you have to
if (get_field('mekos')) {
$product_attributes['mekos'] = [
'label' => 'Μήκος',
'value' => $mekos . ' centimeters'
];
}
Upvotes: 1