Custom Fields
Re-Envisioned
Support MB Term Meta Adding field group for WooCommerce Category

  • Creator
    Topic
  • #29589
    Resolved info@woutr.io
    Participant

    Hi there,

    Maybe i am overlooking he solution but i can't fnd how to add custom fields for specific WooCommerce category only. I added Conditional Logic and Custom Taxonomy modules.
    Is it possible?

    Jasper

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #29592
    Long Nguyen
    Moderator

    Hi,

    Currently, the extension MB Term Meta only supports showing the field on all terms of the taxonomy. I will create a feature request to support showing the field on specific terms, just like 'terms' => array( termID, or termSlug ).

    You can try to create a condition before registering the meta box by coding. For example

    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    
    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
        if( !is_admin() ) return;
        $list_product_cat = array(16, 18); // list of product category IDs
        if( $_GET['taxonomy'] == 'product_cat' && in_array( $_GET['tag_ID'], $list_product_cat ) ) {
            $meta_boxes[] = [
                'title'       => __( 'Term Meta', 'your-text-domain' ),
                'id'          => 'term-meta1',
                'taxonomies'  => ['product_cat'],
                'fields'      => [
                    [
                        'name' => __( 'Text', 'your-text-domain' ),
                        'id'   => $prefix . 'text_opthfz8evwb',
                        'type' => 'text',
                    ],
                ],
            ];
        }
        return $meta_boxes;
    }

    Hope that makes sense.

    #29608
    info@woutr.io
    Participant

    Thanks! Much appreciated

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.