Liquid Web is here to support your migration needs into our Managed WooCommerce Hosting platform. Whether you are migrating from an external or internal source, our in-house team of migration experts transforms the data migration process into a simple task. To ensure the smoothest and best possible data transfer, we have a quick overview and a few points for your consideration. Continue reading “Migration to Managed WooCommerce”
Having search engines crawl add-to-cart links and other unwanted pages can damage your SEO rankings. Add-to-links can cause more specific issues because those pages are not cached, and this can also increase your CPU and memory usage as they are hit repeatedly.
Fortunately, it is very simple to adapt your site’s robot.txt file to make sure Google and other search engines are only the crawling pages you want. You can these lines of code into the site robots.txt file, specifically to address the add-to-cart links:
User-agent: * Disallow: /*add-to-cart=*
When you add these lines to the robot.txt file the file is not saying that any search engine that hits the site cannot index your add-to-cart links.
We also recommend that you adapt your robots.txt file to disallow indexing of the cart, checkout and my-account pages, which can be done by adding the lines below, to the same file.
Disallow: /cart/ Disallow: /checkout/ Disallow: /my-account/
If you sell products as an Amazon, or other company affiliate, then you probably want to mark those products as external or affiliate products. This is something you can do within a default WooCommerce install, and it requires no special plugins or code.
First, add your new product, then choose External/Affiliate product from the Product Data dropdown menu.
In this section you can set the external URL, any special button text, and the price.
Advanced Custom Fields Pro is a plugin that allows you to do a number of things. However, in this tutorial, we’re going to walk you through how to add custom tabs to WooCommerce products.
Please note that this tutorial is a bit of a developer tutorial. You will be adding some code to your theme’s functions.php file and adding another php file to your theme. You also need to make sure that you have the Advanced Custom Fields Pro plugin installed and activated on your site.
The first thing you need to do is create a new file in your theme’s folder. We’ll call it acf-fields.php. We’ll add the following code to the file.
This code is what creates the ACF repeater fields and thus creates the tabs on your WooCommerce product.
Next, you’ll need to add this code to your theme’s functions.php file. This will set up the tabs in your theme.
With both files being uploaded to your site, you will now have ACF custom tabs on your WooCommerce products.
By default, WordPress will only let you search by email address or username on the Users page, which can make it hard to find information quickly. Installing the Full Name Search in WP-admin plugin will allow you to search by a customer’s first name and full name.
Keeping track of customer accounts is important, and if you want a site administrator to receive a notification that’s a simple task. You can add this code snippet via the Code Snippets plugin (recommended), or manually by pasting it into your theme’s functions.php file:
Just change “admin” with the username you want the emails to go to.
If you have products that tend to sell out, or that you typically sell in bulk, it might be beneficial to display the available product quantity. This can ensure your customers have the ability to order the quantity or volume they need.
Displaying your stock availability is as simple as adding a quick code snippet to your theme’s function.php.
As the internet evolves, so does the information you need from customers when they register with your store. It’s likely that a default registration form will cover everything you want to gather when some signs up. For example, having social media usernames can help you keep in touch, but those fields are not automatically part of the default form.
It’s also important that you be able to add the same information if you manually create a user within the dashboard itself. Adding and modifying a bit of code in your theme’s function.php file will allow you to do both.
Let’s break down this code a bit.
Lines 1 to 50, adds the two new fields to the taxonomy in the Product Vendors form. This allows you to specify their Facebook or Twitter URLs as to manually create or edit a vendor in the WP-Admin.
Lines 51 to 76, validates and saves the fields in the database.
Lines 78 to 91, adds the same fields to the registration form. You can show this on a page by using the shortcode:
The fields will appear after the Vendor Description fields. These are shown at the end of the form right before the Submit button.
Lastly, lines 93 to 98 saved the fields in the vendor taxonomy.
Of course this is a simple example with two text fields. You could easily add any kind of fields you want, even more than 2.
This is just a simple example with two text fields, as you can imagine you can add any kind of fields, and as many as you want.
Online shopping is one of the great conveniences of this age, and anything you can do to make purchasing easier is appreciated by your customers and likely to bring in more revenue through your store. An easy way to enable more sales is allowing customers to add multiple products to the cart, without having to leave their current page.
Offering this functionality is as simple as installing the WooCom Add Multiple Products plugin and using the newly added widget.
In addition, you can use this shortcode to add the input form to other pages:
From there, you can then choose which individual products this ability applies to via your settings page.
WooCommerce out of the box is great. It helps you quickly build a checkout process, gives you basic reporting, provides you with a way to add products to your store, and even helps setup shipping for you. But what happens if you want a little more control over your checkout process? What if you want to push the boundaries a bit and hide some checkout fields from the checkout process on specific products or product categories where those fields don’t make sense?
That’s what we’re going to cover in this tutorial.
The only way I currently know how to remove checkout fields is by doing it with code. Let’s start out simple by setting up a simple function to remove a checkout field. This is very basic. Simply add the following to your theme’s functions.php file (or create a simple plugin that you could add this to.)
What’s great about this code snippet is that you can add any fields you want removed from your checkout process.
Note: You do want to be careful with this though. Removing fields from your checkout process can cause you to not get enough information from the purchaser.
While this removes a checkout field, it doesn’t do it for specific products or product categories. Let’s move into that next.
Product Specific Conditional
Ok, when you want to conditionally remove a field based on if a product is in the cart or not, we need to do a little more work. We’ll be building off of the initial function we just went over.
We first need to create a new function that checks to see if a specific product ID is in the cart. We’ll have an array in there, so we’ll be looking for multiple products, which is helpful if you have multiple products that you don’t want to have a field/s show up in the checkout process.
After we have the array of product IDs, we then create an array of products that are in the cart. We’ll loop through the IDs and see if any of our product IDs are in there. If we find one (or multiple), we return true. This way we can use that true in our removal checkout field function.
Here’s the function for our products and the products that are in the cart.
In the first array, you can change those product IDs to match the IDs of the products you’re looking for.
With this additional function, we now need to go back to our other function and make a slight change. We need to check to see if our function returns true or false. Here’s that logic added to our first function.
That’s it. We can now search for specific products and remove checkout fields if those products are in the cart. In the next section, we’ll look at adapting our code to look for specific categories.
Product Category Conditional
Using similar code that we did previously, we can modify one function to check for categories instead of product IDs.
The biggest difference here is that we initially need to have an array of categories instead of IDs. We then need to figure out the cart products and what categories they belong too. This is a bit more complicated so there are a few foreach blocks to get to the categories.
We then compare the product categories we have in our array with the product categories that are in the cart. If our categories exist, we’ll return true, otherwise we’ll return false. Here’s that code with some comments for assistance.
And all we need to do is look at our second function and replace wc_ninja_product_is_in_the_cart() with our new function wc_ninja_category_is_in_the_cart().