@@ -18,7 +18,7 @@ $(function () {
18
18
// Note these are currently all Stripe TEST product Ids and need to be updated to
19
19
// the live strip product IDs
20
20
21
- const productToButtonNameMap = {
21
+ const productToCheckboxNameMap = {
22
22
[ products . AWS . stripeProductId ] : products . AWS . key ,
23
23
[ products . ProSupport . stripeProductId ] : products . ProSupport . key ,
24
24
[ products . RefArch . stripeProductId ] : products . RefArch . key ,
@@ -78,10 +78,10 @@ $(function () {
78
78
if ( rawCart ) {
79
79
const products = JSON . parse ( rawCart ) ;
80
80
for ( const product of products ) {
81
- const buttonName = productToButtonNameMap [ product . productId ] ;
81
+ const checkboxName = productToCheckboxNameMap [ product . productId ] ;
82
82
83
- if ( buttonName ) {
84
- $ ( '.addon-button [name="' + buttonName + '"]' ) . click ( ) ;
83
+ if ( checkboxName ) {
84
+ $ ( '.addon-checkbox [name="' + checkboxName + '"]' ) . prop ( 'checked' , true ) . trigger ( "change" ) ;
85
85
}
86
86
}
87
87
}
@@ -91,43 +91,20 @@ $(function () {
91
91
}
92
92
93
93
// Listen to Addon button clicks
94
- $ ( ".addon-button " ) . on ( "click " , function ( ) {
94
+ $ ( ".addon-checkbox " ) . on ( "change " , function ( ) {
95
95
var updateCheckoutOptions = { } ;
96
96
97
- var actionType = $ ( this ) . data ( "addon-action-type" ) ;
98
97
var productId = $ ( this ) . data ( "product-id" ) ;
98
+ var productKey = this . name ;
99
99
100
- // Process the add action and switch the addon button so user can clear their selection
101
- function _handleAddAction ( button ) {
102
- updateCheckoutOptions [ button . name ] = true ;
103
- $ ( button ) . text ( "Remove" ) ;
104
- $ ( button ) . addClass ( "addon-remove-button" ) ;
105
- $ ( button ) . data ( "addon-action-type" , "Remove" ) ;
100
+ if ( this . checked ) {
101
+ updateCheckoutOptions [ productKey ] = true ;
106
102
_addToCart ( productId ) ;
107
- }
108
-
109
- // Process the remove action and switch the addon button so user can make a selection
110
- function _handleRemoveAction ( button ) {
111
- updateCheckoutOptions [ button . name ] = false ;
112
- $ ( button )
113
- . text ( "Add to Subscription " )
114
- . append (
115
- "<i class='fa fa-angle-double-right fa-lg' aria-hidden='true'></i>"
116
- ) ;
117
- $ ( button ) . removeClass ( "addon-remove-button" ) ;
118
- $ ( button ) . data ( "addon-action-type" , "Add" ) ;
103
+ } else {
104
+ updateCheckoutOptions [ productKey ] = false ;
119
105
_removeFromCart ( productId ) ;
120
106
}
121
107
122
- switch ( actionType ) {
123
- case "Add" :
124
- _handleAddAction ( this ) ;
125
- break ;
126
- case "Remove" :
127
- _handleRemoveAction ( this ) ;
128
- break ;
129
- default : // Do nothing
130
- }
131
108
_updateCheckout ( updateCheckoutOptions ) ;
132
109
} ) ;
133
110
@@ -158,70 +135,11 @@ $(function () {
158
135
function _updateCheckout ( newOptions ) {
159
136
checkoutOptions = Object . assign ( { } , checkoutOptions , newOptions ) ;
160
137
161
- _updateUI ( ) ;
162
138
_updatePrice ( ) ;
163
139
}
164
140
165
- function _updateUI ( ) {
166
- var support = checkoutOptions . pro_support ;
167
- var refarch = checkoutOptions . setup_deployment ;
168
- var compliance = checkoutOptions . setup_compliance ;
169
-
170
- $ ( ".grunty-sprite" ) . attr ( "data-sprite" , 0 ) ;
171
- $ ( "#subscription_type" ) . val ( checkoutOptions . subscription_type ) ;
172
-
173
- // updates addon switch
174
- $ ( "[data-switch]" + '[name="pro_support"]' ) . prop ( "checked" , support ) ;
175
- $ ( "[data-switch]" + '[name="setup_deployment"]' ) . prop ( "checked" , refarch ) ;
176
- $ ( "[data-switch]" + '[name="setup_compliance"]' ) . prop (
177
- "checked" ,
178
- compliance
179
- ) ;
180
-
181
- if ( support ) {
182
- $ ( ".grunty-sprite" ) . attr ( "data-sprite" , 2 ) ;
183
- $ ( "#subscription-addon-1" ) . removeClass ( "check-list-disabled" ) ;
184
- } else {
185
- $ ( "#subscription-addon-1" ) . addClass ( "check-list-disabled" ) ;
186
- }
187
-
188
- if ( refarch ) {
189
- $ ( ".grunty-sprite" ) . attr ( "data-sprite" , 1 ) ;
190
-
191
- $ ( "#checkout-price-addon" ) . show ( ) ;
192
- $ ( "#checkout-price-addon--mobile" ) . show ( ) . css ( "display" , "block" ) ;
193
- $ ( ".checkout-price-view" ) . addClass ( "move-up" ) ;
194
-
195
- $ ( "#subscription-addon-2" ) . removeClass ( "check-list-disabled" ) ;
196
- } else {
197
- $ ( "#checkout-price-addon" ) . hide ( ) ;
198
- $ ( "#checkout-price-addon--mobile" ) . hide ( ) ;
199
- $ ( ".checkout-price-view" ) . removeClass ( "move-up" ) ;
200
-
201
- $ ( "#subscription-addon-2" ) . addClass ( "check-list-disabled" ) ;
202
- }
203
-
204
- if ( compliance ) {
205
- $ ( "#subscription-addon-3" ) . removeClass ( "check-list-disabled" ) ;
206
-
207
- // Update Refarch texts to reflect CIS selection
208
- $ ( "#subscription-addon-3-text" ) . text ( "CIS Reference Architecture" ) ;
209
- $ ( "#addon-text-refarch" ) . text ( "CIS Reference Architecture" ) ;
210
- } else {
211
- $ ( "#subscription-addon-3" ) . addClass ( "check-list-disabled" ) ;
212
-
213
- // Update Refarch texts to reflect CIS selection removal
214
- $ ( "#subscription-addon-3-text" ) . text ( "Reference Architecture" ) ;
215
- $ ( "#addon-text-refarch" ) . text ( "Reference Architecture" ) ;
216
- }
217
-
218
- if ( support && refarch ) {
219
- $ ( ".grunty-sprite" ) . attr ( "data-sprite" , 3 ) ;
220
- }
221
- }
222
-
223
141
function _updatePrice ( ) {
224
- var monthlyTotal , dueNowTotal ;
142
+ var monthlyTotal ;
225
143
226
144
switch ( checkoutOptions . subscription_type ) {
227
145
case "standard" :
@@ -244,18 +162,13 @@ $(function () {
244
162
monthlyTotal += pricing . subscriptions . standard . cis_compliance_price . value ;
245
163
}
246
164
247
- dueNowTotal = monthlyTotal ;
248
-
249
165
if ( checkoutOptions . setup_deployment ) {
250
- dueNowTotal += 4950 ;
251
- $ ( "#due-monthly-block" ) . show ( ) ;
166
+ $ ( '#js-one-time-total' ) . show ( ) ;
252
167
} else {
253
- // only show the monthly disclaimer when it differs from due now
254
- $ ( "#due-monthly-block" ) . hide ( ) ;
168
+ $ ( "#js-one-time-total" ) . hide ( ) ;
255
169
}
256
170
257
- $ ( "#due-now" ) . text ( dueNowTotal . toLocaleString ( ) ) ;
258
- $ ( ".monthly-total" ) . text ( monthlyTotal . toLocaleString ( ) ) ;
171
+ $ ( "#js-monthly-total" ) . text ( monthlyTotal . toLocaleString ( ) ) ;
259
172
}
260
173
261
174
_setDefaults ( ) ;
0 commit comments