Created
September 15, 2023 06:55
-
-
Save akther80/53aadc8531b05b9197a3080704860127 to your computer and use it in GitHub Desktop.
MyTravel - DIsplay Room Amenities in Room product format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( ! function_exists( 'mytravel_room_amenities_preview_1' ) ) { | |
/** | |
* Output room ameniities preview | |
*/ | |
function mytravel_room_amenities_preview_1() { | |
if ( ! mytravel_is_acf_activated() ) { | |
return; | |
} | |
$area = mytravel_get_field( 'area' ); | |
$total_beds = mytravel_get_field( 'total_beds' ); | |
$amenities = mytravel_get_field( 'primary_room_amenities' ); | |
if ( $area || $total_beds || $amenities ) : | |
?> | |
<h4 class="d-block w-100"><?php echo esc_html__( 'Amenities', 'mytravel'); ?></h4> | |
<ul class="list-unstyled mb-0 row"> | |
<?php | |
if ( $area ) { | |
?> | |
<li class="col-6 mb-3"><?php mytravel_room_amenity_html( apply_filters( 'mytravel_room_amenities_1', 'flaticon-plans' ), $area ); ?></li> | |
<?php | |
} | |
if ( $total_beds ) { | |
?> | |
<li class="col-6 mb-3"><?php mytravel_room_amenity_html( apply_filters( 'mytravel_room_amenities_2', 'flaticon-bed-1' ), $total_beds ); ?></li> | |
<?php | |
} | |
if ( $amenities ) { | |
foreach ( $amenities as $amenity ) : | |
if ( ! is_wp_error( $amenity ) && $amenity ) { | |
$term_id = $amenity->term_id; | |
$taxonomy = $amenity->taxonomy; | |
$icon = mytravel_get_field( 'icon_class', $taxonomy . '_' . $term_id ); | |
?> | |
<li class="col-6 mb-3"><?php mytravel_room_amenity_html( $icon, $amenity->name ); ?></li> | |
<?php | |
} | |
endforeach; | |
} | |
?> | |
</ul> | |
<?php | |
endif; | |
} | |
} | |
add_action( 'mytravel_after_single_room', 'mytravel_single_product_container_wrap_start', 1 ); | |
add_action( 'mytravel_after_single_room', 'mytravel_room_amenities_preview_1', 2 ); | |
add_action( 'mytravel_after_single_room', 'mytravel_single_product_container_wrap_end', 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment