Before starting I must make a plea in favor of online stores with Woocommerce because many of you will be thinking that ecommerce is not set up with WordPress + Woocommerce. And I tell you that you are wrong.
Woocommerce yes or no
- With WP + Woo you need fewer resources to start the online store: ideal for testing a market, testing a range of products, starting to sell online when you already have a physical store, etc. By resources we mean web hosting power, hours of work and price of technical labor. If we want to compare, WP + Woo moves with half the power of Prestashop and with a quarter of Magento . Professionals who can start an online store with Woocommerce (including customizations, not just installing), there are many, for any other technology they are scarce (and therefore more expensive).
- The learning curve Woo is very fast (graphically a curve very steep).
- Woo allows fast customization of many functionalities, faster and more comfortable than a SaaS.
- All functionality extension plugins for Woo work and do what they say. 75% of Prestashop modules do not work properly.
- There are described ecommerce with more than 50 thousand products maintained with Woocommerce, why can’t you do it?
Now I’m going to give you one more reason to use WP + Woo: you can have several online stores with the same shopping cart. This functionality has been offered by Magento for a long time, but if your technology budget is limited and you find yourself in one of the above situations, that is not a valid option.
It is true that if you want to have several different stores your e-commerce project seems to be large enough to consider using a “big” technology. Or not. Your ecommerce project may have the characteristic of needing several independent online stores, even if they are small, to test different markets or different ranges of products, and at the same time it is interesting to have a single common shopping cart.
The technical explanation for non-technical people about the shopping cart
The information about what you have in your shopping cart can be saved in two different ways:
- In a cookie . This is how the store knows what you have in your cart if you are not logged in with your username and password.
- In a temporary record in the database, linked to your user in the store, that is, you must be identified.
If we want two online stores under different domains to share the same shopping cart, in the event that the information about what we have put in the cart is stored in a cookie, the only way to do it is to generate two cookies with the same content, one for each domain. This requires that technically when you browse a store you do it for both of them in some way, and that when you modify the content of your shopping cart, the order is executed in both so that the cookies are simultaneously modified.
In the event that we are identified in the online store and that the shopping cart information is saved in the database, we are faced with the same situation described above with cookies but with the database, or, share the database of users and the shopping cart between several stores, so that it is from the ecommerce that the information of the user and their shopping cart is unique in a shared data table.
Additionally, it must be taken into account that if you checkout (the payment of the purchase) in any of the stores, you must be able to do it with products from the other store, something somewhat rare for the internal processes of an ecommerce application. So sharing a data table, or several between independent stores is not trivial, and any solution is technically heavy to implement.
As I mentioned just before, one of the options is to share database tables between different stores. Here is the key, in sharing the same database for the two stores (or whatever). The easiest way to do this is to share the entire database, including the product database, even if some products appear in one store and others in another store.
Sharing the database between two electronic businesses means that it is a single database for the two stores, with a single ecommerce management application.
This implies that the user interface layer is the one that is going to be in charge of displaying one content or another depending on the domain or store in which we are. Underneath, a single online store application will actually be working, in this case Woocommerce on WordPress.
How to have multiple websites and a single WordPress + Woocommerce installation
WordPress, like almost any online content manager, is responsible for managing internal redirects of web pages to be able to use friendly links (urls). This is a problem if we want to use the same database for two different domains since all references to files and to the website itself are made through absolute links, that is, links that always include the domain name of the website. That makes it impossible to have a single installation and two different domains simultaneously.
To solve this great problem we have WordPress Multisite or WordPress Network (known as WordPress MU for its origin although for years it has been the same WP with a special configuration). This variant of WordPress allows you to have a single installation for multiple independent websites. But we still have a big problem to solve, and that is that the database is shared but each website has its own tables for configuration and its own content, since they function as completely independent and autonomous websites. This implies that the database tables corresponding to Woocommerce are also multiplied and are specific to each of the web sites on the network. This is the way WordPress.com gives web hosting service to any user.
How to have several domains with a single WordPress
The WordPress site network can be configured in two ways. Each website can be either subdomains of a main domain, or a directory of the main domain (installed at the root of the domain). When we do an installation of WP MU it is necessary to choose one or the other option, we cannot combine them.
In this case, the option to use directories is enough. Remember that you must have WP installed in the root of the domain.
To convert each of those websites from a folder to a separate domain, we need a plugin called WordPress MU Domain Mapping that will take care of redirecting all calls to a given domain to the corresponding website in WordPress.
With this plugin we can already envision the solution for two domains to use the same website, which is what it is about for the two domains to use the same Woocommerce, and therefore both online stores share users and shopping cart (also of course everything else).
Nothing prevents us from indicating in the configuration of the WP MU Domain Mapping plugin, that two domains are linked to the same website. As simple as that. In this way we will have two web domains with exactly the same content, one replica of the other.
Show different content based on domain
The last step is to customize the WordPress and Woocommerce templates ( theme ) so that depending on the domain the user is visiting, some content or others, some categories or others, some products or others, one header or another is loaded, that the internal search engine is restricted in each domain to what it corresponds to, etc.
And let’s not forget about SEO, we must be careful about what content we allow to index for each domain and not duplicate them because it would penalize us in the face of Google. Also meta headers, Twitter Cards and tracking codes such as Google Analytics must be customized for each domain.
We will do this in a simple way by simply adding a noindex meta in the header of the contents that may be shown under a domain that does not correspond to it. If we use XML Sitemaps to help Google index our content, we must also take it into account to generate the xml map correctly and add the corresponding content to each domain.
Difficulties to solve
One of the difficulties that I thought would destroy all of the above is that each of the online stores should work under the https security protocol . This implies that at the web server level it is necessary to have an SSL security certificate for each domain (or spend a fortune on a multi-domain certificate).
It turns out that our installation, as I have described it so far, uses different domains in a virtualized way, but a single physical site, which complicates the installation of an SSL certificate for each of the domains on the same physical site. I use server administration panels to manage the hosting, for convenience and because I do not like to get into the heavy task of setting up a web hosting by hand manipulating Apache or Nginx files. Hosting administration panels usually only allow you to install an SSL certificate on a domain with physical hosting configured. This has a solution, in fact I use Let’s Encrypt’s free SSL certificates , but I’ll leave that for another time.
If I’m honest, the heaviest thing can be the customization of the theme to show some content or others. What I recommend is that if this is your case, do not even think about using the official Woo theme , the Storefront, or any that is its son. The customization requires triple effort than any other theme .