WC_Brands::rest_api_maybe_set_brands
Maybe set brands when requesting PUT /products/<id>.
Метод класса: WC_Brands{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WC_Brands = new WC_Brands(); $WC_Brands->rest_api_maybe_set_brands( $post, $request );
- $post(WP_Post) (обязательный)
- Post object.
- $request(WP_REST_Request) (обязательный)
- Request object.
Список изменений
| С версии 9.4.0 | Введена. |
Код WC_Brands::rest_api_maybe_set_brands() WC Brands::rest api maybe set brands WC 10.3.6
public function rest_api_maybe_set_brands( $post, $request ) {
if ( isset( $request['brands'] ) && is_array( $request['brands'] ) ) {
$terms = array_map( 'absint', $request['brands'] );
wp_set_object_terms( $post->ID, $terms, 'product_brand' );
}
}