/**
  * Fixes links to the tours archive page. Filter used by WPML plugin to disaply list of trnslated pages.
  *
  * @param  assoc $languages
  * @return assoc
  */
 public function filter_icl_ls_languages_fix_tours_link($languages)
 {
     static $first_call = true, $tour_page_id;
     if ($first_call) {
         // checking if current page is tours page, if no - removing this filter
         // need improve
         $first_call = false;
         if (!adventure_tours_check('is_tour_search')) {
             remove_filter('icl_ls_languages', array($this, 'filter_icl_ls_languages_fix_tours_link'), 20);
             return $languages;
         }
     }
     if (null === $tour_page_id) {
         $tour_page_id = adventure_tours_get_option('tours_page', '');
     }
     global $sitepress;
     foreach ($languages as $code => $language) {
         // for WPML version prior 3.3.0
         // $languages[$code]['url'] = get_permalink( apply_filters( 'translate_object_id', $tour_page_id, 'page', true, $language['language_code'] ) );
         // for WPML version > 3.3.0
         $sitepress->switch_lang($language['language_code']);
         $languages[$code]['url'] = get_permalink(apply_filters('translate_object_id', $tour_page_id, 'page', true, $language['language_code']));
         $sitepress->switch_lang();
     }
     return $languages;
 }
Exemple #2
0
 /**
  * Returns badge field value.
  *
  * @param  integer $bid
  * @param  string  $field
  * @return string
  */
 public function get_field($bid, $field)
 {
     if ($bid > 0 && $bid <= $this->count && $field) {
         $option = "tour_badge_{$bid}_{$field}";
         return adventure_tours_get_option($option);
     }
     return null;
 }
 /**
  * Hook for 'save_post' action.
  *
  * @param  int  $post_id
  * @return void
  */
 public function action_save_post_tour_page($post_id)
 {
     if (wp_is_post_revision($post_id)) {
         return;
     }
     // if saved post is 'Tours' page - maybe we need flush rewrite rules (slug may be updated)
     if (adventure_tours_get_option('tours_page') == $post_id) {
         $this->check_tours_base_change();
     }
 }
 /**
  * Returns an array of arguments for ordering tour based on the selected values.
  *
  * @param string $orderby
  * @param string $order
  * @return array
  */
 public function get_archive_ordering_args($orderby = '', $order = '')
 {
     global $wpdb;
     // Get ordering from query string unless defined
     if (!$orderby) {
         $orderby_value = isset($_GET['orderby']) ? wc_clean($_GET['orderby']) : apply_filters('adventure_tours_default_archive_orderby', adventure_tours_get_option('tours_archive_orderby'));
         // Get order + orderby args from string
         $orderby_value = explode('-', $orderby_value);
         $orderby = esc_attr($orderby_value[0]);
         $order = !empty($orderby_value[1]) ? $orderby_value[1] : $order;
     }
     $orderby = strtolower($orderby);
     $order = strtoupper($order);
     $args = array();
     // default - menu_order
     $args['orderby'] = 'menu_order title';
     $args['order'] = $order == 'DESC' ? 'DESC' : 'ASC';
     $args['meta_key'] = '';
     switch ($orderby) {
         case 'rand':
             $args['orderby'] = 'rand';
             break;
         case 'date':
             $args['orderby'] = 'date';
             $args['order'] = $order == 'ASC' ? 'ASC' : 'DESC';
             break;
         case 'price':
             $args['orderby'] = "meta_value_num {$wpdb->posts}.ID";
             $args['order'] = $order == 'DESC' ? 'DESC' : 'ASC';
             $args['meta_key'] = '_price';
             break;
         case 'popularity':
             $args['meta_key'] = 'total_sales';
             // Sorting handled later though a hook
             add_filter('posts_clauses', array('WC_Query', 'order_by_popularity_post_clauses'));
             break;
         case 'rating':
             // Sorting handled later though a hook
             add_filter('posts_clauses', array('WC_Query', 'order_by_rating_post_clauses'));
             break;
         case 'title':
             $args['orderby'] = 'title';
             $args['order'] = $order == 'DESC' ? 'DESC' : 'ASC';
             break;
     }
     return apply_filters('adventure_tours_get_archive_ordering_args', $args);
 }
