Adding field group for WooCommerce Category

Support MB Term Meta Adding field group for WooCommerce CategoryResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #29589
    info@woutr.io[email protected]
    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

    #29592
    Long NguyenLong 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[email protected]
    Participant

    Thanks! Much appreciated

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