1"use strict"; 2angular 3 .module("sfmStore") 4 .controller("registrationController", function( 5 USER_TITLES, 6 VALIDATORS, 7 $scope, 8 $state, 9 $stateParams, 10 $order, 11 $registration, 12 $analytics, 13 $sfmProductExpired, 14 $sfmAlreadyRegistered, 15 prepProduct 16 ) { 17 var vm = this; 18 var order = $order.getOrder(); 19 vm.order = $order; 20 vm.analytics = $analytics; 21 vm.titles = USER_TITLES; 22 vm.emailPattern = VALIDATORS.email; 23 vm.phonePattern = VALIDATORS.phone; 24 vm.product = prepProduct.data.data; 25 vm.profile = order.profile; 26 vm.profile.title = vm.profile.title || "?"; 27 vm.profile.sms_consent = true; 28 vm.isAlreadyRegistered = false; 29 vm.isValidMultipleRegistration = false; 30 vm.multiRegisObj = { 31 activated: false, 32 extraAttendees: [] 33 } 34 vm.isAddToCartDisabled = false 35 vm.requiredNameError = false 36 37 // Disable multiple registration for certain products 38 // Currently expos for Spring 2026 39 var disableMultiRegProductIds = [1483, 1484, 1485, 1486, 1487, 1488]; 40 vm.allowMultipleRegistration = disableMultiRegProductIds.indexOf(parseInt(vm.product.id)) === -1; 41 42 if (!vm.product || parseInt(vm.product.registration_closed)) { 43 $sfmProductExpired.showModal(); 44 $state.go("storeHome"); 45 } 46 47 $scope.$watch("vm.isMultipleRegis", function(newVal) { 48 if (newVal) { 49 var activate = newVal > 0 ? true : false; 50 if (activate) { 51 vm.multiRegisObj = { 52 activated: true, 53 extraAttendees: [ 54 { 55 key: 0, 56 first_name: "", 57 last_name: "", 58 email: "" 59 } 60 ] 61 } 62 } else { 63 vm.multiRegisObj = { 64 activated: false, 65 extraAttendees: [] 66 } 67 } 68 } 69 }); 70 71 function deleteAttendeeByKey(k) { 72 vm.multiRegisObj.extraAttendees.splice(k, 1) 73 vm.multiRegisObj.extraAttendees.map(a => { 74 a.key = a.key>k ? a.key-1 : a.key; 75 return a; 76 }) 77 } 78 79 vm.checkForAlreadyRegisteredEmailInput = function(attendee) { 80 vm.addToCartDisabled = true 81 $registration.checkForAlreadyRegisteredByEmail(attendee.email, vm.product.id).then(function(res) { 82 // if not already registered, but the group id is out out of sync or not null, throw a specific warning 83 if(!vm.multiRegisObj.activated) {return true;} 84 if ( 85 res.data.data.group_id && 86 res.data.data.group_id !== vm.profile.school_id && 87 res.data.data.school_group !== vm.profile.school_id 88 ) { 89 $sfmAlreadyRegistered.showWrongGroupModal() 90 deleteAttendeeByKey(attendee.key) 91 vm.addToCartDisabled = false 92 return true; 93 } 94 if (res.data.data.already_registered === true) { 95 $sfmAlreadyRegistered.showSoftReminderModal() 96 deleteAttendeeByKey(attendee.key) 97 vm.addToCartDisabled = false 98 return true; 99 } 100 vm.addToCartDisabled = false 101 102 return false; 103 }) 104 } 105 106 $registration.checkForAlreadyRegistered(vm.order, vm.product.id).then(function(res) { 107 var payload = res.data.data; 108 if (payload !== null) { 109 vm.isAlreadyRegistered = true; 110 $sfmAlreadyRegistered.showReminderModal(); 111 } 112 }) 113 114 // send a view_item event whenever this controller is invoked 115 dataLayer.push({ ecommerce: null }); 116 dataLayer.push({ 117 'event': 'view_item', 118 'ecommerce': { 119 'items': [{ 120 'item_name': vm.product.title, 121 'item_id': String(vm.product.id), 122 'item_category': String(vm.product.category_id), 123 'currency': "USD", 124 'price': Number(vm.product.cost) 125 }] 126 } 127 }); 128 129 vm.addAttendee = function() { 130 if(vm.multiRegisObj.extraAttendees !== undefined 131 && vm.multiRegisObj.extraAttendees.length < 4){ 132 vm.multiRegisObj.extraAttendees.push({ 133 key: vm.multiRegisObj.extraAttendees.length, 134 first_name: "", 135 last_name: "", 136 email: "" 137 }) 138 } 139 } 140 141 vm.removeAttendee = function() { 142 vm.multiRegisObj.extraAttendees.length > 1 ? vm.multiRegisObj.extraAttendees.pop() : vm.multiRegisObj.extraAttendees; 143 } 144 145 function allNamesGiven() { 146 let extraAttendees = vm.multiRegisObj.extraAttendees; 147 if (extraAttendees.length > 0) { 148 for (let i = 0; i < extraAttendees.length; i++) { 149 if (extraAttendees[i].first_name === "" || extraAttendees[i].last_name === "") { 150 vm.requiredNameError = true 151 return false 152 } 153 } 154 vm.requiredNameError = false 155 } 156 return true; 157 } 158 159 vm.addToCart = function() { 160 if ( 161 vm.expoForm.$valid && 162 !vm.multiRegisObj.extraAttendees.find(a => a.email===undefined) && 163 allNamesGiven() 164 ) { 165 var item = vm.product; 166 item.attendees = vm.multiRegisObj.extraAttendees || [] 167 $order.addOrderItem(item); 168 vm.qty = 1; 169 170 $order.startCart({ 171 email: vm.profile.email, 172 item_id: vm.product.id, 173 item_name: vm.product.title 174 }); 175 176 dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object. 177 dataLayer.push({ 178 'event': 'add_to_cart', 179 'ecommerce': { 180 'items': [{ 181 'item_name': item.title, 182 'item_id': String(item.id), 183 'item_category': String(item.category_id), 184 'quantity': vm.qty 185 }] 186 } 187 }); 188 189 $state.go("cart", { 190 previousPage: vm.product.category_id, 191 itemAdded: item 192 }); 193 } else { 194 angular.forEach(vm.expoForm.$error.required, function(field) { 195 field.$setDirty(); 196 }); 197 } 198 }; 199 200 $analytics.pushVirtualPageview(window.location.href); 201 });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.