<?php
/**
 * wp-it-courses WordPress Theme, ordasvit.com
 * wp-it-courses is distributed under the terms of the GNU GPL
 * Copyright: 2023 OrdaSvit, Andrey Kvasnevskiy, ordasvit.com
 */

// add show attribute in product catalog
add_action( 'woocommerce_after_shop_loop_item', 'wp_it_courses_add_attribute_amount_of_places', 5 );
function wp_it_courses_add_attribute_amount_of_places (){
  global $product;
  

  $values = get_the_terms( $product->id, 'pa_amount-of-places');

  if(isset($values) && !empty($values) ) {

    if( isset($values->errors) ) return ;

     echo '<div class="product_attribute amount-of-places"> <i class="fas fa-users"></i>';

    foreach ( $values as $value ) {
      echo $value->name;
    }

    echo '</div>';

  }

}

add_action( 'woocommerce_after_shop_loop_item', 'wp_it_courses_add_attribute_duration', 5 );
function wp_it_courses_add_attribute_duration (){
  global $product;
  

  $values = get_the_terms( $product->id, 'pa_duration');

  if(isset($values) && !empty($values) ) {

    if( isset($values->errors) ) return ;

     echo '<div class="product_attribute duration"> <i class="fas fa-calendar-check"></i>';

    foreach ( $values as $value ) {
      echo $value->name;
    }

    echo '</div>';

  }

}