Created
October 29, 2012 23:26
-
-
Save yattias/3977303 to your computer and use it in GitHub Desktop.
Converting an hold on an inventory item to a reservation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @author K0b3 | |
* Makes a service request to reservations api in order to create a reservation | |
* @param <int> $hold_id | |
* The hold ID to be upgraded to a reservation | |
* @param <int> $order_group_id | |
* The order group which the hold is part of | |
* @param <int> $customer_id | |
* The user ID | |
* @return <int> -1 if failed to create reservation OR reservation booking ID or FALSE on failure | |
* @since 11/30/2011 | |
*/ | |
function res_v2_reserve_hold($hold_id, $order_group_id, $customer_id) { | |
$rbid = FALSE; | |
if (!empty($customer_id) && !empty($order_group_id) && !empty($hold_id) && is_numeric($customer_id) && $customer_id > 0) { | |
//ASSERT: Required params are available | |
//Assemble params | |
$params = array( | |
'reservationHoldId' => $hold_id, | |
'orderGroupId' => $order_group_id, | |
'customerId' => $customer_id | |
); | |
$response = rtr_services_exec( | |
RESERVATION_SERVICE, | |
RESERVE, | |
$params, | |
RESERVE_HTTP_METHOD, 1); | |
if (!is_numeric($response['response']) || (is_numeric($response['response']) && $response['response'] == '-1')) { | |
//ASSERT: Failure occured trying to create a hold | |
rtr_error('Reservations2 ALERT:: Failed to create a reservation'); | |
} | |
else { | |
rtr_info('SUCCESS reserving hold: ' . $hold_id); | |
$rbid = $response['response']; | |
} | |
} | |
else { | |
rtr_warn('Reservations2 ALERT:: Malformed list of arguments was detected'); | |
} | |
return $rbid; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment