Automattic\WooCommerce\Internal\ProductAttributes
VisualAttributeTermAdmin::render_table_visual_attribute_fields
Render visual attribute fields for edit forms.
Method of the class: VisualAttributeTermAdmin{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = VisualAttributeTermAdmin::render_table_visual_attribute_fields( $term ): void;
- $term(WP_Term) (required)
- Current term.
VisualAttributeTermAdmin::render_table_visual_attribute_fields() VisualAttributeTermAdmin::render table visual attribute fields code WC 10.9.1
<?php
private static function render_table_visual_attribute_fields( \WP_Term $term ): void {
$color_value = get_term_meta( $term->term_id, 'color', true );
$color_value = is_string( $color_value ) ? $color_value : '';
$image_value = absint( get_term_meta( $term->term_id, 'image', true ) );
$visual_type = $image_value > 0 ? VisualAttributeTermMeta::TYPE_IMAGE : VisualAttributeTermMeta::TYPE_COLOR;
$field_prefix = 'term-';
?>
<tr class="form-field wc-admin-visual-attribute-type">
<th scope="row" valign="top">
<label><?php esc_html_e( 'Swatch type', 'woocommerce' ); ?></label>
</th>
<td><?php self::render_visual_type_inputs( $field_prefix, $visual_type ); ?></td>
</tr>
<tr class="form-field wc-admin-visual-attribute-color">
<th scope="row" valign="top">
<label for="<?php echo esc_attr( self::get_color_input_id( $field_prefix ) ); ?>"><?php esc_html_e( 'Color value', 'woocommerce' ); ?></label>
</th>
<td><?php self::render_color_input_control( $field_prefix, $color_value ); ?></td>
</tr>
<tr class="form-field wc-admin-visual-attribute-image">
<th scope="row" valign="top">
<label for="<?php echo esc_attr( self::get_image_input_id( $field_prefix ) ); ?>"><?php esc_html_e( 'Image value', 'woocommerce' ); ?></label>
</th>
<td><?php self::render_image_input_control( $field_prefix, $image_value ); ?></td>
</tr>
<?php
}