WC_REST_Products_V2_Controller::get_default_attributes()
Get default attributes.
Метод класса: WC_REST_Products_V2_Controller{}
Хуков нет.
Возвращает
Массив
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_default_attributes( $product );
- $product(WC_Product) (обязательный)
- Product instance.
Код WC_REST_Products_V2_Controller::get_default_attributes() WC REST Products V2 Controller::get default attributes WC 8.7.0
protected function get_default_attributes( $product ) { $default = array(); if ( $product->is_type( 'variable' ) ) { foreach ( array_filter( (array) $product->get_default_attributes(), 'strlen' ) as $key => $value ) { if ( 0 === strpos( $key, 'pa_' ) ) { $default[] = array( 'id' => wc_attribute_taxonomy_id_by_name( $key ), 'name' => $this->get_attribute_taxonomy_name( $key, $product ), 'option' => $value, ); } else { $default[] = array( 'id' => 0, 'name' => $this->get_attribute_taxonomy_name( $key, $product ), 'option' => $value, ); } } } return $default; }