// If a submission account is specified (otherwise it should be a guest user prior to checkout)
if ($this->cart['request']['account'] && !isset($this->cart['accounts'][$this->cart['request']['account']])) {
- $this->cart['messages'][] .= 'Account for person submitting the request is missing.';
+ $this->cart['messages'][] .= 'The account for person submitting the request is missing.';
}
/*
// If we don't have events for this cart
if (!is_array($this->cart['events']) || count($this->cart['events']) == 0) {
- $this->cart['messages'][] = 'Cart is empty.';
+ $this->cart['messages'][] = 'Your cart is empty.';
$this->cart['blockCheckout'] = true;
} else {
// If this registrant is flagged for removal from cart
if ($removeRegistrant) {
-// *** remove registrant from cart in Database
+
+ // Remove registrant request from Database
+ $this->removeRegistrantFromCart($registrant['id']);
+
$this->cart['message'][] = 'Registrant '.$registrant['fname'].' '.$registrant['fname'].' was removed from cart due to lack of availabile space.';
$this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['removed'] = true;
$this->cart['blockCheckout'] = true;
$rateBaseCharge = $rate['base_rate'];
}
$rateRegistrants++;
+
if ($rateRegistrants > $rate['registrant_credits']) {
$registrantCharges = $rate['per_registrant'];
}
// If we don't have registrants
if (!$haveRegistrants) {
- $this->cart['messages'][] = 'Rate '.$rate['rate_name'].' has no registrants.';
+ $this->cart['messages'][] = 'Rate "'.$rate['rate_name'].'" has no registrants. This rate has been removed from the cart.';
$removeRate = true;
$deleteRateNow = true;
}
if ($removeRate) {
-// Remove rate from cart in database
+ // Remove rate request from database
+ $this->removeRateFromCart($rate['id']);
+
$this->cart['message'][] = 'Rate '.$rate['rate_name'].' was removed from cart.';
$this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['removed'] = true;
$this->cart['blockCheckout'] = true;
// If we don't have rates
if (!$haveRates) {
- $this->cart['messages'][] = 'Class '.$class['class_name'].' has no rates.';
+ $this->cart['messages'][] = 'Class "'.$class['class_name'].'" has no rates. This class has been removed from the cart.';
$removeClass = true;
$deleteClassNow = true;
}
// If class has been flagged for removal from cart, delete it from cart in database
if ($removeClass) {
+ // Remove class request from Database
+ $this->removeClassFromCart($class['id']);
+
$this->cart['message'][] = 'Class '.$class['class_name'].' was removed from cart.';
$this->cart['events'][$eventKey]['classes'][$classKey]['removed'] = true;
$this->cart['blockCheckout'] = true;
-// *** remove class from cart in Database
-
} else {
$haveClasses = true;
// If we don't have classes
if (!$haveClasses) {
- $this->cart['messages'][] = 'Event '.$event['event_name'].' has no classes.';
+ $this->cart['messages'][] = 'Event "'.$event['event_name'].'" has no classes. This event has been removed from the cart.';
$removeEvent = true;
$deleteEventNow = true;
}
// If has been flagged for removal from cart, delete it from cart in database
if ($removeEvent) {
+ // Remove event request from database
+ $this->removeEventFromCart($event['id']);
+
$this->cart['message'][] = 'Event '.$event['event_name'].' was removed from cart.';
$this->cart['events'][$eventKey]['removed'] = true;
$this->cart['blockCheckout'] = true;
-// *** remove event from cart in Database
-
} else {
$haveEvents = true;
$this->cart['validated'] = true;
}
+ // If a JSON is requested, return data that way
if ($json) {
return json_encode($this->cart);
}
return false;
}
+ /*
+ * Remove a registrant record from the cart
+ *
+ *
+ * @param integer $id ID of this reg_request_registrant record
+ *
+ * @access public
+ */
+ public function removeRegistrantFromCart($registrantId)
+ {
+
+ $RequestRegistrant = new GlmDataRegistrationsRequestRegistrant($this->wpdb, $this->config);
+ $RequestRegistrant->deleteEntry($registrantId, true);
+
+ }
+
+ /*
+ * Remove a rate record from the cart
+ *
+ *
+ * @param integer $id ID of this reg_request_rate record
+ *
+ * @access public
+ */
+ public function removeRateFromCart($rateId)
+ {
+
+ $RequestRate = new GlmDataRegistrationsRegRequestRate($this->wpdb, $this->config);
+ $RequestRate->deleteEntry($rateId, true);
+
+ }
+
+ /*
+ * Remove a class record from the cart
+ *
+ *
+ * @param integer $id ID of this reg_request_class record
+ *
+ * @access public
+ */
+ public function removeClassFromCart($classId)
+ {
+
+ $RequestClass = new GlmDataRegistrationsRequestClass($this->wpdb, $this->config);
+ $RequestClass->deleteEntry($classId, true);
+
+ }
+
+ /*
+ * Remove an event record from the cart
+ *
+ *
+ * @param integer $id ID of this reg_request_event record
+ *
+ * @access public
+ */
+ public function removeEventFromCart($eventId)
+ {
+
+ $RequestEvent = new GlmDataRegistrationsRequestEvent($this->wpdb, $this->config);
+ $RequestEvent->deleteEntry($eventId, true);
+
+ }
+
+
/*
* Add an account to the accounts list in the temoporary cart array if not already there