I have this working in the woocommerce content-product.php, but i don’t want to modify the core files.

<p style="font-size:11px;">
<?php
    if ( is_page( array ( 571,558 )) ) {
      echo "Melts To:";
        } elseif ( has_term( 'ice' )  ) {   
     echo "Melts To:";

    }else {
 echo " ";
    }
    ?><strong>
    <?php 
    echo $product->get_attribute('melts-to');
?></strong>

So I tried to make a function to use add action

 function action_woocommerce_after_shop_loop_item_title(){
$melts = get_the_terms( $product->id, 'melts-to');


foreach ( $melts as $melt ) {

if ( is_page( array ( 571,558 )) ) {
    echo "<p style='font-size:11px;'> Melts To: <strong>" ;
    echo $melt->name ;
    echo "</strong></p>" ;
} elseif ( has_term( 'ice' )  ) {   
    echo "Melts To:";
    echo $melt->name ;
}else {
    echo " ";
};
};
};
// add the action 
add_action( 'woocommerce_after_shop_loop_item_title', 'action_woocommerce_after_shop_loop_item_title', 10, 0 ); 

I am way off of getting the attribute of Melts to as it only echos the html. Any guidance is GREAT aside from continued study of php, Thanks in advace.

Read more here: function syntax is off,


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: