1. Home
  2. Knowledge Base
  3. Uncanny Codes
  4. Selling Codes with WooCommerce

Selling Codes with WooCommerce


Uncanny Codes 4.0 and later allow you to sell codes directly to customers. This means administrators can generate large batches of codes, associate a product with those codes, and when users purchase the product they receive the codes for use by themselves or other people. This functionality is useful as a substitute for gift cards, promotional gifts, selling accounts to organizations or really anything where codes grant access to something.

Set up WooCommerce products for code sales

Selling codes does require the use of WooCommerce, the most widely used ecommerce plugin for WordPress. WooCommerce must be configured before codes can be sold.

Sell Codes for WooCommerce

To set up a WooCommerce product to sell codes to end users, perform the following steps:

  1. Generate the code batch you want to sell before creating a new product.
  2. In the Products menu for WooCommerce that appears in /wp-admin/, choose Add New to create a new product.
  3. Set up the product as you normally would for other WooCommerce products. See https://docs.woocommerce.com/document/managing-products/ for additional help. In the Product data drop-down list, choose Codes for Uncanny Automator.
  4. Make sure you set a Regular price for each code. The user will be charged this times the number of codes (the quantity) that they purchase.
  5. In the Code batch field, choose the name of the batch that you want to link to the product. When users buy the product, they will be assigned codes from this batch. (If you don’t see the batch that you want to use, it could be because of one of these 3 things: the batch is not an Automator type, codes in the batch allow more than one redemption per code, or the batch is already mapped to another product. You cannot add a batch to more than one product because it would create issues with inventory tracking.)
  6. Publish the product so that it is available for users to purchase.

The values for Total codes, Available Codes and Stock quantity are not editable. These values are calculated automatically based on the number of codes available.

Buying codes as a WooCommerce customer

Code products are purchased in the same way as other WooCommerce products, but we highly recommend you autocomplete orders that include codes (see the WooCommerce settings in https://www.uncannyowl.com/knowledge-base/set-up-uncanny-codes-for-wordpress/#Settings for more information). This is because codes from a batch are linked to an order as soon as the order is created and are no longer available for sale to other customers.

When a “Codes for Uncanny Automator” product is purchased, the customer buying the product is sent the WooCommerce order completion email, which will include a copy of the purchased codes in plain text and in a CSV attachment. The customer also has access to code details (including an indicator of whether or not the code has been redeemed) on the order details page under the WooCommerce My Account area. See below for an example of what users see after purchasing several codes from a batch.

WooCommerce codes in My Account

Important notes

While the code sale process is straightforward, keeping a few best practices in mind will make selling codes with WooCommerce far easier to manage.

  1. If you map a code batch to a product, make those codes only available for purchasers of the product. It’s not a good idea to also distribute codes that you plan to sell; in other words, if you’re selling codes, don’t also retrieve them from the View Codes page and then share them with other users.
  2. Any WooCommerce plugins that support custom pricing and quantity rules will work with our code products. This means you can, in fact, sell codes only in quantities of 100 if you want, or offer discounts if someone buys 10 or more codes.
  3. You must set up a way for users to redeem the codes that you sell. Make sure you set up a registration form or redemption form, as appropriate, and that buyers of your codes are given instructions so they know how to redeem them. If you’re using Uncanny Automator, maybe set up a recipe so that when Codes products are purchased, the user who buys them receives an extra email with instructions for redemption that they can communicate to the people who receive their codes.
  4. WP Engine Users: There’s a setting in the control panel for WP Engine sites for “Allow Order by RAND()” that must be enabled. If it’s turned off, codes will not be associated with orders properly. Here’s a screenshot:
    Allow ORDER by RAND()



0 replies


Please note that this is not a support forum. If you are experiencing issues on your site, please open a support ticket instead. Site-specific support questions submitted as comments will be unanswered.

Leave a Reply

Your email address will not be published. Required fields are marked *