 Yeah, so I live in Sarasota. I've got a family. I do music. I like it on beach I've worked on quite a few enterprise-level we'll conversize around five years experience and I still have a master fit Play the glory no, that's me my daughter with ice skating a few weeks ago. We're matching out We did try to fall for best That's where you can find me I don't tweet much, but I'm on there and I do listen to it So if you ever have any questions or want to chat Lou, you can hit me up I woke up at 3 30 this morning and drove up here from Sarasota. So if I seem a little sluggish, that's probably more It's also a lot colder here. It wasn't Sarasota. I wouldn't expect in that Yeah, I show up. I'm freezing as I'm getting gas Right off the interstate. This is my second time giving this talk the first time in may might be a few weeks ago and Learned a lot from that. They were my guinea pigs. I've changed up a bit out of some new slides So hopefully it's pretty smooth and you get something out of it. This is a back-end development focus talk It's pretty advanced level, but there are some kind of high-level concepts we go over so you might get something out of it Even if you aren't a really advanced developer And feel free to interrupt me. I'm always happy to talk discuss the deeper and things you'll find interesting so It's hard pretty much impossible to to go over advanced development from a commerce without just talking about PHP development WordPress development in general So a lot of this can be kind of extrapolated and put into any other things you do behind the scenes of WordPress And the other kind of sections we're going to go through Um, I had a live coding watch me try to figure out a problem thing when I was in Miami That was just weird. It just didn't work So I took that section out and added some more just kind of digging into different things you can do Um, so let's start off with how do we woo? First and most important thing with WooCommerce that I've learned is you're dealing with real money people's money sometimes millions of dollars and All of these numbers that you're calculating and adjusting are going to get sent to the irs They're going to be sent to their accountants They're going to be matched up with different databases and Excel spreadsheets So you have to be very careful and very accurate Like we will calculate it down to like the fifth decimal place decimal place if you want them to So I highly recommend, you know, lots of integration tests Double checking all your numbers a lot of qa work We'll commerce it in something you just kind of hack together Especially when you're going to be touching Money amounts and report sheets and exports and things like that Um, it's good if you're doing a bigger project to have clear end goal and end product You know, what's the user story wire frame it up Do all the preparation correctly before you dive in to start actually tweaking WooCommerce's abilities Uh, so let's talk about a user story. I'm gonna kind of build an example in here that's based on A project I'm building with tribe So going through this and kind of give us an idea of what the project's going to do what we've wanted to do How we approach it we're going to go through all those steps So let's think about this our users are resellers the people shopping on the site Are going to be people who buy products probably in bulk and resell them for a higher profit amount So we need to think about how to approach them how to give them the features they need on this shopping cart system Um, depending on the type of person shopping the type of reseller They're going to see different products see different prices different situations are going to come up depending on What is set for that specific user that's shopping? Um, we want to add a feature where the users can save their shopping carts So they can put a hundred bulk items into a shopping cart so to decide Do that a few different times come back and purchase them as they need That kind of advanced functionality Is not default move Um, the user should know the price at which they can resell So we want to be able to show them what their profit margins are going to look like as they're shopping around Um, so we're so far if you require licenses A lot of people would approach that sort of thing with edd We built a custom solution because our client needed a very customized solution So let's just kind of throw that in the mix here when we're thinking about what we're doing Uh, the first step is to get a strategist or be the strategist if you're doing a project to help kind of line out What is going to happen here if and how so with WooCommerce You can kind of separate it into these different buckets of the user the shop the cart check out How how the managers and the admins are going to be handling the back end orders and handling users and so forth Um, so kind of set up a table. You can do it however you want. This is kind of the thing that I see from my strategist Um, so the user what are we going to do with the user? We're going to have the my account section is going to have some special stuff It's going to have custom fields since we are going to have these resellers and different types of users Um, we're going to have a custom licenses archive So if they buy these products that come with licenses They'll be able to go to their archive in a loop and see what those are what they have and the status of them The user types, you know, do we use a metafield? Are we going to use user roles? How are we going to manage this whole part of it? But you know something has to happen there Um The shop loops they're going to be different. We're going to be adjusting the loop queries based on what kind of users shopping there Um, products are going to have custom fields Um custom order statuses, you know Woo comes with like four or five pending processing and on hold complete it comes with these statuses So we're going to want to add some custom ones for ourself pending a license pending verification We're going to be custom email templates to go with those statuses Cards we got calculated columns save the card feature. We want gateways. We're going to need like an account receivable kind of gateway um Managing it from the admin side exports book sales, you know if they want to Set everything on sale at 10% at the same time We need to build some sort of feature where they can manage those types of things Um and then managing, you know, if users have safe carts admin is going to want to be able to see those adjust them remove them So forth And this is just a quick shot. Um, you can get a lot more Intense these kind of layouts before you start coding Plugins are the plugins we can use to kind of save time and recreate in the wheel here and I highly recommend using them I mean if you need a ups shipping functionality Don't build it. We have one that's official that works really well So anything that's officially licensed or sold through woo can be trusted for the most part um, you can use Third-party plugins if you need to but hopefully of course, you'll probably, you know, look for some really high rated and Kept updated versions of plugins Um, so then kind of go through a list Of checking what pieces of woof commerce we're going to be touching in our extensions in our development For this we'll be touching product made up or to made up or to item meta customer meta templates prices and taxes Taxes are Intense um gateways custom order staffs is import tax reports and so on So we touch on one or two things, you know, we can build a really simple plugin to maybe just a single file But for something like this, you're going to want to build somewhat of a framework in your plugin Um, so this is how woo is structured Simplified, um, we have our post types the main post types that woof commerce registers. It's a product product variation The shop order and coupon now they have some other post types they use but these are the these are the big dogs The main ones that you're going to be messing with Transactional data Oh, no, no, we talked about the shop order the shop order is a post type and it is simply It's Since there's an admin interface for managing it like you do any other post type They they store the main shop order ID as a post type Um, but they have order items and order item meta for their custom tables the main ones that they use So when somebody orders a product It basically takes a copy of that product and creates an order item So if you go and change the product later, it's not going to affect What the person bought it's going to stay the same on that in that custom table And those order items are related to shop shops in that custom table or shop. I poor Jesus order IDs in that custom table and then Those order IDs are the post type itself. So It doesn't actually use post meta For an order to kind of store What people bought the transactional data. So it's got this custom table table It's also got a table for tax rates payment tokens Payment methods that people want to save like strike. Let's you save a card to keep it in that table Those are smaller tables smaller uses. They aren't really mixed into the big picture as much The order item and the order item data are the main custom tables that get a lot of action are very important We'll use is classes for a lot of stuff It's very object based the order object is that there's a big one in the product object is a big one It's they call it an abstract class in their documentation, but it's not really you can create just instances of product with a product ID and get a lot of the methods that come along with that They do have the product variation variable and simple which are extensions of the WC product that have specialized methods Just for those particular items Y'all know a variation product versus a simple product Kind of well simple product is it's a product. It's got a price It can have different features to it and so forth Uh a variable product allows you to have variations in each one of those variations is its own kind of product So it can get very hairy when you're dealing with complex systems You have to make sure you account for the different variations versus a simple product Is bundle just not listed or Bundle is do they consider bundle like a single product a simple product? They don't have a bundle so there's no bundle you have to have an add-on In fact, we're going to build a bundle in one of my demos Because it's a very needed feature fairly often The api is good. It's got a lot of helper functions that you can use The wc function gets you the loop commerce object and Yeah, so it gives you access basically whatever you need You can get to the cart the current session of the current cart through the wc object Yeah, so we'll see some of this actual code The meta so we would provides Helper functions for creating form fields. You can create your own meta fields If you want however you want you can use acf you can just you know Hook into add meta box and make your own things But it's highly suggested you stick with the move standard and use their input fields for meta Since they add attributes and classes and mix it in with their js and everything It just keeps everything standardized and in the shop And a lot of times it seems like there's really no reason for all that But then a month down the road you realize your fields are tying into a certain Area of the of the root commerce environment that they should be it just helps avoid a lot of disasters Um conditional meta value returns are pretty cool. We're gonna actually get more into that in a minute So I'm going to go to detail there Um order items I just explained that to you all that order items are different than a product They're a snapshot snapshot of the product at checkout Okay, these are fields i'm talking about so they provide these functions You can just build these it'll echo out the field all the correct move commerce mark up on it and make everything unified Although you do it doesn't like save it for you. You have to hook in and update the post meta and so forth But as you can see here, this is one It shows you that the class is that it attaches to it it provides the date picker that is kind of the Wu standard back there keeps everything together especially This is what i'm talking about kind of conditional meta We do this for a lot of things it tried but if you build a wrapper class around the Wu commerce product And use your own get meta method if you want to adjust that meta as it's coming out This gives you that that power so you can do like Like you've got this method you build If it's not the keys that you're allowing people to get on your code get and you know, you can just return Then you can switch here. You can have your default. It just gets the meta from Wu commerce or if it's a certain thing Like reseller price. Let's check it. What kind of user this is and see if we need to adjust what the price We're getting here is and return that instead So it could be a lot more power than just get those meta um gateways So gateways are literally they convert the cart to an ordered post type What happens between that is up to the gateway So if you're building your own custom gateways, it gives you a lot of power. You can use a different card processor. You can do things that like uh I'll kind of show you in a second But there's a there's a lot of really cool things you can do with gateways You don't have to take payments You can just make a cart go to an order and then your company does something special with that process um We're gonna go more into this later as well But there's two different ways that Wu checks you out One of them is the standard way with ajax you go through The normal checkout process and then boom you've got your order And the other is um, they have a short code order form built into a Wu commerce where You can slap an order form onto any page to put that you want or If you want people to be able to like save these cards like we're talking about and turn them into orders You can build your whole functionality there and use the short code order form But it works differently. So you gotta realize when you're writing your checkout code If there's things you do up during the checkout process You gotta make sure you're ready to handle both directions people can get to that area and create their order Custom statuses. These are they seem like a small thing, but they're actually really powerful and and Really easy to integrate with So Wu comes with the the basic ones processing completed pending and on hold and then they provide this filter WC order statuses where you can filter into it and add any custom statuses you want It does have to start with wc dash in order for the commerce to recognize it Used for custom order types. So when I was talking about how we need people to be able to save cards and stuff like that We Could call it estimates, right so people can save an estimate And what they could do is we can create an order with our own custom payment gateway and send it to a custom status So we was not going to recognize it as completed or processing and we can recognize it to do whatever you want with And otherwise you just have this kind of saved record of an order That hasn't gone through yet and call it whatever you want and call it estimates in this Um custom status all statuses have the option to Wu commerce to send out an email You can turn it on or off whatever it goes to this status and out an email Telling the user whatever so if you have your own custom status You need to build those email templates as well and register them as an email with uh with Wu so they know that you can Turn it on or off as an admin Let's actually look at one I don't I think this links So here's a example of custom payment gateway called estimates that kind of does what I was talking about Um, so to make a gateway you extend the wc payment gateway class You set an id and then this constants our own that we're going to be using it's not required by Wu On the construct you need to do certain things that are required by Wu commerce such as setting an id Um, these things allow these guys right here allow the admin to see You know a name and an explanation of what the gateway is within the admin settings And then you need a filter into available payment gateways to register your gateway with Wu commerce And what we're doing here is pretty cool. So when we're registering our payment gateway We go into a function called check access So maybe we don't want estimates to be available to every single shopper that's hitting up your site So first we say is this an admin? Okay, then we'll return it and say then leave the cool custom gateway in there Because you're on the admin side. You want to be able to Settle all your settings. Um, is the user not logged in? Okay. They can't do estimates. So we're gonna Unset our self estimates gateway and then return the gateways to Wu Uh, is the user what we have? Let's just say we have this user object that we created that Does a lot of checks and methods and stuff for us allows us to give some user powers We have a function in there called can access quotes if they can't then we un-set the gateway or move it But this is a conditional gateway. It's a gateway that only certain user types sort of have available and Yeah, so pretty neat Um, all gateways have a process payment function This is what we will pay when a person is checking out with your gateway They look for this function and this is where you would reach out to the api and process the payment They return false for true and turn it into an order so forth for this one Um, we aren't going to look for payment. We are simply going to reduce our stocks because At least on the product I was working on and for this demo We want those items that they put into an estimate to be on hold for them You know, we don't want to run out of stock and these sites turn their estimate into an order Is there some type of automation in there that they cancel the order if it fails that the stock holds or returns? No, you'd have to build that like we don't have that in this demo There's not but in the actual full giant when we built there is Um, so reduce stock levels And then we update the order status to our custom status. So we have here wc status for this class um wc estimate So that is going to Generate an order Give it that status So when we are in the admin and looking at this order, we'll say this right here, but waiting estimate confirmation Um, we empty the user's card and then we return success and send them to some custom. Thank you page that We have just for this gateway Um, here's see we hook in to add our status And this is also where we filter Something oh, this is where we put our gateway into the the mix with new colors So that's a pretty cool little sample there Uh templates so like I said, I I do back in for um drive. I don't really touch the front end much, but um Our front end guys that we work with they Do this this is just how you need to approach when you're building a custom shop or custom features for WooCommerce Use their templating system They have it within the the folder you go the the plug-in folder WooCommerce templates and you can see their structure for everything for The my account loops for the shop for the checkout forms all that stuff is in there So if you're in all you have to do is create the same thing in your theme or something Put that file in and make it how you want it to be and then you know WooCommerce will use yours instead of their default one Um Do you want to keep all the actions and filters that woo has in place if you can? If you are 100 sure you don't need those in there, they don't but those actions that they do like uh Pre check out form action and post check out form action. Those do more than just display things They handle a lot of the the section functionality and making sure that you're displaying the right stuff for the user That's checking out at that time Keep any logic you have in the custom plug-in that's that's what we preach We try to keep our logic interviews separated and it really does help in the long run to do that And talking about simple plug-in um If you're only touching one or two things there's really no problem with that so I Just say do it but if you go big go big I'll kind of show you what a simple plug-in looks like I mean that's it. It's one file in the plug-in folder Um, it's got a name and all this does is puts a little message After the add to cart button on every product if you're doing something really simple like that Just do it this way make a file if you actually some filters in it Be call it a day, but That's not what this talks about This is about the big ones Building a framework so this is This is what I do most of the time when when we're extending we commerce at my day job, you know, and and uh It's it's pretty cool. So I do it the tribe way. That's why I'm gonna kind of show y'all here As long as you know, there's there's a million ways to do it the right way So this is just kind of how I approach it But definitely the organization separation of logic and views all that stuff can really be important And helpful and long-term development. I highly recommend it. We use containers and uh, Dependency and Jackson's a tribe. I'm not going to use that this mock-up But I definitely recommend looking into it. Um, if you're building a big We commerce extension Uh, I highly suggest using the right tools. We use PHP storm. Um, I definitely it's definitely the best IDD in my opinion For for this kind of development, but there's many other ones that are arguably just as good Um, thanks debug and break points. That's something that took me from One level of developer to another Yeah, it's huge it's massive you're like before that you're fair dumping all your variables So, uh, it's a it's a game Um Recursively searching directories is one of the coolest things I love about these these beautiful IDs is uh Say you want to use a woo filter and you want to make sure there's no other plug-in Or something else using that same one or you want to know what's happening You can you can recursively search keywords through your entire directories and since php storm index, it's really fast And you can see every use of that filter And um, yeah, that's really why you didn't mention there is the control clicking of functions actions future actions Actions if there's actions that you enable the wordpress functionality in there, which you have to define your wordpress board it puts the Like you can hit your break points on the left part with the red dot There's going to be a blue dot linking just like the classes where they extend another class It takes you directly to the I mean I do use the functional which is really neat like So I guess if you go up to your settings, I'm sure you work that out with your chris I thought you were wordpress development He's from the jume look Who's this pose right here? um I can't find a good one. But anyway, typically you can click that function go to declaration I'll take you to right where that is. So if you just move function, yeah, just control clicking the right clicking So if you there's a win function you're using you want to see exactly what it's doing to your data You can do that pop even reverse if you're trying to determine whether a function can be removed after it's been Debra here or something like that Control click it and it'll show you everywhere that it's basically implementations Right, it's the opposite if you control click a function that's in use like the is type right there It'll take you to the is type declaration But if you're at the declaration and you should get this one right here, right? Yeah, find usages find usages. Yes find usages is where it is Yeah, upset. That's it. I'm learning more than the older up here Find usages. It's fantastic. It's the same thing happens if you control click the function and it'll automatically pull up every Never control click it. I'm sorry, man. Yeah, my bad Obviously there's one If there were tiny would give you the drop down. It's the fine drop down very cool And then, um, yeah A local desktop is another big game changer if you haven't done it, um Like I for years I just fdp my files to a server somewhere and tested it up there and changed the pack before It's it's it's growing as a developer. So I suspect maybe And that was you call that's what Josh called it. Um, he here for me. He's not coming to my talk Uh namespace and auto load definitely if you can I know that if you're a product selling product and you have to be compatible You can't do all this yet. You can't I'm php 5.2 and not namespacing not namespace. We do auto load Yeah, but you have to build your own auto load, right? I mean, we can't we just we do the same boots. No since wordpress 3.6 3.8 they can so they have their own spo auto loader backwards about it And basically I just remember I copied their file over in a case They're loading an older version of wordpress just in case and we In case they don't have spo auto loader. We just go back to that ability file and then call it very cool Well, I definitely highly recommend it. It helps a lot with the development process keeps things Keeps you from having to do a lot more drunk work. Uh, so look it up if you haven't and Definitely start using it. It also allows that what I think namespacing does Like the most useful bit of it is that you can use Simple names for your classes. You can name a class check out even though there's probably multiple other plugins that want to use that that thing or cart Very simple names for your classes because they're appropriately namespace which is like keeping it in a directory Uh version control is definitely another big important one. Um, again, I'm more I'm sitting here more on the Proper development speech than actually move commerce But uh using git gives you your historical data. It allows you to work with others. Well, it keeps um, it's just really really nice So definitely I recommend that We like to commit the whole wordpress Install with our work that we're working on that way Everybody's working on the exact same version of wordpress. Um We know that everyone's set up identical and when we want to update wordpress qa can test it here And we can be working out there and it's all centralizing in the same version and Correct. We also put wordpress into a sub directory. Um, so our project is at the base and then we tell where to load the wordpress from Um, I already mentioned this but yeah, keep your keep the theme in the themes. Um, your front end stuff your html Your assets all that should stay in your theme. Keep your php logic In a centralized place like a plugin. Um, don't be doing a lot More than just a couple of like if checks or whatever in your Template files. It's just bad practice. Keep all that centralized in your php logic. Um, turn the plug in Uh documenting is really a lot more important than it seems even if you're working by yourself. Um There's been times I've come back to code our road a month ago And I'm thanking myself from a month ago for writing down what I did there. I mean Documentation is really important. What's that more of a cursing yourself or not or cursing Why didn't I write with this 10 or going back to a year old? You're like Where you're taking your project to somebody that let's you know Which part is your move that you're like that doesn't make sense there And then all of a sudden you just start reporting a bug like a random book Oh But yeah, I can't uh push that enough definitely document your code Even if it's just a just a tiny little bit just do it It also helps with um when you're working on like php storm if you're documenting what your parameters are and what your returns are When you're in another file calling that function, you'll get type hints and suggestions on what you can use there What's wrong with it if you're pushing the wrong things and um It's not that hard in fact I was gonna say and they basically push you to do that I like all of your functions I mean php storm will do it automatically for you if you just slash alt insert star Enter Then it did nothing. I need two stars. I'm gonna say you can go a step further too and do alt alt insert alt insert just right here I don't know how to do that on Anyway slash star star enter and it automatically puts in your inline documentation on that function Yeah, that only does really one if you just like you can insert override methods for class you're working on you can mass insert Dot bars for the entire file Okay So here's a Kind of look at how I would structure a plugin that's doing a lot of a framework that's doing a lot of stuff at wood commerce We have our wood commerce classes here on this side that we're thinking about as we're developing We've got product cart gateways and border so in our plugin Let's wrap all of those in our own classes, you know, so we can do what we've wanted them Within our wrapper class, but still have access to the actual core wood commerce class um So yeah, so we just kind of mock one of those up. I'll show you in a second Then we have our assets or utilities or core and stuff, but I this this Duplication or wrapping that we do really is is very useful at the end of the day I kind of showed you what the post meta thing Let's just kind of look at my project set up here This bigger one. All right, so I have a post types directory We have an order and I have a product. So it's like a product It's a class A class in my namespace called product and that again, that's the joy of namespacing This is the namespace of my plugin so I can name this whatever I want It's got its own full address. I can just call it product and mimic exactly what woo has Um, the name is typically the what I use as the post type So this will be stored as product. That's what woo stores it as is as product Um, when we construct we can pass it in a product ID And when we do that we set them with ideas within our class and we set what the root product is We pull the actual root product Object and put it within arms. So we have this wrapper where we can touch the root product. We can do our own thing I think you can just extend it You can extend but that gives you less power I don't think so I mean it gives you the inability to overwrite a function named there I don't want to overwrite function names. I want to leave root functions as they are I don't want to touch their native code. I don't want to change how their stuff works I want to extend outward around it Um, it gets dangerous when you start doing that because what about when the root upgrades And you've spent all this time manipulating some function and then that's all I'm thinking overload I just meant your your nid is the same as their nid But I see the variation that this pattern works really well for me and for co-workers and so forth. So it works um, this is a little more of a complex And it's not really tested I Um, haven't really needed to do this for a little bit, but in my mind this would be smart You can pull in the exact I usually just use wc product for everything because it has all the main product methods you want such as like get price um Get property those kind of things that you want to be able to pull from the product They're all they're all There's 100 ways to skin this cat. This was my quick run down. Um the get root product Just returns our our root product is bundle. This is a custom function. I want a hat This is something that we doesn't have I'm building a bundle feature So I want to be able to say to my product load this product with this product ID Tell me the price and also tell me as a part of a bundle I can do all that through the same variable because I haven't wrapped the product wrapped in my personal product object Uh get bundled product IDs. That's another method that I want to have Um, we're gonna get a little more into what this is actually doing in a minute I wanted to kind of show you the structure there Uh, let me speak for a second So I got the post types. I separate post medic here. That's what we do. You don't have to do that I mean you can do it however you want. Um, that's what we like though And then I I like the WooCommerce directory. This isn't something that we're directed to do at my job This is something that developed before before me did that I really liked his patterning. So I did it having your own WooCommerce directory directory to mirror object and classes in, um Woo that aren't exactly post types such as the cart. There's a cart class in Woo that does a lot of the cart management and We want to be able to do some stuff with the cart as well. Let's reflect it over here Check out. That's how Woo labels it. Let's label it in an artist. Check out that way we can stay within a grid Um, as they do the shop we can handle our shop stuff Um, we use service providers This kind of keeps all our hooks and filters organized instead of having them spread throughout the whole thing Um, you know, so here we register our instances we We would put within this hook filter all the different hooks we want in a direct back to our class objects Let's be example. We just did Hook it up So many options. Um, so this this section I almost removed my talk, but it's it's got some decent stuff And so we'll just kind of go through it real fast Um, now down what you want to happen make it happen We talked about that already find the most appropriate filter of action That could be pretty challenging because there's a lot of ways to filter and hook into a Woo conversation Do what you want such as starting the checkout process you can hook into Payment complete you can hook into thanking page or do all these things with the data of the order after the order's been completed But then drilling down to exactly where you want to be in that process Is this it's a challenge and it's something that you need to Think a lot about as you're approaching this, you know, do you want to do this before? The status is updated to complete it, you know, it's paid status hasn't been updated There's something I do there What do you just want to wait to get the thank you page and the order is completely done and in the database and set And then you do whatever you want to do so it I don't really have a very thorough example of that, but When it comes time if you're doing this stuff just take some time to really dig in what filters and actions you have available to you We all know about priority probably But as I mentioned earlier, if you're using a filter in Woo commerce that's filtering some data Make sure you don't have any other plugins or third-party plugins that are using the same filter And if you do make sure you're prioritizing it right or removing their calls to it because My very first main slide about Woo was how important this is we're dealing with money You want to make sure that whatever is touching your price and amount data Is built by you or you know, exactly what it's doing to it. So this is just really important to pay attention to that stuff Uh, the multiple passing it I'm briefly touched on this. So here's the example When you check out do the normal check out it goes through, um, the typical Woo commerce checkout process usually uses Ajax. Oh, wow. I'm talking a lot Typically gives an Ajax process And checks out and that's like 90% of the time what you're going to expect to happen when somebody's going through But again, if you're using a short code version of a checkout form with any place of your website It's going to handle it differently. So in order to make sure that what was this So there's something you want to validate during the checkout process Typically you look into WooCommerce after checkout validation So we've read this validation checks and it's saying do you want to perform any two and we do And we can either return false or let it pass through and and check out But that doesn't work on the short code form We had to go in and dig around and find a Actually, I could hook into you and then I had to deal with this is said pay for order query string So that I mean it can get a little messy dealing with WooCommerce's alternate pass that they provide people Oh, there's another one. Uh, if you're Setting your visibility of a product don't show it in the catalog So somebody's going to shop on your page and shop around because the main loop it's not going to show You're like, great. My product's hidden. I don't want people to see this Well, they hit the REST API. It's not hidden. We don't do that. We don't believe they should do that Even I can get out there like, well, that's REST API. That's not our business. You know, you do what you want with that So you actually have to build out functionality to remove these hidden product visibility I'm filtering the query level on this It's pretty messed up. I agree But, you know, that's just some little kinks in here and they know about it And they do have a decent argument for why they don't touch this But at the same time you have to be aware Of what's going on there Uh reports. These are my biggest beef with WooCommerce now. I love WooCommerce I really do. I think it's a great plugin, but there are some serious issues I have with it The report system, you know, in the admin when you're in Woo and you go to reports You see the great bar bar charts and stuff showing your products and your sales and all that It's one What's that? What reporting system? If you go to the WooCom... No, I'm fine. I'm being facetious Good. There are some great third-party ones. I can't think of the name of it now, but I'll talk about their data Is that it? Maverick? Yeah, really good ones I need to share for shipping And it works really well, huh? Awesome. It supports everything over and you get the end-users to go down and ship it boom, boom, boom, boom That's beautiful And then comes back to Woo and updates the status you've got So you go to a third-party service and that's really cool There's a long way to do it right now Well, the default native report system is one giant query that WooCommerce puts together That does all the calculations in the SQL adds up all the totals in there And all this stuff within provides very minimal places for you to hook in and do anything So when I had a customer that wanted to take out, they didn't want... We added a fee for cash on delivery, right? So we used the default WooCommerce fee object, created the fee, added it to the order and so forth When they went to the reports, they don't want to see the cash on delivery fee They're like, that didn't count for sales. We don't want that in our WooCommerce reports I was like, okay, we'll filter it out But it took me forever to write this ridiculous SQL injection just to pull the COD fee out of their calculations And I mean, I guess I get it I guess using just one quick query to get all your calculations stuff seems great But it provides a lot less power to the people like us who want to extend it Or even when they want to go in and do it differently You know, really dig in on those reports, which is probably why they don't change it very much I don't know, I threw this in there because it's kind of cool I guess I was using closures to filter If you haven't done that before, you can put a function into a variable, run it through a filter, do whatever you need and then Remove that filter out It's a really useful thing This I wound up not using it here because it was way easier than I thought Let's talk about translations though We have a customer that we pull the account fields out and it's in Japanese They have a Japanese translation on the website So we show the address and all that stuff in Japanese But then they want to show the English version of it as well Underneath they want their users to see both versions I don't know why but they do They're very attentive on that So we had to unload the WooCommerce text domain Then reload in the country states With these guys spit out get a formatted address with no text domain loaded And then reload the WooCommerce text domain Reload the states back into their data And it would work perfectly So just know, I don't know, I thought it was kind of cool We can just unload it and then whatever That's the right way to do when you need to use that This is wrong So this is my first attempt at doing a thing in WooCommerce So I thought that you could only see the status of an order By using the get status function Right? So that's what you typically get status What's the status? You can check, blah, blah It's just a string So that's why I said the status is not completed Return But the bad thing about that is What if Woo changed completed to just being complete In a future version You know, you don't want to rely on some non-constant string For your big checks in your code But what was happening here Was we, if a user was loaded as Japanese There's default language It wasn't coming back as completed It was coming back as Japanese characters So this check was failing every single time This though, you can do order has status completed And it doesn't run through any translations It uses, it hits up the default WooCommerce text for it But I still think it's wrong to be using a string completed They should be using some sort of constant hx A method that says is order completed Or something like that That's fair, they're probably using an untranslated version And it has status They're passing it Well, yeah, I wouldn't look into the function They are Yeah But when you do get status They run it through the translation Right, you're getting the raw status Exactly Staying compatible Use core Woo functions as much as you can If they deprecated And you're making some updates You'll be able to see the deprecation You'll be able to go to the function that's being deprecated See how Woo's changed how they do that Because typically that's what they do The function is deprecated Then within that deprecated function They change it to do it the proper way That they've updated their methods to use So you can see exactly what they're doing And use that and bring it out Try to avoid direct database access So you know, I mean that's a general rule For everything that you're going to be doing When you're extending especially The WC function is very useful It pulls into the main session A car that's currently going on And you have a lot of access to what the user is dealing with Don't overstep WC product With, oh yeah, so like Don't build your own getPrice function Unless you need to manipulate getPrice Use, if you're using a wrapper class Like I do, a product that wraps around the WC product Always tap into that Woo commerce order To use that getPrice method Don't go, you know, trying to do what Woo is doing already The change log is your friend When the new version comes out Go through the change log Fixing bricks I haven't seen this slide in a long time These aren't your slides Fix your shit So thanks, that's it Q&A