From 3905929f34578c30b46e4ca93f18172f59075c7b Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Thu, 21 Dec 2017 12:40:28 -0500 Subject: [PATCH] Added custom form data to cart summary view. Now respecting priority flags. --- .gitignore | 5 ++- classes/regCartSupport.php | 27 ++++++++++++---- models/front/registrations/cart.php | 2 +- views/front/registrations/cartSummary.html | 36 ++++++++++++++++++---- 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index a14ebf5..cd7b240 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ node_modules/ -.project \ No newline at end of file +.gitignore +.project +.buildpath +.settings/ diff --git a/classes/regCartSupport.php b/classes/regCartSupport.php index 7a2aecc..c1a02c2 100644 --- a/classes/regCartSupport.php +++ b/classes/regCartSupport.php @@ -221,6 +221,12 @@ class GlmRegCartSupport $e = $RegEvent->getEntry($event['reg_event']); $this->cart['events'][$eventKey]['payment_methods'] = $e['payment_methods']; + // If custom fields add-on is installed - get custom fields data + if (apply_filters('glm-members-customfields-plugin-active', false)) { + $this->cart['events'][$eventKey]['event_custom_form'] = + apply_filters( 'glm-members-customfields-form-data-recall', '', "glm_reg_customfields_reg_event_".$event['reg_event'], $requestId, true ); + } + // Get list of event classes requested for this event $this->cart['events'][$eventKey]['classes'] = $RequestClass->getList("T.reg_request_event = ".$event['id']); @@ -277,16 +283,19 @@ class GlmRegCartSupport } + // If custom fields add-on is installed - get custom fields data + $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['event_attendee_custom_form'] = false; + if (apply_filters('glm-members-customfields-plugin-active', false)) { + $form = apply_filters( 'glm-members-customfields-form-data-recall', '', "glm_reg_customfields_reg_event_attendee_".$event['reg_event'], $registrantKey, true ); + $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['event_attendee_custom_form'] = $form; + } + } // Each Registrant } - } // Each Rate } - - } // Each Class } - } // Each Event } @@ -334,9 +343,9 @@ class GlmRegCartSupport */ public function checkRegistrationRequest($requestId = false, $json = false, $noReturn = false) { - + // echo "SESSION DATA:
".print_r($_SESSION,1).print_r($regRequest,1)."
"; - + // Try to get the cart data $this->getRegistrationCart($requestId, false, true); @@ -346,6 +355,7 @@ class GlmRegCartSupport if (!$this->cart['status']) { $this->cart['blockCheckout'] = true; $_SESSION['glm_reg_cart_id'] = false; + trigger_error('Cart ID '.$requestId.' does not have matching reg_request record. Cart ID removed from session.'); return $this->cart; } @@ -515,6 +525,11 @@ class GlmRegCartSupport $rateRegistrantCharges += $registrantCharges; $rateDiscounts += $registrantDiscounts; + // Add in any custom form costs + if ($registrant['event_attendee_custom_form']) { + $rateRegistrantCharges += $registrant['event_attendee_custom_form']['totalCost']; + } + // Save totals for this registrant $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['registrantRate'] = $registrantCharges; $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['registrantDiscounts'] = $registrantDiscounts; diff --git a/models/front/registrations/cart.php b/models/front/registrations/cart.php index 0027e31..c80041b 100644 --- a/models/front/registrations/cart.php +++ b/models/front/registrations/cart.php @@ -154,7 +154,7 @@ class GlmMembersFront_registrations_cart extends GlmRegCartSupport 'cartPageText' => $misc['cart_page_text'] ); - // echo "
".print_r($templateData,1)."
"; + // echo "
".print_r($this->cart,1)."
"; // Return status, any suggested view, and any data to controller return array( diff --git a/views/front/registrations/cartSummary.html b/views/front/registrations/cartSummary.html index d38874e..2aa4682 100644 --- a/views/front/registrations/cartSummary.html +++ b/views/front/registrations/cartSummary.html @@ -42,13 +42,16 @@
{$registrant.fname} {$registrant.lname}
-
+
+ Date & Time: +
+
{$registrant.timeReformatted}
-
- Cookies and Milk (temp test data) +
+ Registrant Charge:
-
+
{if $registrant.registrantRate > 0} ${$registrant.registrantRate|number_format:2} {else} @@ -56,6 +59,25 @@ {/if}
+ {if $registrant.event_attendee_custom_form} + {foreach $registrant.event_attendee_custom_form.form as $customField} + {if $customField.priority_display.value || $customField.cost > 0} +
+
+ {$customField.field_name}: +
+
+ {$customField.stored} +
+ {if $customField.cost > 0} +
+ ${$customField.cost|number_format:2} +
+ {/if} +
+ {/if} + {/foreach} + {/if} {if $registrant.registrantDiscounts > 0}
@@ -69,6 +91,7 @@ {/foreach} {* registrants *} {/foreach} {* rates *} {/foreach} {* classes *} + {if $event.eventDiscounts > 0}
Event Discounts @@ -77,9 +100,10 @@ ${$event.eventDiscounts|number_format:2}
+ {/if}
- Registrants: {$event.eventRegistrants} + Registrants this event: {$event.eventRegistrants}
${$event.eventCharges|number_format:2} @@ -92,7 +116,7 @@ Registration Request Totals
-{if $cart.totalDiscounts == 0} +{if $cart.totalDiscounts > 0}
Total Discounts -- 2.17.1