| Topic | Presenter | Summary | Duration |
| ------------------------------ | --------- | ----------------------------------------------------------------------------------------------------------------- | -------- |
| Creating a New Cart Validation | Josh S. | This is a short video on creating a new cart validation/app settings from a front-end paired programming session. | 10:36 |00:00:07.460 --> 00:00:09.068 I have some apps setting ones.00:00:11.250 --> 00:00:12.990 But they're just altering them,00:00:12.990 --> 00:00:15.080 not, they're not creating one, so.00:00:43.810 --> 00:00:44.958 I see people typing.00:00:52.760 --> 00:00:54.182 Questions come up, but if you00:00:54.182 --> 00:00:55.720 want you don't have to type it.00:00:55.720 --> 00:00:57.680 Unless I mean less is better typed but.00:01:14.400 --> 00:01:15.824 Uh, yeah, I mean,00:01:15.824 --> 00:01:18.560 as long as are they relatively normal,00:01:18.560 --> 00:01:20.450 Josh just come with me.00:01:20.450 --> 00:01:22.998 Or are they relatively normal app settings00:01:22.998 --> 00:01:25.739 like nothing like really bizarre about them?00:01:25.740 --> 00:01:28.636 I mean, I guess that depends on what00:01:28.636 --> 00:01:30.888 you mean by really bizarre.00:01:30.890 --> 00:01:32.750 No, it's it's not normal.00:01:32.750 --> 00:01:36.495 OK no, no OK yeah, I mean one of them00:01:36.495 --> 00:01:38.700 were dictionary mom would not be.00:01:38.700 --> 00:01:39.510 Yeah OK alright.00:01:39.510 --> 00:01:42.051 Uh, well can we go over the one that00:01:42.051 --> 00:01:44.403 would be that would be would be perfect00:01:44.472 --> 00:01:46.983 and we can just record that and you know,00:01:46.990 --> 00:01:48.950 say you know I had to create it,00:01:48.950 --> 00:01:50.426 you know show the ticket first.00:01:50.430 --> 00:01:52.782 Had to create this upsetting and then00:01:52.782 --> 00:01:54.944 just say this is where I started00:01:54.944 --> 00:01:57.100 and this is how I read it and.00:01:57.100 --> 00:02:00.190 Even if it's back in, that's not big deal.00:02:00.190 --> 00:02:01.534 Cool, let me, uh,00:02:01.534 --> 00:02:04.020 quit all my debugging stuff real quick.00:02:04.020 --> 00:02:06.180 I'll take a look.00:02:06.180 --> 00:02:09.900 Uh, make sure I get the there we go, OK?00:02:17.120 --> 00:02:19.058 Go in here.00:02:27.730 --> 00:02:31.088 Come on. There we go, uh,00:02:31.088 --> 00:02:34.136 So what exactly do you wanna?00:02:37.640 --> 00:02:38.928 So what's the ticket?00:02:38.928 --> 00:02:40.538 You had creepy upsetting for,00:02:40.540 --> 00:02:44.068 so these two that I have up right now.00:02:44.070 --> 00:02:45.906 OK, so build out shopping cart00:02:45.906 --> 00:02:48.290 to be used to purchase domestic00:02:48.290 --> 00:02:50.470 order products for retailers.00:02:50.470 --> 00:02:51.715 So basically what Josh had00:02:51.715 --> 00:02:53.915 to do is he had to create a00:02:53.915 --> 00:02:55.400 new type of CART validation.00:02:57.490 --> 00:03:00.113 Based on the user role, yeah.00:03:00.113 --> 00:03:04.937 OK, that is interesting and not super simple,00:03:04.940 --> 00:03:10.158 but. A regular VM used.00:03:10.160 --> 00:03:11.960 That the app setting would be00:03:11.960 --> 00:03:14.188 go go ahead and pull up Visual00:03:14.188 --> 00:03:16.428 Studio Josh and just show the UM.00:03:16.430 --> 00:03:18.824 'cause I mean all the app00:03:18.824 --> 00:03:21.140 settings start back here anyways.00:03:21.140 --> 00:03:25.809 So yeah. So let me see here.00:03:25.810 --> 00:03:28.038 Yeah. So these guys.00:03:30.850 --> 00:03:31.790 Insistent.00:03:34.160 --> 00:03:35.602 Yeah, and so when you wanted to00:03:35.602 --> 00:03:37.018 create an app setting, I mean,00:03:37.018 --> 00:03:38.341 the first thing you wanted to do00:03:38.341 --> 00:03:40.111 is make sure it did something like00:03:40.111 --> 00:03:41.565 that didn't already exist, right?00:03:41.565 --> 00:03:44.540 So how did you go about that?00:03:44.540 --> 00:03:46.703 So I looked in actually the CART00:03:46.703 --> 00:03:48.347 validator config and icart validator00:03:48.347 --> 00:03:50.636 config to see if there was anything00:03:50.636 --> 00:03:52.537 that was specific to user role.00:03:52.540 --> 00:03:54.934 I think when we were looking at it we00:03:54.934 --> 00:03:57.432 made sure that none of the existing00:03:57.432 --> 00:03:59.260 ones actually checked user role.00:03:59.260 --> 00:04:01.500 The closest they get is account type,00:04:01.500 --> 00:04:04.416 but that wasn't what we wanted.00:04:04.420 --> 00:04:06.556 Uhm, since no app setting existed,00:04:06.560 --> 00:04:09.512 it made sense to look at these and00:04:09.512 --> 00:04:12.351 add them in and just base them off00:04:12.351 --> 00:04:15.236 of one of the other CART validator00:04:15.236 --> 00:04:18.152 app settings to make sure the.00:04:18.160 --> 00:04:19.830 Structures correct? Yeah, that's perfect.00:04:19.830 --> 00:04:22.847 Can you go collapse that cart validator?00:04:22.850 --> 00:04:24.957 A region that just scroll up a00:04:24.957 --> 00:04:26.870 little bit and collapse that.00:04:26.870 --> 00:04:29.777 Yep, so just for any front end people who00:04:29.777 --> 00:04:32.564 have never gone back here and see this,00:04:32.570 --> 00:04:34.957 all the app settings exist in Seth00:04:34.957 --> 00:04:36.590 Config Properties 123 and four.00:04:36.590 --> 00:04:38.265 There's four files because there's00:04:38.265 --> 00:04:39.940 just a lot of lines.00:04:39.940 --> 00:04:40.610 I mean,00:04:40.610 --> 00:04:43.290 they could technically all be in one file,00:04:43.290 --> 00:04:45.628 so don't let that ever confuse you.00:04:45.630 --> 00:04:46.970 They're in alphabetical order00:04:46.970 --> 00:04:48.310 by region name here,00:04:48.310 --> 00:04:50.894 so in this case we were the task00:04:50.894 --> 00:04:53.780 he had was for CART validator so.00:04:53.780 --> 00:04:56.180 You know you come in here and these00:04:56.180 --> 00:04:57.858 are usually collapsed by default00:04:57.858 --> 00:05:00.224 and then you could see there's a00:05:00.290 --> 00:05:02.460 region already for CART validator.00:05:02.460 --> 00:05:03.572 And so you know.00:05:03.572 --> 00:05:05.240 But if you didn't see that,00:05:05.240 --> 00:05:07.186 you could easily just search in here.00:05:07.190 --> 00:05:07.467 Obviously,00:05:07.467 --> 00:05:09.683 for you know the word validate or validator.00:05:11.780 --> 00:05:14.774 Or yeah, and so these regions00:05:14.774 --> 00:05:17.630 are where you you create.00:05:17.630 --> 00:05:21.739 Uh, where you create your app settings?00:05:21.740 --> 00:05:24.064 Sorry Josh Key continue Oh no word00:05:24.064 --> 00:05:26.224 David totally good I would say and00:05:26.224 --> 00:05:28.238 then just show us like where did00:05:28.238 --> 00:05:30.296 you use that upsetting like did you00:05:30.296 --> 00:05:32.594 have to put it in app settings dot00:05:32.594 --> 00:05:34.250 config to overwrite the default?00:05:34.250 --> 00:05:37.358 And then what's actually reading it?00:05:37.360 --> 00:05:41.673 So I'm just bringing this up as well, uh?00:05:41.673 --> 00:05:45.617 In the Appsettings config for the project I00:05:45.617 --> 00:05:49.740 added in the two values that they both need.00:05:49.740 --> 00:05:55.545 Uh, it is the in this one in particular.00:05:55.550 --> 00:05:57.605 CART validator config.00:05:57.605 --> 00:06:00.345 That reads those values,00:06:00.350 --> 00:06:04.375 so I had to add in this.00:06:04.380 --> 00:06:07.998 Dictionary for them and it checks.00:06:08.000 --> 00:06:10.646 If the app setting is enabled and00:06:10.646 --> 00:06:13.735 then that the a dictionary that we're00:06:13.735 --> 00:06:16.537 pulling out of that second string.00:06:16.540 --> 00:06:19.126 Isn't Null and then it gets00:06:19.126 --> 00:06:21.440 that and adds it into.00:06:21.440 --> 00:06:24.476 This dictionary, which I'm then using00:06:24.476 --> 00:06:27.789 in the CART validator I was writing.00:06:27.790 --> 00:06:29.660 Yeah, so you wanna go show it in the cart00:06:29.709 --> 00:06:31.718 validator 'cause that will probably be more,00:06:31.720 --> 00:06:37.335 UM. Sure. Yeah, so that actually gets00:06:37.335 --> 00:06:42.230 brought up right down in here, uh?00:06:42.230 --> 00:06:43.152 Once we.00:06:43.152 --> 00:06:45.918 Start getting info from the database.00:06:45.920 --> 00:06:47.912 We're supposed to have user roles00:06:47.912 --> 00:06:50.110 that are assigned to that user ID,00:06:50.110 --> 00:06:52.422 and then in this for each for each00:06:52.422 --> 00:06:54.311 one of the roles were checking00:06:54.311 --> 00:06:56.948 to see if we can get the value00:06:56.948 --> 00:06:59.060 out of that dictionary based on00:06:59.060 --> 00:07:00.586 the role that's assigned.00:07:00.586 --> 00:07:01.402 And then.00:07:01.402 --> 00:07:03.442 That's comparing the subtotal for00:07:03.442 --> 00:07:05.731 the cart to the minimum purchase00:07:05.731 --> 00:07:07.546 amount that's defined in the00:07:07.615 --> 00:07:09.207 dictionary for that role.00:07:12.800 --> 00:07:14.809 And then it does it again here,00:07:14.810 --> 00:07:16.240 because debugging ignore that but.00:07:19.630 --> 00:07:20.851 Don't forget, yeah.00:07:20.851 --> 00:07:23.700 So in the way that we determined,00:07:23.700 --> 00:07:25.576 you know the way that you determined00:07:25.576 --> 00:07:27.618 to create an amp setting is or the00:07:27.618 --> 00:07:29.350 way I think about app settings.00:07:29.350 --> 00:07:30.695 Or if you want something00:07:30.695 --> 00:07:32.040 kind of brought into core,00:07:32.040 --> 00:07:33.930 you're going to make an app setting.00:07:33.930 --> 00:07:35.858 Or if you do a PR and you00:07:35.858 --> 00:07:37.418 don't have an app setting,00:07:37.420 --> 00:07:41.587 you might be told to create an app setting.00:07:41.590 --> 00:07:44.929 But in this case camp once a00:07:44.929 --> 00:07:48.068 like based on the user role.00:07:48.070 --> 00:07:50.110 They have to have a specific00:07:50.110 --> 00:07:52.030 like a minimum order amount,00:07:52.030 --> 00:07:53.830 UM, and part of that.00:07:53.830 --> 00:07:55.762 Some of that was already being00:07:55.762 --> 00:07:59.670 done in this CART validator, so.00:07:59.670 --> 00:08:01.959 Had the idea that you know another00:08:01.959 --> 00:08:04.099 client in the future may want.00:08:04.100 --> 00:08:05.941 To use this and we had to00:08:05.941 --> 00:08:07.710 build it for camp anyways,00:08:07.710 --> 00:08:09.950 so that's kind of where the idea00:08:09.950 --> 00:08:11.730 of the appsettings came in and00:08:11.730 --> 00:08:13.967 Josh is Josh had the idea to use00:08:13.967 --> 00:08:16.037 the dictionary which was just00:08:16.037 --> 00:08:17.693 genius the dictionary basically.00:08:17.700 --> 00:08:20.636 Is a way for a client to assign.00:08:20.640 --> 00:08:20.947 Uhm,00:08:20.947 --> 00:08:23.403 you know they could have 100 user roles00:08:23.403 --> 00:08:26.029 with 100 different minimum order amounts,00:08:26.030 --> 00:08:28.445 and so that's a way for them00:08:28.445 --> 00:08:29.970 to dynamically assign those.00:08:29.970 --> 00:08:33.300 Yeah, and that's just a.00:08:33.300 --> 00:08:35.748 Like the way that I've set it up,00:08:35.750 --> 00:08:37.822 you could set up a parser pretty00:08:37.822 --> 00:08:40.027 much any way you like for these,00:08:40.030 --> 00:08:42.586 but as long as you have the key value00:08:42.586 --> 00:08:44.930 pairs set up in some consistent way,00:08:44.930 --> 00:08:47.066 you could add however many roles00:08:47.066 --> 00:08:49.808 you want in this string and it'll.00:08:49.810 --> 00:08:52.442 Look for the users ID or the00:08:52.442 --> 00:08:54.829 users role ID in that list.00:08:54.830 --> 00:08:56.760 Once it breaks everything out.00:08:56.760 --> 00:09:00.405 So is that saying like if they have a00:09:00.405 --> 00:09:03.324 user ID of 10, it's 2011 is 20,000?00:09:03.324 --> 00:09:07.595 Yep, a user role, user roles are yeah.00:09:07.600 --> 00:09:07.840 Yeah,00:09:07.840 --> 00:09:09.280 so like that's like 10 might00:09:09.280 --> 00:09:11.155 be like sales Rep and 11 might00:09:11.155 --> 00:09:12.255 be like trade professional.00:09:15.380 --> 00:09:16.696 OK, cool, that's yeah,00:09:16.696 --> 00:09:19.102 that's a that's a pretty good use00:09:19.102 --> 00:09:20.897 case because normally what 90%00:09:20.900 --> 00:09:23.105 of the time you didn't see from00:09:23.105 --> 00:09:25.390 the ones that are commented out.00:09:25.390 --> 00:09:27.465 Whatever you're passing in for00:09:27.465 --> 00:09:30.010 value is either just a string00:09:30.010 --> 00:09:32.356 or it's just a Boolean like.00:09:32.360 --> 00:09:34.680 Most of the time, so it's cool that00:09:34.680 --> 00:09:36.660 you're showing one where you actually.00:09:36.660 --> 00:09:38.490 Passing a string it's I mean,00:09:38.490 --> 00:09:40.625 I guess it's still technically a string,00:09:40.630 --> 00:09:41.846 but it's actually turning00:09:41.846 --> 00:09:43.700 into like a Jason object, yes?00:09:43.700 --> 00:09:46.010 So I was debating trying to find00:09:46.010 --> 00:09:47.948 a different way to pass it in,00:09:47.950 --> 00:09:49.702 and then I noticed related to00:09:49.702 --> 00:09:51.609 what I was already working on,00:09:51.610 --> 00:09:53.100 that this was already written00:09:53.100 --> 00:09:54.955 to pull a Dictionary of string00:09:54.955 --> 00:09:56.785 string out of the app settings.00:09:56.790 --> 00:09:58.662 So I just modified it to00:09:58.662 --> 00:10:00.450 do what I needed to do.00:10:05.180 --> 00:10:07.976 So it's tough. Well,00:10:07.976 --> 00:10:09.406 does anybody have any questions?00:10:09.410 --> 00:10:11.750 I think that was.00:10:11.750 --> 00:10:14.305 It's a very back end example, but,00:10:14.305 --> 00:10:16.495 uh, yeah, it's pretty good one.00:10:21.660 --> 00:10:23.950 OK cool well thanks Josh.