Ability to give discounts based on multiple rooms, or length of stay, etc

Ability to only charge a deposit at checkout and display total due on arrival, where an admin can set the type of deposit: %, set amount, or first night.

And, where where "pay in full" can still be an option to the customer with a possible discount if they do choose to pay in full up front.

Comments

ronald_istos’s picture

Status: Active » Needs work

You will be glad to know that we have price modifier hooks in head and dev version of module.

The hook_price_modifier_alter is called everytime a price is calculated and you can step in from your own module (as show below) to modify the price.

You define a modifier type giving it a type (currently just ROOMS_DYNAMIC_MODIFIER), an operation type (ROOMS_ADD, ROOMS_SUB, ROOMS_REPLACE, ROOMS_INCREASE, ROOMS_DECREASE) and the actual value. In the case of increase and decrease the value is consider a percentage so 10 would be 10%.

This needs more work and more documentation but the basics are finally in place.

function myrooms_rooms_price_modifier_alter(&$price_modifiers) {
  
  $price_modifiers['mydiscount'] = array(
    '#type' => ROOMS_DYNAMIC_MODIFIER,
    '#op_type' => ROOMS_SUB,
    '#amount' => 10,
  );

  $price_modifiers['weekenddiscount'] = array(
    '#type' => ROOMS_DYNAMIC_MODIFIER,
    '#op_type' => ROOMS_ADD,
    '#amount' => 1000,
  );
  
  
}
CodigoVision’s picture

excellent news, thanks for the update!

urlaub’s picture

A good solution if you only charge a deposit at checkout after reservation.

But what if I want to charge the remaing balance not on arrival, but for example 30 days before departure date? In this case the deposit would be kind of an partial payment of the order. Does that work out of the box with rooms? A d6-uc module with a related function would be: http://drupal.org/project/uc_downpayment

In combination the "pay in full" option would be a great feature as well, in order to offer early bird discounts.

hurdygurdy’s picture

I wondered about this also. My use case is an equipment rental where renting a particular item the first day costs a certain amount, and every subsequent day's rental fee is discounted, and a week's rental is a fixed price. Is it possible to do that with the price modifier function? Apply prices per day and per resource type?

pbrough’s picture

I have been trying to implement this but there is an error in the code for the module.

  $price_modifiers['mydiscount'] = array(
    '#type' => ROOMS_DYNAMIC_MODIFIER,
    '#op_type' => ROOMS_SUB,
    '#amount' => 10,
  );

Will provide a discount of 10 and not a %. To give a % discount you need to use:

  $price_modifiers['mydiscount'] = array(
    '#type' => ROOMS_DYNAMIC_MODIFIER,
    '#op_type' => ROOMS_DECREASE,
    '#amount' => 10,
  );

The hooks, ROOMS_ADD and ROOMS_SUB modify the price based on a fixed value. ROOMS_INCREASE and ROOMS_DECREASE modify the price based on a percentage.

fchandler’s picture

Issue summary: View changes

I am trying to do this as well, but getting nowhere. Admittedly I don't really know how to code in php. Here is what I did for my info file.

name = rooms_deposit
description = Allows for a deposit payment in Rooms.
core = 7.x
package = Rooms

dependencies[] = rooms

and the module file

<?php
function myrooms_rooms_price_modifier_alter(&$price_modifiers) {
  $price_modifiers['mydiscount'] = array(
    '#type' => ROOMS_DYNAMIC_MODIFIER,
    '#op_type' => ROOMS_DECREASE,
    '#amount' => 50,
  );
}

On Commerce's website they suggested creating a new product and apply it with rules, but there is one product (Rooms Basic Booking) and two product types (product and rooms product). I was thinking it would be creating a rooms product. Sorry I am a front end developer and content manager and am trying to break out of my box.

CodigoVision’s picture

Make sure your function name matches your module name:

function rooms_deposit_rooms_price_modifier_alter

AdamPS’s picture

1) The interface seems to have changed (oops breaks existing hooks - maybe wasn't a good idea?), there is a mandatory #quantity parameter.
2) Typically we don't want a discount that applies to every booking (else just make the price less!), rather only in certain cases.

Here is some example code that applies a discount for long stay bookings: 5% for 6+ days and 10% for 13+ days.

/**
 * Implements hook_rooms_price_modifier_alter().
 */
