Ordernumbers for WooCommerce

IMPORTANT ANNOUNCEMENT: Plugin development ceased, all plugins made available freely (GPL)

With great sadness we have to announce that we are ceasing development of all our VirtueMart, WooCommerce and Joomla plugins. Effective immediately, all our plugins -- even those that were paid downloads -- are made available for free from our homepage (GPL license still applies), but we cannot and will not provide any support anymore.

It has been a great pleasure to be part of the thriving development communities of VirtueMart as well as WooCommerce. However, during the last year it became painstakingly clear that in addition to a full-time job, a young family and several other time-consuming hobbies at professional level (like being a professional singer) the plugin development and the support that it requires is not sustainable and is taking its toll. It has been an honor, but it is now time to say good bye!



The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1


Number Series based on product 23 May 2015 15:01 #1

  • rclose
  • rclose's Avatar Topic Author
Hi, i purchased this so i could run different number series based on products, but there is no product variable or product catagory variable.

So i have 4 products. What variable do i use to refer to the product ID or product name or product category so i can run different number formats for each

ie 0 to x for product 1
0 to X for product 2

Thank you

Number Series based on product 23 May 2015 18:30 #2

Dear Ray,
I have to admit that the documentation is still work in progress (i.e. only the introduction is finished, but the rest is not properly updated for the WooCommerce plugin. In particular the table of available variables in WooCommerce is still completely wrong, that's why you could not find any variable that would describe the products in the cart. We'll try to improve the documentation to a usable state asap.).

There are in fact three list variables that you can use:
  • skus: A list of all SKUs of the products in the cart
  • categories: A list of all category slugs of the products in the cart
  • tags: alist of all tags of the products in the cart

These list variables cannot be directly used in the number format (because they are lists, but the number is just a string), but you can base custom variable definitions on them in the advanced version of the plugin. See the screenshot of the settings I used for my tests:

Notice in particular the custom variable definitions near the bottom:
  • If skus contains "Prod1" => Set variable "product" to "Prod1"
  • If skus contains "Prod2" => Set variable "product" to "Prod2"
  • If skus contains "Prod3" => Set variable "product" to "Prod3"
This creates a variable "product" that you can use in the format, e.g. Order-[product]-#.
If an order contains multiple products, e.g. Prod1 and Prod2, the last assignment will be used (Prod2 in this example).

There are now two possibilities for the order numbers:
1) You want to include some product identifier (e.g. the Prod1, Prod2 and Prod3 in the above example) in the order number format.
To get ordernumbers like (notice that each product has its own counter):
you can simply use an order number format "WC-[product]-#" (and leave the "Global counter" checkbox UNchecked). The counters will be named "WC-Prod1-#", "WC-Prod2-#", etc. See the screenshot of the settings

2) From your message I understand that you want to display only the number, but not some product identifier. I.e. The above orders would get numbering:
1  (Product 1 ordered)
    2  (Product 1 ordered)
    1  (Product 2 ordered)
    3  (Product 1 ordered)
    1  (Product 3 ordered)
In particular, some orders will have duplicate numbers. This is also possible, by using a display format different from the actual counter name. To achieve this, the number format string has the format "displayNumberFormat|counterName". The counter name in this case has to inclue the [product] variable, but the displayNumberFormat does not. In this example, I would use a Order Number Format:

The orders will again be named WC-Prod1-#, WC-Prod2-# (see the counter table in the middle of the page). The difference is that now these counter names are only used to determine the next counter value, but the actual formatting will use the part before the |, i.e. it will be jsut the number.

As proof that this works, I'm also attaching a screenshot of the order list, where I set up three products with SKUs "Prod1", "Prod2" and "Prod3".

First I set the order number format to (the first use case described above):
and did some test orders (the orders near the bottom of the list). The resulting order numbers are "WC-Prod1-1", "WC-Prod1-2", "WC-Prod2-1", etc.

Second, I set the order number format to (the second use case described above, except that I prepended WC- to the display string, so the resulting order numbers are WC-1, WC-2, WC-1, WC-3, WC-1, etc.):

I hope this solves your problem and creates order numbers as you like them.

If you have any further issues, feel free to contact us again.

Best regards,

PS: Rather than creating the custom variable "product", you can even set the variable ordernumber_format to a format string of your choice. This will override the order number format string from the plugin configuration when the condition is met. This means that for Product 1, you can have an order number format "Prod1-[year]-#", while for Product 2 you can set the order number format to "[year]/[month]/[day]-[hour]/#", etc.
  • Page:
  • 1