<?php
/**
 * Product amenities for listing.
 * We take only few aminities to display.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/hbfwc/product-amenities-teaser.php.
 *
 * @package HBFWC\Templates
 * @version 1.0.0
 */

defined( 'ABSPATH' ) || exit;

global $product;

$amenities = wp_get_post_terms(
	$product->get_id(),
	'amenities',
	array(
		'number' => apply_filters( 'hbfwc_amenities_teaser_count', 4 ),
	)
);

if ( $amenities && ! is_wp_error( $amenities ) ) {
	?>
<div class="hbfwc__amenities hbfwc__amenities-teaser">
	<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
}
