1

I'm facing an issue where:

  1. I've created a custom attribute type
  2. Created an attribute, called it 'test'
  3. Added one term to the attribute, and called this 'Hi'
  4. Go to edit the varations in edit product and I cannot seem to add any terms to it. There's just nothing there to select like normal.

This is the code I used to add a custom attribute type:

add_filter( 'product_attributes_type_selector', function($array){
    $array['test'] = __( 'Test', 'awcs' );
} );

The code is working, where it adds the type to the dropdown when creating a new attribute, it's just the variants of the attribute not displaying in the edit product page.

1
  • Try to remove that attribute from the product and add again. It worked for me.
    – Jay Liu
    Commented Jun 12, 2020 at 12:52

2 Answers 2

1

I just had that problem and resolved it alone since i could not find the answer online. You just need to put that code inside an if. Only to run that code on attribute page.

if ($_GET['page']=='product_attributes') {
  add_filter( 'product_attributes_type_selector', function($array){
    $array['test'] = __( 'Test', 'awcs' );
  } );
}
0

It doesn't look like you are returning anything to the filter. Try this.

add_filter("product_attributes_type_selector" , function( $array ){
    $array['test'] = __( 'Test', 'awcs' );
    return $array ;
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.