Automattic\WooCommerce\Internal\StockNotifications

Notification::get_product_formatted_variation_list │ public │ WC 1.0

Retrieves the formatted attributes of the product based on the notification's posted attributes.

Wrapper of the wc_get_formatted_variation function.

Метод класса: Notification{}

Хуков нет.

Возвращает

string.

Использование

$Notification = new Notification();
$Notification->get_product_formatted_variation_list( $flat );
$flat(true|false)
Flatten the list.
По умолчанию: false

Код Notification::get_product_formatted_variation_list() WC 11.3.0

public function get_product_formatted_variation_list( bool $flat = false ) {

	$product = $this->get_product();
	if ( ! $product instanceof \WC_Product_Variation ) {
		return '';
	}

	$attributes = $this->get_variation_attributes_with_posted_data( $product );
	if ( empty( $attributes ) ) {
		return '';
	}

	$attrs = array();
	foreach ( $attributes as $key => $value ) {

		if ( 0 === strpos( $key, 'attribute_pa_' ) ) {
			$attrs[ str_replace( 'attribute_', '', $key ) ] = $value;
		} else {
			// By pass converting global product attributes.
			$attrs[ wc_attribute_label( str_replace( 'attribute_', '', $key ), $product ) ] = $value;
		}
	}

	$formatted_variation_list = wc_get_formatted_variation( $attrs, $flat, true, true );

	return $formatted_variation_list;
}