Quote from: splittingred at Feb 07, 2011, 12:16 PM
Can you post the *entire* code of your hook?
Here it is. Although it’s no longer a hook but a snippet I call in the "Thank you" page (after calling the FormitRetriever). So for that to work, I had to relay the $hook->getValue() calls to $modx->getPlaceholder() method as the snippet is no longer running in the "context" of Formit. Essentially the other elements of the snippet did not change. The initialisation (first three lines) were taken from the Formit snippet and add the correct package.
<?php
require_once $modx->getOption('tariffs.core_path',null,$modx->getOption('core_path').'components/tariffs/').'model/tariffs/tariffs.class.php';
$tar = new Tariffs($modx,$scriptProperties);
$tar->initialize($modx->context->get('key'));
$cottageId = $modx->getPlaceholder('fi.cottage-id');
$cottage = $modx->getObject('Cottage', $cottageId);
// add booking
$booking = $modx->newObject('Booking');
$booking->set('title', $modx->getPlaceholder('fi.title'));
$booking->set('name', $modx->getPlaceholder('fi.lastname'));
$booking->set('firstname', $modx->getPlaceholder('fi.firstname'));
$booking->set('email', $modx->getPlaceholder('fi.email'));
$booking->set('phone', $modx->getPlaceholder('fi.phone'));
$booking->set('country', $modx->getPlaceholder('fi.country'));
$booking->set('cottage', $cottageId);
$booking->set('arrival_date', date('Y-m-d', strtotime($modx->getPlaceholder('fi.arrival-date'))));
$booking->set('departure_date', date('Y-m-d', strtotime($modx->getPlaceholder('fi.departure-date'))));
$booking->set('tariff', $modx->getPlaceholder('fi.tariff'));
$booking->set('adults', $modx->getPlaceholder('fi.adults'));
$booking->set('children', $modx->getPlaceholder('fi.children'));
$booking->set('dogs', $modx->getPlaceholder('fi.dogs'));
if ($modx->getPlaceholder('fi.comments') == null) {
$booking->set('guest_comments', '');
} else {
$booking->set('guest_comments', $modx->getPlaceholder('fi.comments'));
}
$booking->calculateDeposit();
$booking->set('deposit_paid', 'N');
$booking->set('balance_paid', 'N');
$booking->set('confirmed', 'N');
$booking->set('booking_date', date('Y-m-d', strtotime('now')));
$booking->set('source', 'Go Skye website');
$booking->save();
// update calendar
$calendar = new Calendar($cottage, $modx);
$calendar->markOccupied($booking->get('arrival_date'), $booking->get('departure_date'));
return true;