How can I set my store to notify an admin when a new customer account is created?

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.

Happy Modding!

Is there a way to display the stock status in a dropdown for product variations on my store?

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.

Happy customizing.

How do I add custom fields to the registration form on my store if I am using Product Vendors?

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:

[wcpv_registration]

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.

 

How can I add external/affiliate products to my store?

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.

Example:

 

How do I enable multiple products to be added to cart on my store?

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:

[wamp_product_input]

From there, you can then choose which individual products this ability applies to via your settings page.

Is there a way to conditionally show or hide checkout fields for specific products or product categories in my store?

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().

How can I increase the number of default product variations in WooCommerce?

There are case by case instances where you might want to change the number of default product variations. By default, WooCommerce only allows for 30 product variations.

The good news is that you can add a simple code snippet in your theme’s functions.php file.

Add the code below to your theme’s functions.php file and change the number for the number of variations you want to for your products.

With this code now in your functions.php file, you can modify the amount whenever you want.

How can I use Advanced Custom Fields to Add Custom Tabs to WooCommerce Products?

Advanced Custom Fields Pro is a plugin that allows you to do a number of things. However, in this tutorials, we are going to walk you through how to add custom tabs to WooCommerce products.

Please note this tutorial does require the use of code, so it’s best for those familiar with writing code, like a developer. 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.

To get started the first thing you are going to need to do is to create a new file in your theme’s folder. We’ll call it acf-fields.php. Then we’ll add the following code to the file.

This code is what creates the ACF repeater fields and in return 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.

Automatically Restore Stock Levels After Cancellation with WooCommerce

If you’re selling physical products with your WooCommerce store, you already know that accurate inventory counts are really important. You need to know how many t-shirts you have on hand, or if it’s time to restock specialty items after a big sale. With WooCommerce, it’s easy to see how much you’ve sold on your store and watch stock levels. 

When an order is cancelled or refunded, is there a way to have the stock level restored automatically on a WooCommerce store?

When an order is cancelled, what happens? What do you do when you have to issue a refund for an item that didn’t fit? Maybe you manually update stock counts after every cancellation of refund. But that’s more work than you have time for, and it leaves too much room for counting errors.

Fortunately, the WooCommerce Auto Restore Stock plugin automates post-cancellation stock updates. Simply install and activate the plugin on your WooCommerce store. Now your stock levels will automatically adjust when a customer cancels their order, or you cancel and refund for them.

WooCommerce Auto Restore Stock