Exemple #5
0
/**
 * Sidebar template used for woocommerce related page.
 *
 * @author    Themedelight
 * @package   Themedelight/AdventureTours
 * @version   1.0.9
 */
$is_tour_query = adventure_tours_check('is_tour_search');
$current_product = is_single() ? wc_get_product() : null;
$is_single_tour = $current_product && $current_product->is_type('tour');
$is_tour_category = is_tax('tour_category');
$show_booking_form = $is_single_tour;
$sidebar_id = $is_tour_query || $is_single_tour || $is_tour_category ? 'tour-sidebar' : 'shop-sidebar';
$show_sidebar = is_active_sidebar($sidebar_id);
$tour_search_form = $is_tour_query && adventure_tours_get_option('tours_archive_show_search_form', 1) ? adventure_tours_render_tour_search_form() : null;
if (!$show_sidebar && !$show_booking_form && !$tour_search_form) {
    return;
}
?>
<aside class="col-md-3 sidebar" role="complementary">
<?php 
if ($tour_search_form) {
    print adventure_tours_render_tour_search_form();
}
if ($show_booking_form) {
    get_template_part('templates/tour/price-decoration');
    echo adventure_tours_render_tour_booking_form($current_product);
}
if ($show_sidebar) {
    dynamic_sidebar($sidebar_id);
<?php

/**
 * FAQ question posting form themplate part.
 *
 * @author    Themedelight
 * @package   Themedelight/AdventureTours
 * @version   1.0.0
 */
$attributes_text = '';
if ('custom_email' == adventure_tours_get_option('faq_question_form_receiver_type')) {
    $attributes_text = ' email="' . esc_attr(adventure_tours_get_option('faq_question_form_custom_email')) . '"';
}
?>
<div class="form-block form-block--style2 form-block--faq">
	<div class="form-block__content">
		<h3 class="form-block__title"><?php 
esc_html_e('Not found your question?', 'adventure-tours');
?>
</h3>
		<div class="form-block__description"><?php 
esc_html_e('Fill in the form below', 'adventure-tours');
?>
</div>
		<?php 
echo do_shortcode('[faq_question_form' . $attributes_text . ']');
?>
	</div>
	<div class="form-block__validation-success"></div>
</div>
Exemple #7
0
?>

	<?php 
if (have_posts()) {
    ?>

		<?php 
    $need_show_categories = $is_first_page && in_array($display_mode, array('both', 'subcategories'));
    $need_show_tours = in_array($display_mode, array('products', 'both'));
    $tours_display_style = $need_show_tours ? apply_filters('adventure_tours_get_tours_page_display_style', adventure_tours_get_option('tours_archive_display_style')) : '';
    ?>

		<?php 
    if ($need_show_categories) {
        if ('grid' == $tours_display_style) {
            $categories_col_size = adventure_tours_get_option('tours_archive_columns_number', '2');
        } else {
            $categories_col_size = $sidebar_content ? 2 : 3;
        }
        adventure_tours_di('register')->setVar('tour_cat_columns', apply_filters('adventure_tours_tour_categories_columns', $categories_col_size, $sidebar_content ? true : false));
        adventure_tours_render_tour_categories(array('before' => '<div class="row product-rategories">', 'after' => '</div>'));
    }
    ?>

		<?php 
    if ($need_show_tours) {
        if ('grid' == $tours_display_style) {
            get_template_part('templates/tour/loop-grid');
        } else {
            get_template_part('templates/tour/loop-list');
        }
Exemple #8
0
<?php

/**
 * Page header template part for the logo rendering.
 *
 * @author    Themedelight
 * @package   Themedelight/AdventureTours
 * @version   1.0.0
 */
?>
<div class="logo">
<?php 
if ('image' != adventure_tours_get_option('logo_type')) {
    echo strtr('<a id="logoLink" href="{homeUrl}">{name}</a>', array('{homeUrl}' => esc_url(home_url('/')), '{name}' => esc_html(get_bloginfo('name'))));
} else {
    echo strtr('<a id="logoLink" href="{homeUrl}">' . '<img id="normalImageLogo" src="{logoUrl}" alt="{blogNameAtr}" title="{blogDescriptionAtr}">' . '<img id="retinaImageLogo" src="{retinaLogoUrl}" alt="{blogNameAtr}" title="{blogDescriptionAtr}">' . '</a>', array('{homeUrl}' => esc_url(home_url('/')), '{blogNameAtr}' => esc_attr(get_bloginfo('name')), '{blogDescriptionAtr}' => esc_attr(get_bloginfo('description')), '{logoUrl}' => esc_url(adventure_tours_get_option('logo_image')), '{retinaLogoUrl}' => esc_url(adventure_tours_get_option('logo_image_retina'))));
}
?>
</div>
 protected function get_section_id_for_archive_page()
 {
     $result = 0;
     if (adventure_tours_check('is_tour_search')) {
         // static page for tours
         $result = adventure_tours_get_option('tours_page');
     } elseif (is_home()) {
         $result = get_option('page_for_posts');
     } elseif (is_post_type_archive('product')) {
         $result = wc_get_page_id('shop');
     } elseif (is_tax('tour_category')) {
         $tour_category = get_queried_object();
         if ($tour_category && isset($tour_category->term_id)) {
             $storage = adventure_tours_di('tour_category_header_sections_storage');
             if ($storage && $storage->is_active()) {
                 $result = $storage->getData($tour_category->term_id);
             }
         }
     }
     return $result;
 }
Exemple #10
0
<?php

/**
 * Page header template part for the site details rendering.
 *
 * @author    Themedelight
 * @package   Themedelight/AdventureTours
 * @version   1.0.0
 */
?>
<div class="header__info">
	<div class="header__info__items-left">
	<?php 
$contact_phone = adventure_tours_get_option('contact_phone');
$contact_time = adventure_tours_get_option('contact_time');
?>
	<?php 
if ($contact_phone) {
    ?>
		<div class="header__info__item header__info__item--phone"><i class="fa fa-phone"></i><?php 
    echo esc_html($contact_phone);
    ?>
</div>
	<?php 
}
?>
	<?php 
if ($contact_time) {
    ?>
		<div class="header__info__item header__info__item--clock"><i class="fa fa-clock-o"></i><?php 
    echo esc_html($contact_time);
 /**
  * Returns number of columns that should be rendered in the footer.
  *
  * @return int
  */
 function adventure_tours_get_footer_columns()
 {
     $footerLayout = adventure_tours_get_option('footer_layout');
     $laoutToColumns = array('3columns' => 3, '2columns' => 2);
     return isset($laoutToColumns[$footerLayout]) ? $laoutToColumns[$footerLayout] : 4;
 }
Exemple #12
0
<?php

/**
 * Shopping cart icon rendring templated.
 *
 * @author    Themedelight
 * @package   Themedelight/AdventureTours
 * @version   1.0.0
 */
if (!class_exists('WooCommerce') || !adventure_tours_get_option('show_header_shop_cart')) {
    return;
}
$cart_qty = WC()->cart->get_cart_contents_count();
?>
<div class="header__info__item header__info__item--delimiter header__info__item--shoping-cart">
	<a href="<?php 
echo esc_url(WC()->cart->get_cart_url());
?>
">
		<i class="fa fa-shopping-cart"></i>
		<?php 
if ($cart_qty > 0) {
    echo '(' . esc_html($cart_qty) . ')';
}
?>
	</a>
</div>
 protected function do_import_theme_options($cfg)
 {
     $theme_options_file = $cfg['file'];
     $theme_option_component = adventure_tours_di('register')->getVar('_vp_theme_option');
     if (!$theme_option_component) {
         throw new Exception('[di500] Data import error. Please contact support.');
     }
     $theme_option_values = json_decode(file_get_contents($theme_options_file), true);
     if (!$theme_option_values) {
         throw new Exception('[di501] Theme options parsing error. Please contact support.');
     }
     $theme_option_component->init_options_set();
     $theme_option_component->init_options();
     $set = $theme_option_component->get_options_set();
     $tour_page_id = adventure_tours_get_option('tours_page');
     $tour_page_instance = $tour_page_id ? get_page($tour_page_id) : null;
     if (!$tour_page_instance) {
         $tour_page_instance = get_page_by_path('tours', OBJECT, 'page');
         if ($tour_page_instance) {
             $tour_page_id = $tour_page_instance->ID;
         }
     }
     $theme_option_values['tours_page'] = $tour_page_id;
     // populate new values
     $theme_option_component->get_options_set()->populate_values($theme_option_values, false);
     $theme_options_saving_result = $theme_option_component->save_and_reinit();
     if (true != $theme_options_saving_result['status']) {
         throw new Exception('[to503] ' . $theme_options_saving_result['message']);
     } else {
         $saved_theme_values = $theme_option_component->get_options_set()->get_values();
     }
     return 'Settings have been imported.';
 }
Exemple #14
0
 * Social icons rendering template part.
 *
 * @author    Themedelight
 * @package   Themedelight/AdventureTours
 * @version   1.2.2
 */
$social_icons = array('facebook' => 'facebook', 'twitter' => 'twitter', 'googleplus' => 'google-plus', 'pinterest' => 'pinterest', 'linkedin' => 'linkedin', 'instagram' => 'instagram', 'dribbble' => 'dribbble', 'tumblr' => 'tumblr', 'vk' => 'vk');
$links_set = array();
foreach ($social_icons as $key => $icon_class) {
    $url = adventure_tours_get_option('social_link_' . $key);
    if ($url) {
        $links_set[] = array('icon_class' => 'fa fa-' . $icon_class, 'url' => $url);
    }
}
for ($i = 1; $i <= 5; $i++) {
    $url = adventure_tours_get_option("social_link_{$i}_is_active") ? adventure_tours_get_option("social_link_{$i}_url") : null;
    if (!$url) {
        continue;
    }
    $icon_class = adventure_tours_get_option("social_link_{$i}_icon");
    if ($icon_class) {
        $links_set[] = array('icon_class' => 'fa ' . $icon_class, 'url' => $url);
    }
}
$social_icons_html = '';
foreach ($links_set as $link_info) {
    $social_icons_html .= '<a href="' . esc_url($link_info['url']) . '"><i class="' . esc_attr($link_info['icon_class']) . '"></i></a>';
}
if ($social_icons_html) {
    printf('<div class="header__info__item header__info__item--delimiter header__info__item--social-icons">%s</div>', $social_icons_html);
}
 /**
  * Filter for woocommerce bredcrumbs generation function.
  * To fix breadcrumbs for tours and tour categories.
  *
  * @param  array $list
  * @param  array $init_list
  * @return array
  */
 public function filter_woocommerce_get_breadcrumb($list, $init_list)
 {
     $isTourDetails = false;
     if (!empty($GLOBALS['product'])) {
         $p = wc_get_product();
         if ($p && $p->is_type('tour')) {
             $isTourDetails = true;
         }
     }
     $tour_cat_tax_name = 'tour_category';
     $is_set_tour = $isTourDetails || adventure_tours_check('is_tour_search');
     $is_tour_cat = !$is_set_tour ? is_tax($tour_cat_tax_name) : false;
     $tour_element = array();
     if ($is_set_tour || $is_tour_cat) {
         $toursPageId = adventure_tours_get_option('tours_page');
         $toursLink = $toursPageId ? get_permalink($toursPageId) : '';
         if ($toursLink) {
             $tour_element = array(get_the_title($toursPageId), $toursLink);
         }
     }
     if ($is_set_tour) {
         if ($tour_element) {
             $first_element = isset($list[1]) ? $list[1] : null;
             $list[1] = $tour_element;
             // case when init list contatins only Home/ Tour X
             if ($isTourDetails && $first_element && empty($list[2]) && is_single()) {
                 $list[] = $first_element;
             }
         }
         if (adventure_tours_check('is_tour_search')) {
             $last_index = count($list) - 1;
             if (is_search()) {
                 // replacement for breadcrumbs "Search results for ''"
                 if (!get_search_query(false)) {
                     $list[$last_index][0] = esc_html__('Search results', 'adventure-tours');
                     // $list[ $last_index ][0] = str_replace('&ldquo;&rdquo;', '', $list[ $last_index ][0]);
                 }
             } elseif (!empty($_REQUEST['tourtax'])) {
                 // adding 'Search results' element to breadcrumbs in case if search in use and last element is "Tours"
                 if ($tour_element == $list[$last_index]) {
                     $list[] = array(esc_html__('Search results', 'adventure-tours'), '');
                 }
             }
         }
     } elseif ($is_tour_cat) {
         $new_list = array($list[0], $tour_element);
         $current_term = $GLOBALS['wp_query']->get_queried_object();
         $ancestors = get_ancestors($current_term->term_id, $tour_cat_tax_name);
         $ancestors = array_reverse($ancestors);
         foreach ($ancestors as $ancestor) {
             $ancestor = get_term($ancestor, $tour_cat_tax_name);
             if (!is_wp_error($ancestor) && $ancestor) {
                 $new_list[] = array($ancestor->name, get_term_link($ancestor));
             }
         }
         $new_list[] = array($current_term->name);
         return $new_list;
     }
     return $list;
 }
Exemple #16
0
<?php

/**
 * Breadcrumbs template.
 *
 * @author    Themedelight
 * @package   Themedelight/AdventureTours
 * @version   1.0.0
 */
if (!adventure_tours_get_option('breadcrumbs_is_show')) {
    return;
}
$breadcrumbs_html = adventure_tours_di('breadcrumbs')->get_html();
if ($breadcrumbs_html) {
    printf('<div class="breadcrumbs">%s</div>', $breadcrumbs_html);
}
Exemple #17
0
<?php

/**
 * Header template part.
 *
 * @author    Themedelight
 * @package   Themedelight/AdventureTours
 * @version   1.0.9
 */
get_template_part('header', 'clean');
$is_sticky_header = adventure_tours_get_option('sticky-header');
if ($is_sticky_header) {
    TdJsClientScript::addScript('sticky-header', 'Theme.initStickyHeader();');
    echo '<div class="header-wrap"><div class="header-wrap__backlog"></div>';
}
?>
<header class="header" role="banner">
	<div class="container">
		<?php 
get_template_part('templates/header/info');
?>
		<div class="header__content-wrap">
			<div class="row">
				<div class="col-md-12 header__content">
					<?php 
get_template_part('templates/header/logo');
?>
					<?php 
if (has_nav_menu('header-menu')) {
    ?>
					<nav class="main-nav-header" role="navigation">
Exemple #18
0
?>
</div><!-- .container -->
<footer class="footer">
	<?php 
get_template_part('templates/footer/widget-areas');
?>
	<div class="footer__bottom">
		<div class="footer__arrow-top"><a href="#"><i class="fa fa-chevron-up"></i></a></div>
		<div class="container">
			<div class="row">
				<div class="<?php 
echo esc_attr($classCol);
?>
">
					<div class="footer__copyright"><?php 
echo adventure_tours_esc_text(adventure_tours_get_option('footer_text_note'), 'option_input', true);
?>
</div>
				</div>
				<?php 
if ($isShowFooterManu) {
    ?>
					<div class="col-md-6">
						<div class="footer-nav">
							<?php 
    wp_nav_menu(array('theme_location' => 'footer-menu', 'container' => 'ul', 'depth' => 1));
    ?>
						</div>
					</div>
				<?php 
}
Exemple #19
0
    adventure_tours_the_content();
    ?>
</div>
		<?php 
    if (adventure_tours_get_option('social_sharing_blog')) {
        get_template_part('templates/parts/share-buttons');
    }
    ?>
	<?php 
}
?>
	</div>
	<?php 
if ($is_single) {
    ?>
		<?php 
    if (adventure_tours_get_option('about_author')) {
        get_template_part('templates/parts/about-author');
    }
    ?>
		<?php 
    get_template_part('templates/parts/post-navigation');
    ?>
		<?php 
    comments_template();
    ?>
	<?php 
}
?>
</article>
Exemple #20
0
<?php

/**
 * Template Name: FAQ
 *
 * @author    Themedelight
 * @package   Themedelight/AdventureTours
 * @version   1.1.2
 */
get_header();
$cat_tax_name = 'faq_category';
$mode_all = false;
$cat_taxonomies = array();
TdJsClientScript::addScript('faqAccorsionChagesIconInit', 'Theme.faqAccordionCahgesIcon();');
$is_sidebar = is_active_sidebar('faq-sidebar');
$show_question_form = adventure_tours_get_option('faq_show_question_form');
$is_show_col = $is_sidebar || $show_question_form;
$accordion_id = 1;
$accordion_item_id = 1;
if (adventure_tours_check('faq_taxonomies')) {
    if (is_tax($cat_tax_name)) {
        // query for particular category
        $cur_category = get_queried_object();
        if ($cur_category) {
            $cat_taxonomies[] = $cur_category;
        }
    } elseif (have_posts()) {
        // page template is used
        $mode_all = true;
        the_post();
        $cat_taxonomies = get_terms($cat_tax_name);
Exemple #21
0
		<?php 
adventure_tours_render_template_part('templates/parts/scheme-price', '', array('product' => $product));
adventure_tours_render_template_part('templates/parts/scheme-rating', '', array('product' => $product));
?>
		<?php 
if ($tour_thumbnail_url) {
    ?>
			<meta itemprop="image" content="<?php 
    echo esc_url($tour_thumbnail_url);
    ?>
">
		<?php 
}
?>
		<?php 
if (comments_open()) {
    comments_template();
}
?>

		<?php 
if (adventure_tours_get_option('tours_page_show_related_tours')) {
    get_template_part('templates/tour/related-tours');
}
?>
	</main>
	<?php 
get_sidebar('shop');
?>
</div>
Exemple #22
0
<?php

/**
 * Page header template part for the search field rendering.
 *
 * @author    Themedelight
 * @package   Themedelight/AdventureTours
 * @version   1.0.0
 */
if (!adventure_tours_get_option('show_header_search')) {
    return '';
}
// as in this case link tag will be placed to body withou property='stylesheet' attribute
// that makes html validation error
// wp_enqueue_style( 'magnific-popup' );
// wp_enqueue_script( 'magnific-popup' );
TdJsClientScript::addScript('initSerchFormPopup', 'Theme.initSerchFormPopup(' . wp_json_encode(array('placeholder_text' => esc_html__('Type in your request...', 'adventure-tours'))) . ');');
?>
<div class="header__info__item header__info__item--delimiter header__info__item--search"><a href="#search-form-header" class="popup-search-form" data-effect="mfp-zoom-in"><i class="fa fa-search"></i></a></div>

<div id="search-form-header" class="search-form-popup search-form-popup--hide mfp-with-anim mfp-hide ">
	<?php 
get_search_form();
?>
</div>
Exemple #23
0
	<div class="share-buttons__item share-buttons__item--facebook" data-btntype="facebook"></div>
<?php 
}
if (adventure_tours_get_option('social_sharing_twitter')) {
    ?>
	<div class="share-buttons__item share-buttons__item--twitter" data-btntype="twitter"></div>
<?php 
}
if (adventure_tours_get_option('social_sharing_stumbleupon')) {
    ?>
	<div class="share-buttons__item share-buttons__item--stumbleupon" data-btntype="stumbleupon"></div>
<?php 
}
if (adventure_tours_get_option('social_sharing_linkedin')) {
    ?>
	<div class="share-buttons__item share-buttons__item--linkedin" data-btntype="linkedin"></div>
<?php 
}
if (adventure_tours_get_option('social_sharing_pinterest')) {
    ?>
	<div class="share-buttons__item share-buttons__item--pinterest" data-btntype="pinterest"></div>
<?php 
}
if (adventure_tours_get_option('social_sharing_vk')) {
    ?>
	<div class="share-buttons__item share-buttons__item--vk" data-btntype="vk"></div>
<?php 
}
?>
</div>
 /**
  * Handler used for adding tour to the shopping card.
  * Used by booking form.
  *
  * @param string $url redirect url
  * @return void
  */
 public function handler_add_to_cart_handler_tour($url)
 {
     $is_ajax_reply = !empty($_REQUEST['is_ajax']);
     $product_id = $this->get_field_value('add-to-cart', null, 0);
     if ($product_id) {
         $product_id = apply_filters('woocommerce_add_to_cart_product_id', absint($product_id));
     }
     // tmp hack to prevent separation of the same product in shopping cart
     /*if ( $product_id && adventure_tours_check('is_wpml_in_use') ) {
     			$product_id = apply_filters( 'translate_object_id', $product_id, 'product', true, apply_filters( 'wpml_default_language', '' ) );
     		}*/
     if ($product_id < 1) {
         if ($is_ajax_reply) {
             echo wp_json_encode(array('success' => false));
             exit;
         }
         return;
     }
     $product = wc_get_product($product_id);
     list($left_add_counter, $added_to_cart, $booking_form_validation_errors) = $this->process_add_to_cart_request($product, WC()->cart);
     $is_success = !empty($added_to_cart) && wc_notice_count('error') == 0 && $left_add_counter < 1;
     if ($is_success) {
         $url = apply_filters('woocommerce_add_to_cart_redirect', $url);
         if (!$url) {
             $redirect_mode = adventure_tours_get_option('tours_booking_redirect', 'checkout_page');
             if ('checkout_page' == $redirect_mode) {
                 $url = WC()->cart->get_checkout_url();
             } elseif ('cart_page' == $redirect_mode || 'same_as_product' == $redirect_mode && get_option('woocommerce_cart_redirect_after_add') == 'yes') {
                 $url = WC()->cart->get_cart_url();
             }
         }
         $this->added_to_cart($product);
     }
     if ($is_ajax_reply) {
         $ajax_response = array('success' => $is_success);
         if ($is_success) {
             if ($url) {
                 $ajax_response['data'] = array('redirect_url' => $url);
             } else {
                 wc_add_to_cart_message($added_to_cart);
             }
         } else {
             $full_errors_set = $booking_form_validation_errors;
             $wc_notices = WC()->session->get('wc_notices', array());
             $shopping_cart_errors = !empty($wc_notices['error']) ? $wc_notices['error'] : array();
             if ($shopping_cart_errors) {
                 wc_clear_notices();
                 $full_errors_set[$this->get_error_movement_field('quantity')] = $shopping_cart_errors;
             }
             $ajax_response['data'] = array('errors' => $full_errors_set);
         }
         echo wp_json_encode($ajax_response);
         exit;
     } elseif ($is_success) {
         // If has custom URL redirect there
         if ($url) {
             wp_safe_redirect($url);
             exit;
         }
         wc_add_to_cart_message($added_to_cart);
     }
 }
Exemple #25
0
 /**
  * Returns range during that booking for specefied tour can be done.
  *
  * @param  int $tour_id
  * @return assoc        contains 'start' and 'end' keys with dates during that booking is active
  */
 function adventure_tours_get_tour_booking_range($tour_id)
 {
     static $start_days_in, $length;
     if (null == $start_days_in) {
         $start_days_in = (int) adventure_tours_get_option('tours_booking_start');
         $length = (int) adventure_tours_get_option('tours_booking_length');
         if ($start_days_in < 0) {
             $start_days_in = 0;
         }
         if ($length < 1) {
             $length = 1;
         }
     }
     $min_time = strtotime('+' . $start_days_in . ' day');
     $max_time = strtotime('+' . $length . ' day', $min_time);
     return array('start' => date('Y-m-d', $min_time), 'end' => date('Y-m-d', $max_time));
 }
Exemple #26
0
 public static function get_tour_base_rewrite_rule($with_front = false, $reset_cache = true)
 {
     static $base_url, $base_full, $is_front_page, $default_lang, $cur_lang;
     if (null === $base_url || $reset_cache) {
         $tours_page_id = adventure_tours_get_option('tours_page');
         // if WPML in use we need ensure that we have page_id in default language
         if (adventure_tours_check('is_wpml_in_use') && !is_admin()) {
             if (null === $cur_lang) {
                 $default_lang = apply_filters('wpml_default_language', '');
                 $cur_lang = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : $cur_lang;
             }
             if ($default_lang != $cur_lang) {
                 $page_id_in_default_lang = icl_object_id($tours_page_id, 'page', true, $default_lang);
                 if ($page_id_in_default_lang) {
                     $tours_page_id = $page_id_in_default_lang;
                 }
             }
         }
         if ($tours_page_id && 'page' == get_option('show_on_front') && $tours_page_id == get_option('page_on_front')) {
             $base_url = '';
             $is_front_page = true;
         } else {
             $base_url = $tours_page_id ? get_page_uri($tours_page_id) : 'tours';
             if ($base_url) {
                 $base_url .= '/';
             }
         }
     }
     if ($with_front) {
         if (null === $base_full || $reset_cache) {
             $base_full = $base_url || $is_front_page ? $GLOBALS['wp_rewrite']->front . $base_url : '';
         }
         return $base_full;
     }
     return $base_url;
 }