Login
Register

VirtueMart

WooCommerce

Others

Docs

Support

Blog

About

Forum

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!

×

Notice

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

TOPIC:

Custom variables not working properly 29 Apr 2016 10:41 #1

  • iai
  • iai's Avatar Topic Author
Hello

I'm trying to use custom variables on product categories. I have tried to use
Categories
categories
Category
category
for variables and using equal and contains condition and non of them work.
What i want to achieve:
If category = AAA then prefix = AAA
I have [prefix]-[year]-[#####] as an output.

But instead of getting let's say AAA-2016-00001 i get [prefix]-2016-00001 as an invoice and order numbers.
I have disabled all plugins and moved to default theme, but it did not help.

How to use categories as a custom variable. I have tested demo and it did the job. But once i've purchases it does not work on my site.

Custom variables not working properly 03 May 2016 11:33 #2

  • iai
  • iai's Avatar Topic Author
Ok. Seems i have found a bug in your plugin
1) custom variables does not work if name (tag or category) consists of multiple words like training materials. It does not work neither with equal sign nor with contain option. Once i change slug to one word (let's say training) it works ok but then second error comes.... below
2) custom variables does not work if = sign is used, even if work is written completely. It works only when i pur contains. So Categories = training will not work, but Categories contains training will work.

Custom variables not working properly 03 May 2016 23:10 #3

Dear Iai,
Thank you for investigating further.

The categories (and tags) variables are a list of all category/tag SLUGs, not the human-readable names, as the names might be translated in multilingual shops. Typically, if you have a category with display name "Training Materials", the Slug in the category definitions page is "training-materials". If you use that in the custom variable definitions, things should work.

I have updated the documentation page to indicate that the Categories list contains the SLUGs of the categories, not their human-readable names.

Regarding the check with an equal sign: Categories is a LIST, so = does not really make sense in general. For list variables like SKUs, Categories, Tags, ShippingClasses etc. you should always use "contains".
The only case where = makes sense if there is only one category in the cart (i.e. all products belong only to one and the same category, and no other categories => the categories list is a list with one entry). In this case, category="training-materials" might be understood as a condition: There are only products from that one category in the cart, and none of the products in the cart belong to any other category (i.e. the Categories list is a one-element list with sole entry "training-materials"). For now, I think this is too much of a borderline-case, so we'll probably not implement this idea. Using "contains" on those five list variables provides exactly the functionality that you want to use, so I don't see any pressing need to change this.

Sorry for the confusion with the contents of the Categories list!

Best regards,
Reinhold
  • Page:
  • 1