function XXXX_rooms_price_modifier_alter(&$price_modifiers, $booking_info)
{
  $days = $booking_info['end_date']->diff($booking_info['start_date'])->days;
  
  if ($days >= 6)
  {
    $price_modifiers['longstay'] = array(
      '#type' => ROOMS_DYNAMIC_MODIFIER,
      '#op_type' => ROOMS_DECREASE,
      '#amount' => 5,
      '#quantity' => 1,
    );

    if ($days >= 13) $price_modifiers['longstay']['#amount'] = 10;
  }
}
nandwabee’s picture

How would you go about setting different pricing for foreigners and citizens?

Trying to hack around using price modifiers without much success?

ITWest-jg’s picture

When searching for availability price_modifiers contains data from other units.

/**
 * Implements hook_rooms_price_modifier_alter().
 */
function XXXX_rooms_price_modifier_alter(&$price_modifiers, $booking_info)
{
  
  if (has_discount($booking_info))
  {
    $price_modifiers['XXXX.module'] = array(
      '#type' => ROOMS_DYNAMIC_MODIFIER,
      '#op_type' => ROOMS_DECREASE,
      '#amount' => 5,
      '#quantity' => 1,
    );
  } else {

    //
    // BUG FIX:
    //   $price_modifiers seems to contain data from another unit
    //
    if (isset($price_modifiers['XXXX.module'])) {
      unset($price_modifiers['XXXX.module']);
    }
  }
}
gorobinson’s picture

Interested in the first two features outlined here. Has anybody had any success with implementation and can share tips/instructions.

Length of stay based discounts
The php code shared by AdamPS looks perfect but not sure how best to implement as its own module (new to drupal/php). Any tips?

Deposit and payment framework
Also keen to set this up along the following lines;
User sends booking request > Rooms manager reviews and rejects/approves > Request sent for user to pay deposit (25%) or full amount > Request sent for outstanding balance due 6 weeks before start date > Once full payment received, property booking instructions sent
Has anyone had any success? I've seen references to http://drupal.org/project/uc_downpayment and other modules but no confirmed examples or implementation instructions.

Finabluma’s picture

Hi, I wonder how we can filtre the price_modifier by unit-types? Could anyone give some tip about this?

Finabluma’s picture

Sorry, I asked for something that it was easy to solve. With a few lines is been fixed.

Finabluma’s picture

Hi! I'm quite lost on this. I managed to alter $pricemodifiers depending the searchings. But now I would like to print on the search_results page the modifier applied to a certain search result. I want to do this just to show the increment we add to the final price. I guess that with a couple lines we should do this but I have no clue how to do it. I would really appreciate if anyone could give me some tips to solve this. I attached the function to alter the price modifier just in case that helps to clarify what i'm looking for.

function roomify_pisos_rooms_price_modifier_alter(&$price_modifiers, $booking_info){

  // Fetching the room type.
  $room_type = $booking_info['unit']->type;

  // Declaring various room types to check for.
  $compartido = 'alquiler_compartido';

  $days = $booking_info['end_date']->diff($booking_info['start_date'])->days;

  if ($room_type == $compartido){

    if ($days >= 32 && $compartido){

      $price_modifiers['longstay'] = array(
        '#name' => 'Honorarios pisos Medicos',
        '#type' => ROOMS_DYNAMIC_MODIFIER,
        '#quantity' => 1,
        '#op_type' => ROOMS_ADD,
        '#amount' => 100,
      );      

      if ($days >= 48 && $compartido) $price_modifiers['longstay']['#amount'] = 175;

      if ($days >= 75 && $compartido) $price_modifiers['longstay']['#amount'] = 225;

      if ($days >= 105 && $compartido) $price_modifiers['longstay']['#amount'] = 275;

      if ($days >= 135 && $compartido) $price_modifiers['longstay']['#amount'] = 325;

      if ($days >= 165 && $compartido) $price_modifiers['longstay']['#amount'] = 375;

      if ($days >= 195 && $compartido) $price_modifiers['longstay']['#amount'] = 425;

      if ($days >= 225 && $compartido) $price_modifiers['longstay']['#amount'] = 475;

      if ($days >= 255 && $compartido) $price_modifiers['longstay']['#amount'] = 525;

      if ($days >= 285 && $compartido) $price_modifiers['longstay']['#amount'] = 600;

      // kpr($price_modifiers); 
    }    
  }
}
Finabluma’s picture

Does anyone knows how to render the pricemodifier applied independently the total price? I'd really appreciate if anyone could give some tips. I need to render them on the page as info to the visitor. I've trying for some while to solve by myself but without results :(