<?php
/**
 * Product amenities.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/hbfwc/product-amenities.php.
 *
 * @package HBFWC\Templates
 * @version 1.0.0
 */

defined( 'ABSPATH' ) || exit;

global $product;

$amenities_groups = hbfwc_get_amenities_group();

foreach ( $amenities_groups as $key => $group_name ) {
	$amenities = hbfwc_get_post_amenities_by_group( $product->get_id(), $key );

	if ( $amenities && ! is_wp_error( $amenities ) ) {
		?>
<div class="hbfwc__amenities hbfwc__amenities-<?php print esc_attr( $key ); ?>">
	<h4><?php print esc_html( $group_name ); ?></h4>
	<ul class="hbfwc__amenities-list">
		<?php
		foreach ( $amenities as $amenity ) {
			$icon_type = get_term_meta( $amenity->term_id, 'icon_type', true );

			print '<li><span>' . ( 'svg' === $icon_type ? wp_kses( get_term_meta( $amenity->term_id, 'icon_svg', true ), hbfwc_get_svg_args() ) : '<i class="' . esc_attr( get_term_meta( $amenity->term_id, 'icon_class', true ) ) . '"></i>' ) . ' <span>' . esc_html( $amenity->name ) . '</span></span></li>' . "\n";
		}
		?>
	</ul>
</div>
		<?php
	}
}
