<?php if( class_exists( 'Wp_Travel_Engine' ) ) : ?>
<?php 
if( get_theme_mod( 'travel_tour_special_offer_display_option', true ) ) :
  $select_trip_posttype = get_theme_mod( 'travel_tour_special_offer_trip_posttype' );
  if($select_trip_posttype) {
  $selected_trip_posttype = get_page_by_path( get_theme_mod( 'travel_tour_special_offer_trip_posttype' ), '' , 'trip' );
  
  if(!empty($selected_trip_posttype)):
  global $post;
  $post = get_post($selected_trip_posttype);
  setup_postdata( $post );
  
  $tripID = $selected_trip_posttype->ID;
  $tripTitle = $selected_trip_posttype->post_title;
  $image_url = wp_get_attachment_url( get_post_thumbnail_id($tripID) );
  $trip_info = get_post_meta( $tripID,'wp_travel_engine_setting',true );
  $trip_settings = get_option( 'wp_travel_engine_settings', true );
?>
<section class="special-offer mb-96">
    <div class="container-xl">
      <div class="d-flex flex-column-reverse flex-md-row justify-content-start align-items-start">
        <div class="col-md-6 col-sm-12">
          <div class="pe-0 pe-md-20">
            <?php if($tripTitle) { ?>
            <h2><?php the_title(); ?></h2>
            <?php } ?>
            <p class="text-body">
              <?php
              $excerpt = get_the_excerpt();
              $excerpt = substr( $excerpt , 0, 340 );
              echo $excerpt;
              ?> [...]
            </p>
            <?php
              $code = 'USD';
              if( isset( $trip_settings['currency_code'] ) && $trip_settings['currency_code'] != '' ) {
                  $code = esc_attr( $trip_settings['currency_code'] );
              }
              $obj = new Wp_Travel_Engine_Functions();
              $currency = $obj->wp_travel_engine_currencies_symbol( $code );
              $cost = isset( $trip_info['trip_price'] ) ? $trip_info['trip_price']: '';
              $prev_cost = isset( $trip_info['trip_prev_price'] ) ? $trip_info['trip_prev_price']: '';
              if( $cost != '' ) {                   
            ?>
            <div class="mb-32 fs-4 fw-normal">
              <span class="text-decoration-line-through text-black text-opacity-25"><?php echo esc_html( $currency . $obj->wp_travel_engine_price_format( $prev_cost ) ); ?></span>
              <span class=""><?php echo esc_html( $currency . $obj->wp_travel_engine_price_format( $cost ) ); ?> <span class="fs-5">/ <?php esc_html_e( "For Person", 'travel-tour' ); ?></span></span>
            </div>
            <?php }  ?>
            <a href="<?php the_permalink(absint($tripID)); ?>" class="btn btn-primary px-32 py-12 rounded-1">
              <?php esc_html_e( "Learn More", 'travel-tour' ); ?>
            </a>
          </div>
        </div>
        <div class="col-md-6 col-sm-12">
          <div class="mb-32 md-md-0 rounded-2 overflow-hidden">
            <img src="<?php echo esc_url($image_url); ?>" alt="<?php if($tripTitle) echo the_title(); ?>" class="w-p100 h-p100 object-fit-fill">
          </div>
        </div>
      </div>
    </div>
  </section>
  <?php wp_reset_postdata(); endif; } endif; ?>

<?php endif;