6 things you can do with CoCart Products

If you have previously tried WooCommerce REST-API to retrieve products, you will have found that it has a few limitations and some parameters don’t provide options designed for frontend purposes.

Order By

One of the top things that is important when retrieving products is the order.

Here are the possible options you can order products by that the WooCommerce REST-API does not offer.

  • alphabetical – Products return alphabetical
  • reverse_alpha – Products return alphabetical in reverse
  • by_stock – Products return in order by stock amount
  • review_count – Products return in order of review count
  • on_sale_first – Products return in order of products on sale first
  • featured_first – Products return in order of featured first
  • price_asc – Products return in order of price in ascending order
  • price_desc – Products return in order of price in descending order
  • sales – Products return in order of total sales
  • rating – Products return in order of average review rating
curl -X GET https://wp-demo.cocart.xyz/wp-json/cocart/v1/products?orderby=price_desc \
  -H "Content-Type: application/json" \

Show Reviews

One cool thing you can do is retrieve the product reviews along with the product details for each product or an individual product without requesting them later.

Set show_reviews as true as a parameter in your request.

curl -X GET https://wp-demo.cocart.xyz/wp-json/cocart/v1/products?show_reviews=true \
  -H "Content-Type: application/json" \

Customer’s email address and location details are not returned.

Return all Variations

This particular option was requested by many but is also one that can produce a slow query response depending on how it is used and how many variations a particular product has.

Set return_variations as true as a parameter in your request and whether your returning many products or a single variable product, all variations and it’s details will return.

curl -X GET https://wp-demo.cocart.xyz/wp-json/cocart/v1/products?return_variations=true \
  -H "Content-Type: application/json" \

Get the right image size

In the WooCommerce REST-API, products only return the original image size uploaded for the product. That can be too much bandwidth depending on the filesize of the image.

With CoCart ┬ĘProducts, you can get the image size of your choosing for the featured product image or any in the product gallery. All WordPress image sizes including the custom sizes WooCommerce create are returned and any custom image sizes that you register personally.

All image sizes return correctly if that particular size has the image resized. If the image size was registered after the image was uploaded then you will have to use regenerate thumbnails plugin or other of your choosing in order for the size to return correctly.

Here are the sizes available:

  • thumbnail
  • medium
  • medium_large
  • large
  • woocommerce_thumbnail
  • woocommerce_single
  • woocommerce_gallery_thumbnail
  • shop_catalog
  • shop_single
  • shop_thumbnail
  • full

Filter by Category or Tag

While this not new, the difference in CoCart Products REST-API is that you filter products by the category or tag slug instead of the ID, making it easier to remember what to filter the products by… for example “tshirts” instead “25”.

curl -X GET https://wp-demo.cocart.xyz/wp-json/cocart/v1/products?category=tshirts \
  -H "Content-Type: application/json" \

Submit Product Review

WooCommerce REST-API provides the same only it allows administrator’s to submit. CoCart Products allows customers to submit a review. This is the only feature that requires authentication.

curl -X POST https://wp-demo.cocart.xyz/wp-json/cocart/v1/products/reviews \
    -u username:password \
    -H "Content-Type: application/json" \
    -d '{
      "product_id": 329,
      "review": "Naughty Dog has done it again. This game is sick. I look forward to playing this over and over again like I did the first one. 5 stars does not do it justice. Game of the year for sure.",
      "reviewer": "John Doe",
      "reviewer_email": "john.doe@example.com",
      "rating": 5

Want a feature for CoCart Products? Send in your request.