• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

Modification of the plugin for woocommerce attribute grouping

elandeler

Member
May 8, 2020
51
32
18
First the foreword. I have spent a lot of time to find a solution that will allow me to break down the product characteristics into sections (categories). In the end I found only one obscure plugin that is too complex and requires a redux framework. In general, none of the fresh solutions suited me...

Recently I found a plugin in the wilderness, which was abandoned by a developer back in 2017, it almost works fine (almost), except for one function.

Here is the plugin itself:
JC WooCommerce Advanced Attributes 2.0.7
.

The essence is that the name of the attribute's group is specified through the attribute's name, through the point separation (Category name.Attribute name), and the attribute itself is displayed through the custom field, which is filled in the attribute's settings.

The problem is that the attribute's custom name is not displayed on the product page, but instead the original name of the attribute is displayed (Category name.Attribute's name). In other word, the function wc_attribute_label is called instead of jcaa_attribute_label in place of attribute name.

I have no idea where to dig, I don't know much about php. I suspect that the problem lies in the file /libs/jcaa-functions.php on line 202, who can help with that? I can prepare a test environment for the plugin.

I think I'm not the only one looking for an adequate solution for such a task, so you can create a fork for the plugin and post it here.
 
Last edited:
  • Like
Reactions: amamarar
So, you're basically saying that what is in the instructions does not work?

In the instructions it says this:
(Under Group Simple Product Attributes)
2. Under the advanced attributes display settings labelled Custom Label - enter the Name which you want it to appear under the Group e.g. (Bank, Elevation), this name will be displayed on the product information tab.
 
So, you're basically saying that what is in the instructions does not work?

In the instructions it says this:
(Under Group Simple Product Attributes)
2. Under the advanced attributes display settings labelled Custom Label - enter the Name which you want it to appear under the Group e.g. (Bank, Elevation), this name will be displayed on the product information tab.

Yes, I did according to the instructions, put the separator as a dot and checked that this attribute is group, also changed the name in the custom label (but this logically is not required).

Result on the screenshot:
screenshot.png
 
The problem is indeed in the function jcaa_attribute_label in jcaa-functions.php, as you suspected. The variable $name on line 210 is not properly defined. As a result $id is empty (or rather : NULL) and thus the rest of the code doesn't work either.

The solution is to sanitize $name. To do so put the following line directly after line 209 which reads 'global $wpdb;'

PHP:
$name = wc_sanitize_taxonomy_name( str_replace( 'pa_', '', $name ) );

On my local install, it works after I inserted above line.

A little more info: 'pa_' is the prefix WooCommerce uses for Product Attributes in the database. Your attribute name doesn't have that prefix, so to get the right details from the database, that prefix has first to be removed from the search, otherwise the search will always return NULL.
 
Last edited:
  • Like
Reactions: elandeler
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock