Hi Pacotole,
Thanks for using our plugin and reaching out to us. You are right, a few releases back we removed all custom attributes that start with a _ from the drop-downs as a lot of plugin’s and theme’s add custom attributes that start with a _ but are not relevant for WooCommerce products. It got so bad that some of the drop-downs became too long for users to work with. Hence, that is why we removed them.
Would it be an option for you to just rename your attribute to gtin, without the _ ?
All the best,
Eva
I have been able to solve the problem by adding a filter to the query:
function fix_custom_attributes_query($query) {
global $wpdb;
if (strpos($query, "meta.meta_key NOT LIKE '\_%' OR meta.meta_key LIKE '\_woosea%' OR meta.meta_key='_product_attributes'") !== false) {
$query = "SELECT meta.meta_id, meta.meta_key as name, meta.meta_value as type ".
"FROM " . $wpdb->prefix . "postmeta AS meta, " . $wpdb->prefix . "posts AS posts " .
"WHERE meta.post_id = posts.id " .
"AND posts.post_type LIKE '%product%' ".
"AND meta.meta_key NOT LIKE 'pyre%' ".
"AND meta.meta_key NOT LIKE 'sbg_%' ".
"AND meta.meta_key NOT LIKE 'wccaf_%' ".
"AND meta.meta_key NOT LIKE 'rp_%' ".
"AND meta.meta_key NOT LIKE '_oembed%' " . // extra clean
"AND meta.meta_key NOT LIKE '_elementor%' " . // extra clean
//disable "AND (meta.meta_key NOT LIKE '\_%' OR meta.meta_key LIKE '\_woosea%' OR meta.meta_key='_product_attributes') ".
"GROUP BY meta.meta_key ".
"ORDER BY meta.meta_key ASC;";
}
return $query;
}
add_filter('query', 'fix_custom_attributes_query');
It would be great if the plugin had a filter to modify the list of Custom Attributes.
Thanks!
Great you were able to solve the issue at hand yourselves.
We will put your feature request on out wish-list 🙂
All the best,
Eva
You could add in the custom attributes query a condition to include _gtin field
meta.meta_key NOT LIKE '\_%' OR meta.meta_key = '_gtin'
It’s a very used and important field.
Anyway, it would be best to have a filter to modify the sql query.