WC_Brands::rest_api_maybe_set_brands()
Maybe set brands when requesting PUT /products/<id>.
Method of the class: WC_Brands{}
No Hooks.
Return
null
. Nothing (null).
Usage
$WC_Brands = new WC_Brands(); $WC_Brands->rest_api_maybe_set_brands( $post, $request );
- $post(WP_Post) (required)
- Post object
- $request(WP_REST_Request) (required)
- Request object
Changelog
Since 9.4.0 | Introduced. |
WC_Brands::rest_api_maybe_set_brands() WC Brands::rest api maybe set brands code WC 9.5.1
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' ); } }