Q137: How to set up a custom pricing scheme?

Ti trovi qui: ibookfishing » Aiuto » Domande frequenti » Q137: How to set up a custom pricing scheme?
Note: this is an advanced topic not directly supported by ibookfishing's interface and requiring programming skills.

ibookfishing's Pricing Manager supports a vast range of pricing models that include seasonal pricing and discounts depending on a number of conditions (see this question for more info).

If this doesn't fit your pricing model, you can specify a completely custom pricing scheme in form of an external script located on your web server that will return the price based on the input parameters passed to your script by ibookfishing, such as rental start/end time, number of persons, number of resources rented and resource ID.

If you're not a developer, we can write the script for you. In exchange we ask you to credit your own ibookfishing account with a one-time payment of EUR 50 - 100 for simple scripts (ask us if in doubt). Then, we'll need you to send us the exact specification of your pricing structure. So, this way we write this script for you free of charge if you continue using our service.

To use a custom pricing scheme, instead of specifying price in resource settings (you can also do this in the Default price rule in Pricing Manager), specify the URL of your script (e.g. http://yoursite.com/scriptname.php). Please note that further Pricing Manager rules (after Default price) will not be applied when custom script is used. The following parameters are sent (POST method):

  • start (int) -- start time (sent as timestamp, that is the number of seconds since January 1 1970 00:00:00)
  • end (int) -- end time (sent as timestamp)
  • persons (int) -- number of persons
  • resource (int) -- id of the resource to be rented
  • units (int) -- number of time units for rental
  • The script also receives all additional reservation data (depending on which data is specified for given resource). For example, if you added to the reservation form a check box 'Airport transfer' it would be passed as URL parameter 'Airport_transfer'. Note that space and other non-alphanumerical characters are replaced with underscore. Checkboxes, if selected, will have the value: on (no value otherwise).
  • prev-res -- this parameter contains all reservations from the same user for given month (plus previous month) in form of semi-colon separated objects. A single object in in turn a comma-separated list containing the following items: start_time_timestamp(int), end_time_timestamp(int), resource_id(int), quantity(int), status(int)
  • user_xxx - all user-specific properties are passed to the script with the user_ prefix
  • zip - contains user's zip code
  • country - user's country code (ISO 3166), e.g. US for the USA, DE for Germany

The script should return a simple amount (float) such as "10.00" or "105.80" without any other content. The amount should be the gross price (incl. taxes if any).

If you want an error message to be displayed to the client, the script must return the text Error: followed by your error message. This is very useful if you want to specify custom unavailability rules (e.g. on weekends reservations must be for min. 2 hours)

Here's a sample PHP script that can calculate a different price for weekly and daily rentals as well as for different seasons:


< ?php
// date/time functions will work fine with timezone set to GMT
date_default_timezone_set (GMT);

// sample seasons and pricing here
define ('HIGH_SEASON_MONTH_START', 7); // first month of high season (without discount)
define ('HIGH_SEASON_MONTH_END', 9); // last month of high season (without discount)
define ('LOW_SEASON_DISCOUNT', 20); // discount in %
define ('WEEKLY_PRICE', 100); // price for a week in EUR
define ('DAILY_PRICE', 20); // price per day in EUR

function get_param ($name) {
        global $_GET; // let's check GET parameters as well for testing purposes
        global $_POST; // parameters are sent by ibookfishing using POST
        if (isset ($_GET [$name]))
                return $_GET [$name];
        return $_POST [$name];
}

// parameters passed by ibookfishing
$units = get_param ('units'); // number of time units
$count = get_param ('count'); // number of resources
$start_date_stamp = get_param ('start'); // start date
$end_date_stamp = get_param ('end'); // end date
$persons = get_param ('persons'); // number of persons
$resource = get_param ('resource'); // resource id

// start date
$start_date = getdate ($start_date_stamp);
$month = $start_date ['mon'];

// season-based discount
if ($month < HIGH_SEASON_MONTH_START || $month > HIGH_SEASON_MONTH_END)
        $discount_factor = 100 - LOW_SEASON_DISCOUNT;
else
        $discount_factor = 100;

// use weekly or daily price
if ($units >= 7) {
        $weeks = ceil ($units / 7);
        $price = $weeks * WEEKLY_PRICE * $discount_factor / 100;
}
else {
        $price = $units * DAILY_PRICE * $discount_factor / 100;
}

echo $price;

? >


You can test/debug your pricing script by going to http://www.ibookfishing.com/reserve-test.php (you need to be logged in first). Here you can enter your custom pricing URL, choose the dates and under the price shown you can click on the link 'Price URL used'. This will give you the exact parameters passed by ibookfishing to your script for given input parameters (start/end time, number of persons etc.).