function page() { global $booking_settings; // get booking settings $opt_s = $booking_settings->get_settings(); ?> <div class="headline_area"> <h1 class="title"><?php the_title(); ?> </h1> </div> <div class="wrapper"> <div class="row"> <div class="filter fil-1 col-md-6"> <label for="car_type"><?php _e('Type:', 'bizzthemes'); ?> </label> <select id="car_type" class="form-control car_type"> <option value="-1"><?php _e('Any', 'bizzthemes'); ?> </option> <?php $type_terms = get_terms('bizz_cars_type', array('hide_empty' => 0)); $type_options = array(); foreach ($type_terms as $type_term) { echo '<option value="' . $type_term->slug . '">' . $type_term->name . '</option>'; } ?> </select> </div> <div class="filter fil-3 col-md-6"> <label for="car_sort"><?php _e('Sort:', 'bizzthemes'); ?> </label> <select id="car_sort" class="form-control car_sort"> <option value="-1"><?php _e('Latest first', 'bizzthemes'); ?> </option> <option value="price-low" <?php selected($opt_s['vehicle_sort'], 'price-asc'); ?> ><?php _e('Price: low to high', 'bizzthemes'); ?> </option> <option value="price-high" <?php selected($opt_s['vehicle_sort'], 'price-desc'); ?> ><?php _e('Price: high to low', 'bizzthemes'); ?> </option> <option value="name-asc" <?php selected($opt_s['vehicle_sort'], 'name-asc'); ?> ><?php _e('Name: ascending', 'bizzthemes'); ?> </option> <option value="name-desc" <?php selected($opt_s['vehicle_sort'], 'name-desc'); ?> ><?php _e('Name: descending', 'bizzthemes'); ?> </option> </select> </div> </div> <ul id="car_list" class="templatelist clist"> <?php // car posts $args = apply_filters('bizz_car_return', array('post_type' => 'bizz_cars', 'numberposts' => -1, 'suppress_filters' => false)); $car_posts = get_posts($args); // pricing posts $args = array('post_type' => 'bizz_pricing', 'numberposts' => -1, 'fields' => 'ids', 'suppress_filters' => false); $pricing_posts = get_posts($args); $car_options["cars"] = array(); foreach ($car_posts as $car_post) { $custom = get_post_custom($car_post->ID); $car_img = isset($custom["bizzthemes_car_image"][0]) ? $custom["bizzthemes_car_image"][0] : get_template_directory_uri() . '/lib_theme/images/no-img.jpg'; // from $price_from = '<span class="from">' . __('from', 'bizzthemes') . '</span>'; // range $price_range = isset($opt_s['pay_pricerange']) && $opt_s['pay_pricerange'] == 'perhour' ? __('per hour', 'bizzthemes') : __('per day', 'bizzthemes'); $price_range = '<span class="range">' . $price_range . '</span>'; // pricing $pricing = array(); $car_pricing = get_post_meta($car_post->ID, 'bizzthemes_car_pricing', true); foreach ($pricing_posts as $post_id) { $post_custom = get_post_custom($post_id); $queried_post = get_post($post_id); // skip other car types if ($car_pricing && !in_array($queried_post->post_name, $car_pricing)) { continue; } else { if (!$car_pricing && isset($post_custom['bizzthemes_price_type'][0]) && $custom["bizzthemes_car_type"][0] != $post_custom['bizzthemes_price_type'][0]) { continue; } } $post_price = currencystr_to_float($post_custom['bizzthemes_price_daily'][0], $opt_s); $pricing[] = $post_price; } if (!empty($pricing)) { // tax percentage $tax_percentage = isset($opt_s['pay_tax']) ? currencystr_to_float($opt_s['pay_tax'], $opt_s) / 100 : 1; $pricing = min($pricing); #take lowest $pricing = $pricing + $pricing * $tax_percentage; $price = $price_from . '<br/>' . float_to_currencystr($pricing, true, $opt_s) . '<br/>' . $price_range; } else { $pricing = ''; $price = ''; } // build car options array $car_options["cars"][] = array('id' => $car_post->ID, 'post_name' => $car_post->post_name, 'name' => $car_post->post_title, 'description' => do_shortcode($custom["bizzthemes_car_description"][0]), 'edit' => get_edit_post_link($car_post->ID), 'picture_src' => $car_img, 'type' => $custom["bizzthemes_car_type"], 'currency' => get_bizz_currency($opt_s['pay_currency']), 'cost' => $price == "" ? 'not-set' : $price, 'cost_val' => $pricing == "" ? 'not-set' : $pricing, 'availability' => true, 'equipment' => array('seats' => $custom["bizzthemes_car_seats"][0], 'doors' => $custom["bizzthemes_car_doors"][0], 'transmission' => $custom["bizzthemes_car_transmission"][0])); } // sort the same as on booking widget $car_options["cars"] = apply_filters('bizz_car_sort', bizz_list_sort($car_options["cars"], 'availability'), $car_options["cars"]); foreach ($car_options["cars"] as $car_post) { ?> <li class="clearfix" id="li_car_<?php echo $car_post['id']; ?> "> <div class="data_wrapper"> <div class="picture left"> <img class="car_image img-polaroid" src="<?php echo $car_post['picture_src']; ?> " width="100" alt="" /> </div> <div class="details clearfix"> <h2 class="car_name"><?php echo $car_post['name']; ?> iii</h2> <input type="hidden" class="car_id" value="<?php echo $car_post['id']; ?> " /> <input type="hidden" class="car_type" value="<?php echo implode(",", $car_post["type"]); ?> " /> <input type="hidden" class="car_transmission" value="<?php echo $car_post["equipment"]["transmission"]; ?> " /> <input type="hidden" class="car_val" value="<?php echo $car_post['cost_val']; ?> " /> <ul class="car_properties"> <li class="seats"><span class="eq_value"><?php echo $car_post["equipment"]["seats"]; ?> </span></li> <li class="doors"><span class="eq_value"><?php echo $car_post["equipment"]["doors"]; ?> </span></li> <li class="transmission"><span class="eq_value"><?php echo $car_post["equipment"]["transmission"]; ?> </span></li> </ul> <a href="#" class="toggled car_details"><?php _e('Details', 'bizzthemes'); ?> </a> <?php if (current_user_can('manage_options')) { ?> <a href="<?php echo get_edit_post_link($car_post['id']); ?> " class="car_edit"><?php _e('(Edit)', 'bizzthemes'); ?> </a> <?php } ?> <div class="car_details_tooltip"><?php echo wpautop($car_post["description"]); ?> </div> </div> </div> <div class="price_wrapper"> <!-- Button to trigger modal --> <button data-target="#bookingmodal" role="button" class="btn btn-danger btn-bookingmodal" data-toggle="modal"><?php _e('Book Now', 'bizzthemes'); ?> </button> <span class="car_price"><?php echo $car_post['cost']; ?> </span> </div> </li> <?php } ?> </ul> </div> <?php }
function bizz_return_car_extras($car_id = '', $coupon_post = '', $opt_s = '') { // read cookie $carhire_cookie = array(); $carhire_cookie = json_decode(stripslashes($_COOKIE['carhire'])); // list extras $extras = get_terms('bizz_cars_extra', apply_filters('bizz_cars_extra_args', array('hide_empty' => 0))); $count = count($extras); $car_extras["car_extras"] = array(); $custom = get_post_custom($car_id); #car id $car_extras = isset($custom["bizzthemes_car_extras"]) ? $custom["bizzthemes_car_extras"] : ''; $car_extras = is_array($car_extras) ? $car_extras : array(); if ($count > 0) { foreach ($extras as $extra) { if (!in_array($extra->slug, $car_extras)) { #1476 for porsche continue; } // thumbnail $extra_img = get_option('taxonomy_' . $extra->term_id . '_bizz_extra_image'); $extra_img = $extra_img ? $extra_img : get_template_directory_uri() . '/lib_theme/images/no-img.jpg'; // count $extra_count = get_option('taxonomy_' . $extra->term_id . '_bizz_extra_count'); $extra_count = $extra_count ? $extra_count : 1; // required $extra_required = get_option('taxonomy_' . $extra->term_id . '_bizz_extra_required'); $extra_required = $extra_required ? $extra_required : 0; // field $extra_field = get_option('taxonomy_' . $extra->term_id . '_bizz_extra_field'); $extra_field = $extra_field ? $extra_field : 0; // field placeholder $extra_field_placeholder = get_option('taxonomy_' . $extra->term_id . '_bizz_extra_field_placeholder'); $extra_field_placeholder = $extra_field_placeholder ? $extra_field_placeholder : ''; // bind to pickup location $extra_location = get_option('taxonomy_' . $extra->term_id . '_bizz_extra_location'); $extra_location = $extra_location ? $extra_location : array(); $extra_location = is_array($extra_location) ? $extra_location : array($extra_location); // bind to return location $extra_location_return = get_option('taxonomy_' . $extra->term_id . '_bizz_extra_location_return'); $extra_location_return = $extra_location_return ? $extra_location_return : array(); $extra_location_return = is_array($extra_location_return) ? $extra_location_return : array($extra_location_return); // bind to different location $extra_location_diff = get_option('taxonomy_' . $extra->term_id . '_bizz_extra_location_diff'); $extra_location_diff = $extra_location_diff ? $extra_location_diff : 0; // range $range = get_option('taxonomy_' . $extra->term_id . '_bizz_extra_price_s'); $day_hour = $opt_s['pay_pricerange'] == 'perhour' ? __('per hour', 'bizzthemes') : __('per day', 'bizzthemes'); $extra_range = $range == 'rental' ? __('per rental', 'bizzthemes') : $day_hour; $extra_price = float_to_currencystr(bizz_extra_price($extra->term_id, $carhire_cookie, true, '', $opt_s, true), true, $opt_s) . ' ' . $extra_range; $extra_price_disc = float_to_currencystr(bizz_extra_price($extra->term_id, $carhire_cookie, true, $coupon_post, $opt_s, true), true, $opt_s) . ' ' . $extra_range; // skip if extra bound to pickup location and pickup location is different and should be same if (count($extra_location) >= 1 && count(array_intersect(array($carhire_cookie->location_of_pickup, $carhire_cookie->location_of_pickup_slug), $extra_location)) == 0) { continue; } // skip if extra bound to return location and return location is different and should be same if (count($extra_location_return) >= 1 && count(array_intersect(array($carhire_cookie->location_of_return, $carhire_cookie->location_of_return_slug), $extra_location_return)) == 0) { continue; } // skip if extra bound to location and location is same, but should be different if ($extra_location_diff && $carhire_cookie->location_of_pickup == $carhire_cookie->location_of_return) { continue; } $car_extras["car_extras"][] = array('id' => $extra->term_id, 'slug' => $extra->slug, 'name' => $extra->name, 'description' => do_shortcode($extra->description), 'cost' => float_to_currencystr(bizz_extra_price($extra->term_id, $carhire_cookie, true, '', $opt_s), true, $opt_s), 'cost_disc' => float_to_currencystr(bizz_extra_price($extra->term_id, $carhire_cookie, true, $coupon_post, $opt_s), true, $opt_s), 'cost_val' => float_to_currencystr(bizz_extra_price($extra->term_id, $carhire_cookie, false, $coupon_post, $opt_s), true, $opt_s), 'cost_val_disc' => float_to_currencystr(bizz_extra_price($extra->term_id, $carhire_cookie, false, '', $opt_s), true, $opt_s), 'cost_int' => $extra_price, 'cost_int_disc' => $extra_price_disc, 'cost_n' => bizz_extra_price($extra->term_id, $carhire_cookie, false, $coupon_post, $opt_s), 'picture_src' => $extra_img, 'currency' => get_bizz_currency($opt_s['pay_currency']), 'count' => $extra_count, 'required' => $extra_required, 'availability' => 1, 'field' => $extra_field, 'field_placeholder' => $extra_field_placeholder); } if (isset($car_extras["car_extras"]) && !class_exists('TheTaxonomySort')) { $car_extras["car_extras"] = apply_filters('bizz_extras_sort', bizz_list_sort($car_extras["car_extras"], 'required', 'asc'), $car_extras["car_extras"]); } } return json_encode($car_extras); }