Ejemplo n.º 1
0
    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 
    }
Ejemplo n.º 2
0
function bizz_extra_price($extra_id = '', $carhire_cookie = '', $taxed = false, $coupon_post = '', $opt_s = '', $single = false)
{
    // tax percentage
    $tax_percentage = isset($opt_s['pay_tax']) ? currencystr_to_float($opt_s['pay_tax'], $opt_s) / 100 : 1;
    // price
    $price = get_option('taxonomy_' . $extra_id . '_bizz_extra_price');
    $price = currencystr_to_float($price, $opt_s);
    $max_price = get_option('taxonomy_' . $extra_id . '_bizz_max_extra_price');
    $max_price = currencystr_to_float($max_price, $opt_s);
    // apply coupon per unit
    if ($coupon_post && (in_array($extra_id, $coupon_post['extra']) || in_array('all', $coupon_post['extra'])) && $coupon_post['type'] == 'fixed_unit') {
        $price = $price - $coupon_post['amount'];
    }
    // tax
    if ($taxed) {
        $price = $price + $price * $tax_percentage;
    }
    // range
    $range = get_option('taxonomy_' . $extra_id . '_bizz_extra_price_s');
    // per rental or daily?
    $calculate = $range == 'rental' ? 1 : $carhire_cookie->count_slots;
    // price for all booked days
    $price = $price * $calculate;
    // apply coupon per percantage
    if ($coupon_post && (in_array($extra_id, $coupon_post['extra']) || in_array('all', $coupon_post['extra'])) && $coupon_post['type'] == 'percentage') {
        $percentage = currencystr_to_float($coupon_post['amount'], $opt_s) / 100;
        $price = $price - $price * $percentage;
    }
    // apply coupon per block
    if ($coupon_post && (in_array($extra_id, $coupon_post['extra']) || in_array('all', $coupon_post['extra'])) && $coupon_post['type'] == 'fixed_block') {
        $price = $price - $coupon_post['amount'];
    }
    // force single
    if ($single) {
        $price = $price / $calculate;
    }
    // max price?
    if ($max_price && $max_price < $price) {
        $price = $max_price;
    }
    return $price;
}
Ejemplo n.º 3
0
function custom_bizz_render_remaining($field, $meta)
{
    global $post, $booking_settings;
    // currency
    $currency = !empty($field['currency']) ? $field['currency'] : '$';
    // get booking settings
    $opt_s = $booking_settings->get_settings();
    // calculate
    $total = get_post_meta($post->ID, 'bizzthemes_car_pay_total', true);
    $paid = get_post_meta($post->ID, 'bizzthemes_car_pay_paid', true);
    $remaining = currencystr_to_float($total, $opt_s) - currencystr_to_float($paid, $opt_s);
    // output
    echo '<table>';
    echo '<tr>';
    echo '<td style="padding: 0;">';
    echo $currency . '&nbsp;' . $remaining . '<span class="bizz_metabox_description">', $field['desc'], '</span>';
    echo '</td>';
    echo '</tr>';
    echo '</table>';
}
Ejemplo n.º 4
0
function bizz_redirect_mollie($return, $bookopts, $form_data, $this_post_id, $opt_s)
{
    if (isset($form_data['payment_method']) && $form_data['payment_method'] == 'mollie') {
        // Initialize
        require_once dirname(__FILE__) . "/mollie-api/src/Mollie/API/Autoloader.php";
        $mollie = new Mollie_API_Client();
        $api = $opt_s['pay_mollie_api'] != '' ? $opt_s['pay_mollie_api'] : 'test_W9vJrPAB2Jv4LGRZkGZgLmkznzDAs2';
        $mollie->setApiKey($api);
        // Order ID
        $order_id = $bookopts['tracking_id'];
        /*
         * Payment parameters:
         *   amount        Amount in EUROs. This example creates a € 10,- payment.
         *   description   Description of the payment.
         *   redirectUrl   Redirect location. The customer will be redirected there after the payment.
         *   metadata      Custom metadata that is stored with the payment.
         */
        $payment = $mollie->payments->create(apply_filters('bizz_mollie_call', array("amount" => currencystr_to_float($bookopts['pay_deposit'], $opt_s), "description" => __('Deposit', 'bizzthemes'), "webhookUrl" => trailingslashit(home_url()) . "?mollie={$order_id}", "redirectUrl" => $opt_s['pay_thankyou'], "metadata" => array("order_id" => $order_id, "post_id" => $this_post_id))));
        // Send the customer off to complete the payment.
        return $payment->getPaymentUrl();
    }
}