WooCommerce: Limit the fields returned in the “Update a Product” API

Is it possible to limit the fields returned in a WooCommerce POST “Update Multiple Products”? By default the API returns all the fields from each product updated. I’d like to reduce the size of the JSON returned.

The API documentation states “You may limit the fields returned in the response using the fields parameter”. However, the example is for GET /wc-api/v3/products

Read More

I need to limit the fields for POST /wc-api/v3/products/bulk

I’ve tried appending the fields parameter to the URL, but it doesn’t work (the parameter is ignored and all product fields are returned).

My URL looks like the following:
https://www.mywoocommercestore.com/wc-api/v3/products/bulk?fields=id,price,regular_price,sale_price,stock_quantity,error

Related posts

1 comment

  1. If you have access to the site where WooCommerce is installed then you can make use of woocommerce_api_products_bulk_response filter and modify the output.

    Add the following code to theme’s functions.php file

    add_filter( 'woocommerce_api_products_bulk_response', 'custom_woocommerce_api_products_bulk_response' );
    
    function custom_woocommerce_api_products_bulk_response( $products ) {
    
        // $products is an array containing all the data about the products
        // that were created or updated. Write your logic to remove unwanted fields
    
        return $products;
    }
    

Comments are closed.