Automattic\WooCommerce\Internal\ProductAttributes

VisualAttributeTermMeta::save_term_visual_by_typepublic staticWC 10.9.0

Save visual attribute term meta using the selected visual type.

Method of the class: VisualAttributeTermMeta{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = VisualAttributeTermMeta::save_term_visual_by_type( $term_id, $type, $color, $image_id ): void;
$term_id(int) (required)
Term ID.
$type(string) (required)
Selected visual type.
$color(string)
Hex color value.
Default: ''
$image_id(int)
Attachment ID for the term image.

Changelog

Since 10.9.0 Introduced.

VisualAttributeTermMeta::save_term_visual_by_type() code WC 10.9.1

public static function save_term_visual_by_type( int $term_id, string $type, string $color = '', int $image_id = 0 ): void {
	if ( self::TYPE_IMAGE === $type ) {
		self::save_term_visual( $term_id, '', $image_id );
		return;
	}

	self::save_term_visual( $term_id, $color, 0 );
}