iThemes Exchange, our free ecommerce plugin, is the easiest way to get your clients selling online with WordPress.
In this week’s Learn Theme & Add-on Development for iThemes Exchange webinar, lead dev Glenn Ansley gave attendees a tour guide of the code base for iThemes Exchange. Here’s a quick recap.
Note: you may view all the slides here.
By the end of the webinar, you’ll know how to:
- Change the order of the fields on the registration page
- Create a new product type
- Create a new add-on/theme for iThemes Exchange
- Use the API
Replay the webinar
How iThemes Exchange is Organized
Glenn walked through how iThemes Exchange files are organized. You’ll see three main folders in the root of the plugin. 1) First is the /lib (short for library) this is where the lowest level of code lives. This is the building block for everything we do. For the most part, you won’t need this unless you want to see something very specific we’re doing. Lib provides the foundational work for the API. 2) The /api directory is probably where most of you are going to want to jump in. If you need to do something in Exchange, chances are we’ve written something to help you do it. For example messages.php allows you to send messages to the users. If you get familiar with any of our code base, go to /api first. 3) Another area that is helpful to you is /core-addons. In the basic Exchange download we give you the bare minimum that you need to run a shop. You’ll notice that you won’t have a cart, for example. This was a decision based upon a community poll among our user base. When you know you need it, then you can add it. If you know you’re going to create a new add-on, go into this directory and look at what we did with out add-ons.
This is important if you’re a developer making customized solutions for iThemes Exchange. It’s helpful to know how we do things and how Exchange is organized. You can save yourself a lot of work by checking out these files.
How Products and Product Types Work
In Exchange we have a product post type. All Exchange products are a single WP post_type. In WordPress your familiar with post types, i.e.: pages, posts, etc. Product types are a type of wrapper to differentiate between various product types. By having different product types, we can make the interface more targeted to what you’re trying to do. This leads to the concept of product features, which is a big part of product types. Here’s how it works: you create a product type, then you register product features and assign features to the product. You can do this with API calls also. Here is where we register our custom post type for products. You can see that all our various product types are actually one WordPress post type The admin UI is reactive to the registered types. Exchange allows you to label your product type membership, etc. Depending on how many product types you have enabled, your UI will change.
How Product Features Work
Start with the abstract class if you’re going to create your own product feature. Extend the abstract class. Then in that function that is called when you initiate the class, Exchange sets up everything based on the arguments you provide. It’s helpful to mention that we’ve taken all the things that usually come with a WordPress post and converted those into product features.
How Templating Works
Templating is complicated and has a lot of parts. We did that because we wanted to give you (the developers) a lot of flexibility. With great flexibility comes great complexity. It doesn’t have to be complex, if you don’t want it to be. However, the complexity is worth it in the end, should you choose to template. Here is a list of all the iThemes Exchange template-parts We’ve broken down most of these to include smaller template parts. This is where the complexity comes in. If you want to follow/use the includes here’s how you can do it, using content-store.php as an example. This is our template for the store. We’ve included some template parts and the loops. We could have put all the code here, but we broke it down into smaller files. What you see happening in the screen above is when your customer lands on the login form, we’re going to include the content-login.php file and it’s going to call the actions and fields loop. Each of those are going to include their respective fields and actions that you want. It gets a bit more complex from here, if you’d like to dig deeper, replay the webinar.
These are just some quick highlights from Glenn’s webinar. He covered much more, in great depth. Watch the full webinar so you don’t miss anything!