NAV
cURL Node.js jQuery PHP WP API

Introduction

GitHub Mark Logo Edit on GitHub

CoCart Products allows you to view all and access specific products, attributes, categories, tags and product reviews without authentication required. Only details of the products that customers need to know are returned.

API Versions

The current WordPress REST API integration for CoCart Products is version v1 which takes a first-order position in the endpoints.

The following table shows API versions present in each major version of CoCart Products:

API Version CoCart Version WC Version WP Version PHP Version
v1 2.0.x or later 4.0.x or later 5.2 or later 7.0 or later

Requirements

To use the latest version of the CoCart Products you must be using:

Request/Response Format

The default response format is in JSON. Requests with a message-body use plain JSON to set or update resource attributes. Successful requests will return a 200 OK HTTP status.

Some general information about response:

Body Types

There are different types of body types when making a request. Make sure when using either of these body types that you have the correct Content-Type for the header.

Body Type Content-Type
form-data  application/json
raw  application/json
x-www-form-urlencoded application/x-www-form-urlencoded

I personally find using raw works best if you are passing an array of data for a variation or cart_item_data.

Errors

Occasionally you might encounter errors when accessing the REST API. Here are the possible types:

Error Code Error Type
400 Bad Request Invalid request, e.g. using an unsupported HTTP method
401 Unauthorized Authentication or permission error, e.g. incorrect login
403 Forbidden Not allowed to process this action or have permission.
404 Not Found Requests to resources that don't exist or are missing
405 Method Not Allowed A request method is not supported for the requested resource.
500 Internal Server Error Server error

WP REST API error example

{
  "code": "rest_no_route",
  "message": "No route was found matching the URL and request method",
  "data": {
    "status": 404
  }
}

CoCart error example

{
  "code": "cocart_clear_cart_failed",
  "message": "Clearing the cart failed!",
  "data": {
    "status": 500
  }
}

Errors return both an appropriate HTTP status code and response object which contains a code, message and data attribute.

Getting Started

GitHub Mark Logo Edit on GitHub

Install and Activate

If you have a copy of the plugin as a zip file, you can manually upload it and install it through the Plugins admin screen.

  1. Navigate to Plugins > Add New.
  2. Click the Upload Plugin button at the top of the screen.
  3. Select the zip file from your local filesystem.
  4. Click the Install Now button.
  5. When installation is complete, you’ll see “Plugin installed successfully.” Click the Activate Plugin button at the bottom of the page.

List of server requirements.

For the most stable and performance experience, it’s recommended that you use the most recent version of the plugin. You can get the latest releases here.

Of course, as new features are in development, feel free to check out the latest develop branch or check out any other release.

GitHub - Download / Clone Plugin

CoCart Products is available on GitHub: https://github.com/co-cart/cocart-products

The plugin is hosted there on a public GitHub repository in order to better facilitate community contributions from developers and users alike.

You can download the latest release or clone the plugin from GitHub.

Add the downloaded/cloned plugin to your WordPress plugin directory. On a typical WordPress install, this is located at /wp-content/plugins.

Error Responses

GitHub Mark Logo Edit on GitHub

You might encounter an error when using CoCart Products. These error responses explain what might have happened.

Error Status Error Response
cocart_product_invalid_id Invalid product ID.
cocart_review_invalid_id Invalid review ID.
cocart_cannot_list_resources Sorry, you cannot list resources.
cocart_cannot_view_resource Sorry, you cannot view this resource.
cocart_taxonomy_invalid Taxonomy does not exist.
cocart_term_invalid Term does not exist.
cocart_cannot_list_attributes Sorry, you cannot list attributes.
cocart_cannot_view_attribute Sorry, you cannot view this attribute.
cocart_attribute_invalid Attribute does not exist.
cocart_cannot_list_reviews Sorry, you cannot list reviews.
cocart_cannot_view_review Sorry, you cannot view this review.
cocart_cannot_create Sorry, you are not allowed to create reviews.
cocart_review_exists Cannot create existing product review.
cocart_review_content_invalid Invalid review content.
cocart_comment_author Product review field exceeds maximum length allowed.
cocart_comment_content Product review field exceeds maximum length allowed.
cocart_review_failed_create Creating product review failed.

Products

GitHub Mark Logo Edit on GitHub

The products API allows you to view individual or a batch of products. Below lists the global product attributes each product returns. Certain product types will provide additional attributes so it's important that when developing, you check that those product attributes exist before using them.

Product attributes

Attribute Type Description
id integer Unique identifier for the product.
name string Product name.
slug string Product slug.
permalink string Product URL.
date_created date-time The date the product was created, in the site's timezone.
date_created_gmt date-time The date the product was created, as GMT.
date_modified date-time The date the product was last modified, in the site's timezone.
date_modified_gmt date-time The date the product was last modified, as GMT.
type string Product type.
featured boolean Identifies if the product is featured.
catalog_visibility string Catalogue visibility.
description string Product description.
short_description string Product short description.
sku string Unique sku identifier for the product.
price string Current product price.
regular_price string Product regular price.
sale_price string Product sale price.
date_on_sale_from date-time Start date of sale price, in the site's time zone.
date_on_sale_from_gmt date-time Start date of sale price, as GMT.
date_on_sale_to date-time End date of sale price, in the site's time zone.
date_on_sale_to_gmt date-time End date of sale price, as GMT.
on_sale boolean Identifies if the product is on sale.
purchasable boolean Identifies if the product can be bought.
total_sales integer Amount of sales.
virtual boolean Identifies if the product is virtual.
downloadable boolean Identifies if the product is downloadable.
external_url string Product external URL.
button_text string Product external button text. Only used for external products.
manage_stock boolean Identifies the stock management at product level.
stock_quantity integer Stock quantity.
stock_status string Stock status of the product.
backorders string Returns the backorder status.
backorders_allowed boolean Identifies if backorders are allowed.
backordered boolean Identifies if the product is on backordered.
sold_individually boolean Identifies if only one of the item can be bought in a single order.
weight string Product weight.
dimensions object Product dimensions. See Product - Dimensions properties
shipping_required boolean Identifies if the product needs to be shipped.
reviews_allowed boolean Identifies if the product allows reviews.
average_rating string Reviews average rating.
rating_count integer Amount of reviews that the product have.
reviews array Returns product reviews if queried.
review_count integer Amount of reviews that the product have.
related_ids array List of related products IDs.
upsell_ids array List of up-sell products IDs.
cross_sell_ids array List of cross-sell products IDs.
parent_id integer Product parent ID.
categories array List of categories. See Product - Categories properties
tags array List of tags. See Product - Tags properties
images array List of images. See Product - Images properties
attributes array List of attributes. See Product - Attributes properties
default_attributes array Defaults variation attributes. See Product - Default attributes properties
variations array List of variations IDs or details of each variation.
grouped_products array List of grouped products ID.
menu_order integer Menu order, used to custom sort products.
meta_data array Meta data. See Product - Meta data properties
subscription array Subscription data. See Product - Subscription properties Only returns for subscription products.

Product - Dimensions properties

Attribute Type Description
length string Product length.
width string Product width.
height string Product height.

Product - Categories properties

Attribute Type Description
id integer Category ID.
name string Category name.
slug string Category slug.

Product - Tags properties

Attribute Type Description
id integer Tag ID.
name string Tag name.
slug string Tag slug.

Product - Images properties

Attribute Type Description
id integer Image ID.
date_created date-time The date the image was created, in the site's timezone.
date_created_gmt date-time The date the image was created, as GMT.
date_modified date-time The date the image was last modified, in the site's timezone.
date_modified_gmt date-time The date the image was last modified, as GMT.
src array All registered image sizes for the image are returned.
name string Image name.
alt string Image alternative text.

Product - Attributes properties

Attribute Type Description
id integer Attribute ID.
name string Attribute name.
position integer Attribute position.
visible boolean Identifies if the attribute is visible on the "Additional information" tab in the product's page.
variation boolean Identifies if the attribute can be used as a variation.
options array List of available term names of the attribute.

Product - Default attributes properties

Attribute Type Description
id integer Attribute ID.
name string Attribute name.
option string Selected attribute term name.

Product - Meta data properties

Attribute Type Description
id integer Meta ID.
key string Meta key.
value string Meta value.

Product - Subscription properties

These attributes are only returned for a subscription product.

Attribute Type Description
price string Subscription price.
period string Subscription period.
period_interval string Subscription period interval.
length string Subscription length.
trial_period string Subscription trial period.
trial_length string Subscription trial length.
sign_up_fee string Subscription sign up fee.
one_time_shipping string Subscription one time shipping.
limit string Subscription limit.
regular_price string Subscription regular price. Returns for variations only.

Retrieve a product

This API lets you retrieve and view a specific product by ID.

HTTP request

GET
/wp-json/cocart/v1/products/<id>
curl -X GET https://example.com/wp-json/cocart/v1/products/329 \
  -H "Content-Type: application/json" \
CoCart.get("products/329")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products/329",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products/329",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products/329' );
$body = wp_remote_retrieve_body( $response );
{
  "id": 329,
  "name": "The Last of Us Part 2 - Ellie Edition",
  "slug": "the-last-of-us-part-2-ellie-edition",
  "permalink": "https://example.com/product/the-last-of-us-part-2-ellie-edition/",
  "date_created": "2020-02-12T17:01:46",
  "date_created_gmt": "2020-02-12T16:01:46",
  "date_modified": "2020-02-12T17:01:46",
  "date_modified_gmt": "2020-02-12T16:01:46",
  "type": "simple",
  "featured": false,
  "catalog_visibility": "visible",
  "description": "",
  "short_description": "",
  "sku": "",
  "price": "£180.00",
  "regular_price": "£180.00",
  "sale_price": "",
  "date_on_sale_from": null,
  "date_on_sale_from_gmt": null,
  "date_on_sale_to": null,
  "date_on_sale_to_gmt": null,
  "on_sale": false,
  "purchasable": true,
  "total_sales": 0,
  "virtual": false,
  "downloadable": false,
  "external_url": "",
  "button_text": "",
  "manage_stock": false,
  "stock_quantity": null,
  "in_stock": true,
  "stock_status": "instock",
  "backorders": "no",
  "backorders_allowed": false,
  "backordered": false,
  "sold_individually": false,
  "weight": "",
  "dimensions": {
    "length": "",
    "width": "",
    "height": ""
  },
  "shipping_required": true,
  "reviews_allowed": false,
  "average_rating": "0",
  "rating_count": 0,
  "review_count": 0,
  "rating_html": "",
  "reviews": [],
  "related_ids": [],
  "upsell_ids": [],
  "cross_sell_ids": [],
  "parent_id": 0,
  "categories": [
    {
      "id": 42,
      "name": "Video Games",
      "slug": "video-games"
    }
  ],
  "tags": [],
  "images": [
    {
      "id": 330,
      "date_created": "2020-02-12T18:00:39",
      "date_created_gmt": "2020-02-12T16:00:39",
      "date_modified": "2020-02-12T18:00:39",
      "date_modified_gmt": "2020-02-12T16:00:39",
      "src": {
        "thumbnail": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-150x150.jpg",
        "medium": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-169x300.jpg",
        "medium_large": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-768x1365.jpg",
        "large": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-576x1024.jpg",
        "1536x1536": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-864x1536.jpg",
        "2048x2048": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A.jpg",
        "woocommerce_thumbnail": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-324x324.jpg",
        "woocommerce_single": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-416x740.jpg",
        "woocommerce_gallery_thumbnail": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-100x100.jpg",
        "shop_catalog": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-324x324.jpg",
        "shop_single": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-416x740.jpg",
        "shop_thumbnail": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-100x100.jpg",
        "full": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A.jpg",
        "custom": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A.jpg"
      },
      "name": "TLOU2_WP_DUALITY_1080X1920_002A",
      "alt": "",
      "position": 0
    }
  ],
  "attributes": [],
  "default_attributes": [],
  "variations": [],
  "grouped_products": [],
  "menu_order": 0,
  "meta_data": [],
  "yoast_seo_meta": {
    "title": null,
    "description": null,
    "focus_keyword": null,
    "content_score": null,
    "linkdex": null,
    "primary_product_category": null
  },
  "_links": {
    "self": [
      {
        "permalink": "https://example.com/product/the-last-of-us-part-2-ellie-edition/",
        "href": "https://example.com/wp-json/cocart/v1/products/329"
      }
    ],
    "collection": [
      {
        "permalink": "https://example.com/",
        "href": "https://example.com/wp-json/cocart/v1/products"
      }
    ]
  }
}

List all products

This API helps you to view all the products.

HTTP request

GET
/wp-json/cocart/v1/products
curl -X GET https://example.com/wp-json/cocart/v1/products \
  -H "Content-Type: application/json" \
CoCart.get("products")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products' );
$body = wp_remote_retrieve_body( $response );
[
  {
    "id": 329,
    "name": "The Last of Us Part 2 - Ellie Edition",
    "slug": "the-last-of-us-part-2-ellie-edition",
    "permalink": "https://example.com/product/the-last-of-us-part-2-ellie-edition/",
    "date_created": "2020-02-12T17:01:46",
    "date_created_gmt": "2020-02-12T16:01:46",
    "date_modified": "2020-02-12T17:01:46",
    "date_modified_gmt": "2020-02-12T16:01:46",
    "type": "simple",
    "featured": false,
    "catalog_visibility": "visible",
    "description": "",
    "short_description": "",
    "sku": "",
    "price": "£180.00",
    "regular_price": "£180.00",
    "sale_price": "",
    "date_on_sale_from": null,
    "date_on_sale_from_gmt": null,
    "date_on_sale_to": null,
    "date_on_sale_to_gmt": null,
    "on_sale": false,
    "purchasable": true,
    "total_sales": 0,
    "virtual": false,
    "downloadable": false,
    "external_url": "",
    "button_text": "",
    "manage_stock": false,
    "stock_quantity": null,
    "in_stock": true,
    "stock_status": "instock",
    "backorders": "no",
    "backorders_allowed": false,
    "backordered": false,
    "sold_individually": false,
    "weight": "",
    "dimensions": {
      "length": "",
      "width": "",
      "height": ""
    },
    "shipping_required": true,
    "reviews_allowed": false,
    "average_rating": "0",
    "rating_count": 0,
    "review_count": 0,
    "rating_html": "",
    "reviews": [],
    "related_ids": [],
    "upsell_ids": [],
    "cross_sell_ids": [],
    "parent_id": 0,
    "categories": [
      {
        "id": 42,
        "name": "Video Games",
        "slug": "video-games"
      }
    ],
    "tags": [],
    "images": [
      {
        "id": 330,
        "date_created": "2020-02-12T18:00:39",
        "date_created_gmt": "2020-02-12T16:00:39",
        "date_modified": "2020-02-12T18:00:39",
        "date_modified_gmt": "2020-02-12T16:00:39",
        "src": {
          "thumbnail": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-150x150.jpg",
          "medium": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-169x300.jpg",
          "medium_large": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-768x1365.jpg",
          "large": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-576x1024.jpg",
          "1536x1536": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-864x1536.jpg",
          "2048x2048": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A.jpg",
          "woocommerce_thumbnail": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-324x324.jpg",
          "woocommerce_single": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-416x740.jpg",
          "woocommerce_gallery_thumbnail": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-100x100.jpg",
          "shop_catalog": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-324x324.jpg",
          "shop_single": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-416x740.jpg",
          "shop_thumbnail": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A-100x100.jpg",
          "full": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A.jpg",
          "custom": "https://example.com/wp-content/uploads/2020/02/TLOU2_WP_DUALITY_1080X1920_002A.jpg"
        },
        "name": "TLOU2_WP_DUALITY_1080X1920_002A",
        "alt": "",
        "position": 0
      }
    ],
    "attributes": [],
    "default_attributes": [],
    "variations": [],
    "grouped_products": [],
    "menu_order": 0,
    "meta_data": [],
    "yoast_seo_meta": {
      "title": null,
      "description": null,
      "focus_keyword": null,
      "content_score": null,
      "linkdex": null,
      "primary_product_category": null
    },
    "_links": {
      "self": [
        {
          "permalink": "https://example.com/product/the-last-of-us-part-2-ellie-edition/",
          "href": "https://example.com/wp-json/cocart/v1/products/329"
        }
      ],
      "collection": [
        {
          "permalink": "https://example.com/",
          "href": "https://example.com/wp-json/cocart/v1/products"
        }
      ]
    }
  },
  {
    "id": 185,
    "name": "WordPress Pennant",
    "slug": "wordpress-pennant",
    "permalink": "https://example.com/product/wordpress-pennant/",
    "date_created": "2020-01-24T14:55:56",
    "date_created_gmt": "2020-01-24T13:55:56",
    "date_modified": "2020-01-24T14:56:40",
    "date_modified_gmt": "2020-01-24T13:56:40",
    "type": "external",
    "featured": false,
    "catalog_visibility": "visible",
    "description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
    "short_description": "This is an external product.",
    "sku": "wp-pennant",
    "price": "£11.05",
    "regular_price": "£11.05",
    "sale_price": "",
    "date_on_sale_from": null,
    "date_on_sale_from_gmt": null,
    "date_on_sale_to": null,
    "date_on_sale_to_gmt": null,
    "on_sale": false,
    "purchasable": false,
    "total_sales": 0,
    "virtual": false,
    "downloadable": false,
    "external_url": "https://mercantile.wordpress.org/product/wordpress-pennant/",
    "button_text": "Buy on the WordPress swag store!",
    "manage_stock": false,
    "stock_quantity": null,
    "in_stock": true,
    "stock_status": "instock",
    "backorders": "no",
    "backorders_allowed": false,
    "backordered": false,
    "sold_individually": false,
    "weight": "",
    "dimensions": {
      "length": "",
      "width": "",
      "height": ""
    },
    "shipping_required": true,
    "reviews_allowed": true,
    "average_rating": "0",
    "rating_count": 0,
    "review_count": 0,
    "rating_html": "",
    "reviews": [],
    "related_ids": [],
    "upsell_ids": [],
    "cross_sell_ids": [],
    "parent_id": 0,
    "categories": [
      {
        "id": 29,
        "name": "Decor",
        "slug": "decor"
      }
    ],
    "tags": [],
    "images": [
      {
        "id": 208,
        "date_created": "2020-01-24T15:56:39",
        "date_created_gmt": "2020-01-24T13:56:39",
        "date_modified": "2020-01-24T15:56:39",
        "date_modified_gmt": "2020-01-24T13:56:39",
        "src": {
          "thumbnail": "https://example.com/wp-content/uploads/2020/01/pennant-1-150x150.jpg",
          "medium": "https://example.com/wp-content/uploads/2020/01/pennant-1-300x300.jpg",
          "medium_large": "https://example.com/wp-content/uploads/2020/01/pennant-1-768x768.jpg",
          "large": "https://example.com/wp-content/uploads/2020/01/pennant-1.jpg",
          "1536x1536": "https://example.com/wp-content/uploads/2020/01/pennant-1.jpg",
          "2048x2048": "https://example.com/wp-content/uploads/2020/01/pennant-1.jpg",
          "woocommerce_thumbnail": "https://example.com/wp-content/uploads/2020/01/pennant-1-324x324.jpg",
          "woocommerce_single": "https://example.com/wp-content/uploads/2020/01/pennant-1-416x416.jpg",
          "woocommerce_gallery_thumbnail": "https://example.com/wp-content/uploads/2020/01/pennant-1-100x100.jpg",
          "shop_catalog": "https://example.com/wp-content/uploads/2020/01/pennant-1-324x324.jpg",
          "shop_single": "https://example.com/wp-content/uploads/2020/01/pennant-1-416x416.jpg",
          "shop_thumbnail": "https://example.com/wp-content/uploads/2020/01/pennant-1-100x100.jpg",
          "full": "https://example.com/wp-content/uploads/2020/01/pennant-1.jpg",
          "custom": "https://example.com/wp-content/uploads/2020/01/pennant-1.jpg"
        },
        "name": "pennant-1.jpg",
        "alt": "",
        "position": 0
      }
    ],
    "attributes": [],
    "default_attributes": [],
    "variations": [],
    "grouped_products": [],
    "menu_order": 0,
    "meta_data": [],
    "yoast_seo_meta": {
      "title": null,
      "description": null,
      "focus_keyword": null,
      "content_score": null,
      "linkdex": null,
      "primary_product_category": null
    },
    "_links": {
      "self": [
        {
          "permalink": "https://example.com/product/wordpress-pennant/",
          "href": "https://example.com/wp-json/cocart/v1/products/185"
        }
      ],
      "collection": [
        {
          "permalink": "https://example.com/",
          "href": "https://example.com/wp-json/cocart/v1/products"
        }
      ]
    }
  }
]

Available parameters

Parameter Type Description
page integer Current page of the collection. Default is 1.
per_page integer Maximum number of items to be returned in result set. Default is 10.
search string Limit results to those matching a string.
after string Limit response to resources published after a given ISO8601 compliant date.
before string Limit response to resources published before a given ISO8601 compliant date.
exclude array Ensure result set excludes specific IDs.
include array Limit result set to specific ids.
offset integer Offset the result set by a specific number of items.
order string Order sort attribute ascending or descending. Options: asc and desc. Default is desc.
orderby string Sort collection by object attribute. Options: date, id, include, title, slug alphabetical, reverse_alpha, by_stock, review_count, on_sale_first, featured_first, price_asc, price_desc, sales and rating. Default is your WooCommerce default catalogue setting.
parent array Limit result set to those of particular parent IDs.
parent_exclude array Limit result set to all items except those of a particular parent ID.
slug string Limit result set to products with a specific slug.
type string Limit result set to products assigned a specific type. Options: simple, grouped, external, variable, subscription and variable-subscription.
sku string Limit result set to products with a specific SKU.
featured boolean Limit result set to featured products.
category string Limit result set to products assigned a specific category ID.
tag string Limit result set to products assigned a specific tag ID.
attribute string Limit result set to products with a specific attribute.
attribute_term string Limit result set to products with a specific attribute term ID (required an assigned attribute).
on_sale boolean Limit result set to products on sale.
min_price string Limit result set to products based on a minimum price.
max_price string Limit result set to products based on a maximum price.
stock_status string Limit result set to products with specified stock status. Options: instock, outofstock and onbackorder.
show_reviews boolean Set to true to return product reviews.
return_variations boolean Set to true to return the variations of variable products.

Product variations

GitHub Mark Logo Edit on GitHub

The product variations API allows you to view individual or a batch of product variations.

Product variation attributes

Attribute Type Description
id integer Unique identifier for the variation.
date_created date-time The date the variation was created, in the site's timezone.
date_created_gmt date-time The date the variation was created, as GMT.
date_modified date-time The date the variation was last modified, in the site's timezone.
date_modified_gmt date-time The date the variation was last modified, as GMT.
description string Variation description.
permalink string Variation URL.
sku string Unique identifier.
price string Current variation price.
regular_price string Variation regular price.
sale_price string Variation sale price.
date_on_sale_from date-time Start date of sale price, in the site's timezone.
date_on_sale_from_gmt date-time Start date of sale price, as GMT.
date_on_sale_to date-time End date of sale price, in the site's timezone.
date_on_sale_to_gmt date-time End date of sale price, as GMT.
on_sale boolean Identifies if the variation is on sale.
status string Variation status.
purchasable boolean Identifies if the product can be bought.
virtual boolean Identifies if the variation is a virtual product.
downloadable boolean Identifies if the variation is a downloadable product.
manage_stock boolean Identifies the stock management at product level.
stock_quantity integer Stock quantity.
stock_status string Controls the stock status of the product.
backorders string Returns the backorder status.
backorders_allowed boolean Identifies if backorders are allowed.
backordered boolean Identifies if the product is on backordered.
weight string Variation weight.
dimensions object Variation dimensions. See Product variation - Dimensions properties
image object Variation image data. See Product variation - Image properties
attributes array List of attributes. See Product variation - Attributes properties
menu_order integer Menu order, used to custom sort products.
meta_data array Meta data. See Product variation - Meta data properties

Product variation - Dimensions properties

Attribute Type Description
length string Variation length.
width string Variation width.
height string Variation height.

Product variation - Image properties

Attribute Type Description
id integer Image ID.
date_created date-time The date the image was created, in the site's timezone.
date_created_gmt date-time The date the image was created, as GMT.
date_modified date-time The date the image was last modified, in the site's timezone.
date_modified_gmt date-time The date the image was last modified, as GMT.
src array All registered image sizes for the image are returned.
name string Image name.
alt string Image alternative text.

Product variation - Attributes properties

Attribute Type Description
id integer Attribute ID.
name string Attribute name.
option string Selected attribute term name.

Product variation - Meta data properties

Attribute Type Description
id integer Meta ID.
key string Meta key.
value string Meta value.

Retrieve a product variation

This API lets you retrieve and view a specific product variation by ID.

HTTP request

GET
/wp-json/cocart/v1/products/<product_id>/variations/<id>
curl -X GET https://example.com/wp-json/cocart/v1/products/162/variations/176 \
  -H "Content-Type: application/json" \
CoCart.get("products/162/variations/176")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products/162/variations/176",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products/162/variations/176",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products/162/variations/176' );
$body = wp_remote_retrieve_body( $response );
{
  "id": 176,
  "date_created": "2020-01-24T14:55:54",
  "date_created_gmt": "2020-01-24T13:55:54",
  "date_modified": "2020-01-24T14:56:30",
  "date_modified_gmt": "2020-01-24T13:56:30",
  "description": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.</p>\n",
  "permalink": "https://example.com/product/v-neck-t-shirt/?attribute_pa_color=red",
  "sku": "woo-vneck-tee-red",
  "price": "20",
  "regular_price": "20",
  "sale_price": "",
  "date_on_sale_from": null,
  "date_on_sale_from_gmt": null,
  "date_on_sale_to": null,
  "date_on_sale_to_gmt": null,
  "on_sale": false,
  "purchasable": true,
  "virtual": false,
  "downloadable": false,
  "manage_stock": false,
  "stock_quantity": null,
  "stock_status": "instock",
  "backorders": "no",
  "backorders_allowed": false,
  "backordered": false,
  "weight": "",
  "dimensions": {
    "length": "",
    "width": "",
    "height": ""
  },
  "image": {
    "id": 187,
    "date_created": "2020-01-24T15:55:58",
    "date_created_gmt": "2020-01-24T13:55:58",
    "date_modified": "2020-01-24T15:55:58",
    "date_modified_gmt": "2020-01-24T13:55:58",
    "src": {
      "thumbnail": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-150x150.jpg",
      "medium": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-300x300.jpg",
      "medium_large": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-768x767.jpg",
      "large": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2.jpg",
      "1536x1536": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2.jpg",
      "2048x2048": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2.jpg",
      "woocommerce_thumbnail": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-324x324.jpg",
      "woocommerce_single": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-416x415.jpg",
      "woocommerce_gallery_thumbnail": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-100x100.jpg",
      "shop_catalog": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-324x324.jpg",
      "shop_single": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-416x415.jpg",
      "shop_thumbnail": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-100x100.jpg",
      "full": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2.jpg",
      "custom": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2.jpg"
    },
    "name": "vneck-tee-2.jpg",
    "alt": ""
  },
  "attributes": {
    "attribute_pa_color": {
      "id": 1,
      "name": "Color",
      "option": "Red"
    }
  },
  "menu_order": 0,
  "meta_data": [],
  "_links": {
    "self": [
      {
        "href": "https://example.com/wp-json/cocart/v1/products/162/variations/176"
      }
    ],
    "collection": [
      {
        "href": "https://example.com/wp-json/cocart/v1/products/162/variations"
      }
    ],
    "parent_product": [
      {
        "permalink": "https://example.com/product/v-neck-t-shirt/",
        "href": "https://example.com/wp-json/cocart/v1/products/162"
      }
    ]
  }
}

List all product variations

This API helps you to view all the product variations.

HTTP request

GET
/wp-json/cocart/v1/products/<product_id>/variations
curl -X GET https://example.com/wp-json/cocart/v1/products/22/variations \
  -H "Content-Type: application/json" \
CoCart.get("products/22/variations")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products/22/variations",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products/22/variations",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products/22/variations' );
$body = wp_remote_retrieve_body( $response );
[
  {
    "id": 176,
    "date_created": "2020-01-24T14:55:54",
    "date_created_gmt": "2020-01-24T13:55:54",
    "date_modified": "2020-01-24T14:56:30",
    "date_modified_gmt": "2020-01-24T13:56:30",
    "description": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.</p>\n",
    "permalink": "https://example.com/product/v-neck-t-shirt/?attribute_pa_color=red",
    "sku": "woo-vneck-tee-red",
    "price": "20",
    "regular_price": "20",
    "sale_price": "",
    "date_on_sale_from": null,
    "date_on_sale_from_gmt": null,
    "date_on_sale_to": null,
    "date_on_sale_to_gmt": null,
    "on_sale": false,
    "purchasable": true,
    "virtual": false,
    "downloadable": false,
    "manage_stock": false,
    "stock_quantity": null,
    "stock_status": "instock",
    "backorders": "no",
    "backorders_allowed": false,
    "backordered": false,
    "weight": "",
    "dimensions": {
      "length": "",
      "width": "",
      "height": ""
    },
    "image": {
      "id": 187,
      "date_created": "2020-01-24T15:55:58",
      "date_created_gmt": "2020-01-24T13:55:58",
      "date_modified": "2020-01-24T15:55:58",
      "date_modified_gmt": "2020-01-24T13:55:58",
      "src": {
        "thumbnail": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-150x150.jpg",
        "medium": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-300x300.jpg",
        "medium_large": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-768x767.jpg",
        "large": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2.jpg",
        "1536x1536": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2.jpg",
        "2048x2048": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2.jpg",
        "woocommerce_thumbnail": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-324x324.jpg",
        "woocommerce_single": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-416x415.jpg",
        "woocommerce_gallery_thumbnail": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-100x100.jpg",
        "shop_catalog": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-324x324.jpg",
        "shop_single": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-416x415.jpg",
        "shop_thumbnail": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2-100x100.jpg",
        "full": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2.jpg",
        "custom": "https://example.com/wp-content/uploads/2020/01/vneck-tee-2.jpg"
      },
      "name": "vneck-tee-2.jpg",
      "alt": ""
    },
    "attributes": {
      "attribute_pa_color": {
        "id": 1,
        "name": "Color",
        "option": "Red"
      }
    },
    "menu_order": 0,
    "meta_data": [],
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/162/variations/176"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/162/variations"
        }
      ],
      "parent_product": [
        {
          "permalink": "https://example.com/product/v-neck-t-shirt/",
          "href": "https://example.com/wp-json/cocart/v1/products/162"
        }
      ]
    }
  },
  {
    "id": 177,
    "date_created": "2020-01-24T14:55:54",
    "date_created_gmt": "2020-01-24T13:55:54",
    "date_modified": "2020-01-24T14:56:31",
    "date_modified_gmt": "2020-01-24T13:56:31",
    "description": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.</p>\n",
    "permalink": "https://example.com/product/v-neck-t-shirt/?attribute_pa_color=green",
    "sku": "woo-vneck-tee-green",
    "price": "20",
    "regular_price": "20",
    "sale_price": "",
    "date_on_sale_from": null,
    "date_on_sale_from_gmt": null,
    "date_on_sale_to": null,
    "date_on_sale_to_gmt": null,
    "on_sale": false,
    "purchasable": true,
    "virtual": false,
    "downloadable": false,
    "manage_stock": false,
    "stock_quantity": null,
    "stock_status": "instock",
    "backorders": "no",
    "backorders_allowed": false,
    "backordered": false,
    "weight": "",
    "dimensions": {
      "length": "",
      "width": "",
      "height": ""
    },
    "image": {
      "id": 188,
      "date_created": "2020-01-24T15:55:59",
      "date_created_gmt": "2020-01-24T13:55:59",
      "date_modified": "2020-01-24T15:55:59",
      "date_modified_gmt": "2020-01-24T13:55:59",
      "src": {
        "thumbnail": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1-150x150.jpg",
        "medium": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1-300x300.jpg",
        "medium_large": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1-768x768.jpg",
        "large": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1.jpg",
        "1536x1536": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1.jpg",
        "2048x2048": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1.jpg",
        "woocommerce_thumbnail": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1-324x324.jpg",
        "woocommerce_single": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1-416x416.jpg",
        "woocommerce_gallery_thumbnail": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1-100x100.jpg",
        "shop_catalog": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1-324x324.jpg",
        "shop_single": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1-416x416.jpg",
        "shop_thumbnail": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1-100x100.jpg",
        "full": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1.jpg",
        "custom": "https://example.com/wp-content/uploads/2020/01/vnech-tee-green-1.jpg"
      },
      "name": "vnech-tee-green-1.jpg",
      "alt": ""
    },
    "attributes": {
      "attribute_pa_color": {
        "id": 1,
        "name": "Color",
        "option": "Green"
      }
    },
    "menu_order": 0,
    "meta_data": [],
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/162/variations/177"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/162/variations"
        }
      ],
      "parent_product": [
        {
          "permalink": "https://example.com/product/v-neck-t-shirt/",
          "href": "https://example.com/wp-json/cocart/v1/products/162"
        }
      ]
    }
  },
  {
    "id": 178,
    "date_created": "2020-01-24T14:55:54",
    "date_created_gmt": "2020-01-24T13:55:54",
    "date_modified": "2020-01-24T14:56:32",
    "date_modified_gmt": "2020-01-24T13:56:32",
    "description": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.</p>\n",
    "permalink": "https://example.com/product/v-neck-t-shirt/?attribute_pa_color=blue",
    "sku": "woo-vneck-tee-blue",
    "price": "15",
    "regular_price": "15",
    "sale_price": "",
    "date_on_sale_from": null,
    "date_on_sale_from_gmt": null,
    "date_on_sale_to": null,
    "date_on_sale_to_gmt": null,
    "on_sale": false,
    "purchasable": true,
    "virtual": false,
    "downloadable": false,
    "manage_stock": false,
    "stock_quantity": null,
    "stock_status": "instock",
    "backorders": "no",
    "backorders_allowed": false,
    "backordered": false,
    "weight": "",
    "dimensions": {
      "length": "",
      "width": "",
      "height": ""
    },
    "image": {
      "id": 189,
      "date_created": "2020-01-24T15:56:00",
      "date_created_gmt": "2020-01-24T13:56:00",
      "date_modified": "2020-01-24T15:56:00",
      "date_modified_gmt": "2020-01-24T13:56:00",
      "src": {
        "thumbnail": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1-150x150.jpg",
        "medium": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1-300x300.jpg",
        "medium_large": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1-768x768.jpg",
        "large": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1.jpg",
        "1536x1536": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1.jpg",
        "2048x2048": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1.jpg",
        "woocommerce_thumbnail": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1-324x324.jpg",
        "woocommerce_single": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1-416x416.jpg",
        "woocommerce_gallery_thumbnail": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1-100x100.jpg",
        "shop_catalog": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1-324x324.jpg",
        "shop_single": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1-416x416.jpg",
        "shop_thumbnail": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1-100x100.jpg",
        "full": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1.jpg",
        "custom": "https://example.com/wp-content/uploads/2020/01/vnech-tee-blue-1.jpg"
      },
      "name": "vnech-tee-blue-1.jpg",
      "alt": ""
    },
    "attributes": {
      "attribute_pa_color": {
        "id": 1,
        "name": "Color",
        "option": "Blue"
      }
    },
    "menu_order": 0,
    "meta_data": [],
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/162/variations/178"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/162/variations"
        }
      ],
      "parent_product": [
        {
          "permalink": "https://example.com/product/v-neck-t-shirt/",
          "href": "https://example.com/wp-json/cocart/v1/products/162"
        }
      ]
    }
  }
]

Available parameters

Parameter Type Description
page integer Current page of the collection. Default is 1.
per_page integer Maximum number of items to be returned in result set. Default is 10.
search string Limit results to those matching a string.
after string Limit response to resources published after a given ISO8601 compliant date.
before string Limit response to resources published before a given ISO8601 compliant date.
exclude array Ensure result set excludes specific IDs.
include array Limit result set to specific ids.
offset integer Offset the result set by a specific number of items.
order string Order sort attribute ascending or descending. Options: asc and desc. Default is desc.
orderby string Sort collection by object attribute. Options: date, id, include, title and slug. Default is your WooCommerce default catalogue setting.
parent array Limit result set to those of particular parent IDs.
parent_exclude array Limit result set to all items except those of a particular parent ID.
slug string Limit result set to products with a specific slug.
sku string Limit result set to products with a specific SKU.
on_sale boolean Limit result set to products on sale.
min_price string Limit result set to products based on a minimum price.
max_price string Limit result set to products based on a maximum price.
stock_status string Limit result set to products with specified stock status. Options: instock, outofstock and onbackorder.

Product attribute terms

GitHub Mark Logo Edit on GitHub

The product attribute terms API allows you to view individual attribute terms.

Product attribute term attributes

Attribute Type Description
id integer Unique identifier for the attribute terms.
name string Term name.
slug string An alphanumeric identifier for the attribute terms unique to its type.
description string HTML description of the attribute terms.
menu_order integer Menu order, used to custom sort the attribute terms.
count integer Number of published products for the attribute terms.

Retrieve an attribute term

This API lets you retrieve a product attribute term by ID.

GET
/wp-json/cocart/v1/products/attributes/<attribute_id>/terms/<id>
curl -X GET https://example.com/wp-json/cocart/v1/products/attributes/2/terms/23 \
  -H "Content-Type: application/json" \
CoCart.get("products/attributes/2/terms/23")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products/attributes/2/terms/23",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products/attributes/2/terms/23",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products/attributes/2/terms/23' );
$body = wp_remote_retrieve_body( $response );
{
  "id": 23,
  "name": "XXS",
  "slug": "xxs",
  "description": "",
  "menu_order": 1,
  "count": 1,
  "_links": {
    "self": [
      {
        "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms/23"
      }
    ],
    "collection": [
      {
        "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms"
      }
    ]
  }
}

List all attribute terms

This API lets you retrieve all terms from a product attribute.

GET
/wp-json/cocart/v1/products/attributes/<attribute_id>/terms
curl -X GET https://example.com/wp-json/cocart/v1/products/attributes/2/terms \
  -H "Content-Type: application/json" \
CoCart.get("products/attributes/2/terms")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products/attributes/2/terms",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products/attributes/2/terms",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products/attributes/2/terms' );
$body = wp_remote_retrieve_body( $response );
[
  {
    "id": 23,
    "name": "XXS",
    "slug": "xxs",
    "description": "",
    "menu_order": 1,
    "count": 1,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms/23"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms"
        }
      ]
    }
  },
  {
    "id": 22,
    "name": "XS",
    "slug": "xs",
    "description": "",
    "menu_order": 2,
    "count": 1,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms/22"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms"
        }
      ]
    }
  },
  {
    "id": 17,
    "name": "S",
    "slug": "s",
    "description": "",
    "menu_order": 3,
    "count": 1,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms/17"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms"
        }
      ]
    }
  },
  {
    "id": 18,
    "name": "M",
    "slug": "m",
    "description": "",
    "menu_order": 4,
    "count": 1,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms/18"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms"
        }
      ]
    }
  },
  {
    "id": 19,
    "name": "L",
    "slug": "l",
    "description": "",
    "menu_order": 5,
    "count": 1,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms/19"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms"
        }
      ]
    }
  },
  {
    "id": 20,
    "name": "XL",
    "slug": "xl",
    "description": "",
    "menu_order": 6,
    "count": 1,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms/20"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms"
        }
      ]
    }
  },
  {
    "id": 21,
    "name": "XXL",
    "slug": "xxl",
    "description": "",
    "menu_order": 7,
    "count": 1,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms/21"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2/terms"
        }
      ]
    }
  }
]

Available parameters

Parameter Type Description
page integer Current page of the collection. Default is 1.
per_page integer Maximum number of items to be returned in result set. Default is 10.
search string Limit results to those matching a string.
exclude array Ensure result set excludes specific ids.
include array Limit result set to specific ids.
order string Order sort attribute ascending or descending. Options: asc and desc. Default is asc.
orderby string Sort collection by attribute. Options: id, include, name, slug, term_group, description and count. Default is name.
hide_empty boolean Whether to hide attribute terms not assigned to any products. Default is false.
parent integer Limit result set to attribute terms assigned to a specific parent.
product integer Limit result set to attribute terms assigned to a specific product.
slug string Limit result set to attribute terms with a specific slug.

Product attributes

GitHub Mark Logo Edit on GitHub

The product attributes API allows you to view all or individual product attributes.

Product attribute attributes

Attribute Type Description
id integer Unique identifier for the product attribute.
name string Attribute name.
slug string An alphanumeric identifier for the resource unique to its type.
type string Type of attribute. By default only select is supported.
order_by string Default sort order. Options: menu_order, name, name_num and id. Default is menu_order.
has_archives boolean Enable/Disable attribute archives. Default is false.

Retrieve a product attribute

This API lets you retrieve and view a specific product attribute by ID.

GET
/wp-json/cocart/v1/products/attributes/<id>
curl -X GET https://example.com/wp-json/cocart/v1/products/attributes/1 \
  -H "Content-Type: application/json" \
CoCart.get("products/attributes/1")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products/attributes/1",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products/attributes/1",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products/attributes/1' );
$body = wp_remote_retrieve_body( $response );
{
  "id": 1,
  "name": "Color",
  "slug": "pa_color",
  "type": "select",
  "order_by": "menu_order",
  "has_archives": true,
  "_links": {
    "self": [
      {
        "href": "https://example.com/wp-json/cocart/v1/products/attributes/6"
      }
    ],
    "collection": [
      {
        "href": "https://example.com/wp-json/cocart/v1/products/attributes"
      }
    ]
  }
}

List all product attributes

This API helps you to view all the product attributes.

HTTP request

GET
/wp-json/cocart/v1/products/attributes
curl -X GET https://example.com/wp-json/cocart/v1/products/attributes \
  -H "Content-Type: application/json" \
CoCart.get("products/attributes")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products/attributes",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products/attributes",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products/attributes' );
$body = wp_remote_retrieve_body( $response );
[
  {
    "id": 1,
    "name": "Color",
    "slug": "pa_color",
    "type": "select",
    "order_by": "menu_order",
    "has_archives": true,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/6"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes"
        }
      ]
    }
  },
  {
    "id": 2,
    "name": "Size",
    "slug": "pa_size",
    "type": "select",
    "order_by": "menu_order",
    "has_archives": false,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes/2"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/attributes"
        }
      ]
    }
  }
]

Product categories

GitHub Mark Logo Edit on GitHub

The product categories API allows you to view all or individual product categories.

Product category attributes

Attribute Type Description
id integer Unique identifier for the category.
name string Category name.
slug string An alphanumeric identifier for the category unique to its type.
parent integer The ID for the parent of the category.
description string HTML description of the category.
display string Category archive display type. Options: default, products, subcategories and both. Default is default.
image object Image data. See Product category - Image properties
menu_order integer Menu order, used to custom sort the category.
count integer Number of published products for the category.

Product category - Image attributes

Attribute Type Description
id integer Image ID.
date_created date-time The date the image was created, in the site's timezone.
date_created_gmt date-time The date the image was created, as GMT
date_modified date-time The date the image was last modified, in the site's timezone.
date_modified_gmt date-time The date the image was last modified, as GMT.
src string Image URL.
name string Image name.
alt string Image alternative text.

Retrieve a product category

This API lets you retrieve a product category by ID.

GET
/wp-json/cocart/v1/products/categories/<id>
curl https://example.com/wp-json/cocart/v1/products/categories/9 \
  -H "Content-Type: application/json" \
CoCart.get("products/categories/9")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products/categories/9",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products/categories/9",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products/categories/9' );
$body = wp_remote_retrieve_body( $response );
{
  "id": 9,
  "name": "Clothing",
  "slug": "clothing",
  "parent": 0,
  "description": "",
  "display": "default",
  "image": {
    "id": 730,
    "date_created": "2017-03-23T00:01:07",
    "date_created_gmt": "2017-03-23T03:01:07",
    "date_modified": "2017-03-23T00:01:07",
    "date_modified_gmt": "2017-03-23T03:01:07",
    "src": "https://example.com/wp-content/uploads/2017/03/T_2_front.jpg",
    "name": "",
    "alt": ""
  },
  "menu_order": 0,
  "count": 36,
  "_links": {
    "self": [
      {
        "href": "https://example.com/wp-json/cocart/v1/products/categories/9"
      }
    ],
    "collection": [
      {
        "href": "https://example.com/wp-json/cocart/v1/products/categories"
      }
    ]
  }
}

List all product categories

This API lets you retrieve all product categories.

GET
/wp-json/cocart/v1/products/categories
curl https://example.com/wp-json/cocart/v1/products/categories \
  -H "Content-Type: application/json" \
CoCart.get("products/categories")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products/categories",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products/categories",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products/categories' );
$body = wp_remote_retrieve_body( $response );
[
  {
    "id": 15,
    "name": "Albums",
    "slug": "albums",
    "parent": 11,
    "description": "",
    "display": "default",
    "image": [],
    "menu_order": 0,
    "count": 4,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories/15"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories"
        }
      ],
      "up": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories/11"
        }
      ]
    }
  },
  {
    "id": 9,
    "name": "Clothing",
    "slug": "clothing",
    "parent": 0,
    "description": "",
    "display": "default",
    "image": {
      "id": 730,
      "date_created": "2017-03-23T00:01:07",
      "date_created_gmt": "2017-03-23T03:01:07",
      "date_modified": "2017-03-23T00:01:07",
      "date_modified_gmt": "2017-03-23T03:01:07",
      "src": "https://example.com/wp-content/uploads/2017/03/T_2_front.jpg",
      "name": "",
      "alt": ""
    },
    "menu_order": 0,
    "count": 36,
    "_links": {
      "self": [
        {
          "href": "https://example/wp-json/cocart/v1/products/categories/9"
        }
      ],
      "collection": [
        {
          "href": "https://example/wp-json/cocart/v1/products/categories"
        }
      ]
    }
  },
  {
    "id": 10,
    "name": "Hoodies",
    "slug": "hoodies",
    "parent": 9,
    "description": "",
    "display": "default",
    "image": [],
    "menu_order": 0,
    "count": 6,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories/10"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories"
        }
      ],
      "up": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories/9"
        }
      ]
    }
  },
  {
    "id": 11,
    "name": "Music",
    "slug": "music",
    "parent": 0,
    "description": "",
    "display": "default",
    "image": [],
    "menu_order": 0,
    "count": 7,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories/11"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories"
        }
      ]
    }
  },
  {
    "id": 12,
    "name": "Posters",
    "slug": "posters",
    "parent": 0,
    "description": "",
    "display": "default",
    "image": [],
    "menu_order": 0,
    "count": 5,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories/12"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories"
        }
      ]
    }
  },
  {
    "id": 13,
    "name": "Singles",
    "slug": "singles",
    "parent": 11,
    "description": "",
    "display": "default",
    "image": [],
    "menu_order": 0,
    "count": 3,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories/13"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories"
        }
      ],
      "up": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories/11"
        }
      ]
    }
  },
  {
    "id": 14,
    "name": "T-shirts",
    "slug": "t-shirts",
    "parent": 9,
    "description": "",
    "display": "default",
    "image": [],
    "menu_order": 0,
    "count": 6,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories/14"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories"
        }
      ],
      "up": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/categories/9"
        }
      ]
    }
  }
]

Available parameters

Parameter Type Description
page integer Current page of the collection. Default is 1.
per_page integer Maximum number of items to be returned in result set. Default is 10.
search string Limit results to those matching a string.
exclude array Ensure result set excludes specific ids.
include array Limit result set to specific ids.
order string Order sort attribute ascending or descending. Options: asc and desc. Default is asc.
orderby string Sort collection by category attribute. Options: id, include, name, slug, term_group, description and count. Default is name.
hide_empty boolean Whether to hide categories not assigned to any products. Default is false.
parent integer Limit result set to categories assigned to a specific parent.
product integer Limit result set to categories assigned to a specific product.
slug string Limit result set to categories with a specific slug.

Product tags

GitHub Mark Logo Edit on GitHub

The product tags API allows you to view all or individual product tags.

Product tag attributes

Attribute Type Description
id integer Unique identifier for the tag.
name string Tag name.
slug string An alphanumeric identifier for the resource unique to its type.
description string HTML description of the resource.
count integer Number of published products for the tag.

Retrieve a product tag

This API lets you retrieve a product tag by ID.

GET
/wp-json/cocart/v1/products/tags/<id>
curl https://example.com/wp-json/cocart/v1/products/tags/34 \
  -H "Content-Type: application/json" \
CoCart.get("products/tags/34")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products/tags/34",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products/tags/34",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products/tags/34' );
$body = wp_remote_retrieve_body( $response );
{
  "id": 34,
  "name": "Leather Shoes",
  "slug": "leather-shoes",
  "description": "",
  "count": 0,
  "_links": {
    "self": [
      {
        "href": "https://example.com/wp-json/cocart/v1/products/tags/34"
      }
    ],
    "collection": [
      {
        "href": "https://example.com/wp-json/cocart/v1/products/tags"
      }
    ]
  }
}

List all product tags

This API lets you retrieve all product tag.

GET
/wp-json/cocart/v1/products/tags
curl https://example.com/wp-json/cocart/v1/products/tags \
  -H "Content-Type: application/json" \
CoCart.get("products/tags")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products/tags",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products/tags",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products/tags' );
$body = wp_remote_retrieve_body( $response );
[
  {
    "id": 34,
    "name": "Leather Shoes",
    "slug": "leather-shoes",
    "description": "",
    "count": 0,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/tags/34"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/tags"
        }
      ]
    }
  },
  {
    "id": 35,
    "name": "Oxford Shoes",
    "slug": "oxford-shoes",
    "description": "",
    "count": 0,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/tags/35"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/cocart/v1/products/tags"
        }
      ]
    }
  }
]

Available parameters

Parameter Type Description
page integer Current page of the collection. Default is 1.
per_page integer Maximum number of items to be returned in result set. Default is 10.
search string Limit results to those matching a string.
exclude array Ensure result set excludes specific ids.
include array Limit result set to specific ids.
offset integer Offset the result set by a specific number of items.
order string Order sort attribute ascending or descending. Options: asc and desc. Default is asc.
orderby string Sort collection by tag attribute. Options: id, include, name, slug, term_group, description and count. Default is name.
hide_empty boolean Whether to hide tags not assigned to any products. Default is false.
product integer Limit result set to tags assigned to a specific product.
slug string Limit result set to tags with a specific slug.

Product reviews

GitHub Mark Logo Edit on GitHub

The product reviews API allows you to view product reviews and create a product review.

Product review attributes

Attribute Type Description
id integer Unique identifier for the product review.
date_created string The date the review was created, in the site's timezone.
date_created_gmt string The date the review was created, as GMT.
product_id integer Unique identifier for the product that the review belongs to.
status string Status of the review. Options: approved and hold. Defaults to approved.
reviewer string Reviewer name.
reviewer_email string Reviewer email.
review string The content of the review.
rating integer Review rating (0 to 5).
verified boolean Shows if the reviewer bought the product or not.

Create a product review

This API helps you to create a new product review. Either submit the review as the customer or as administrator on behalf of the customer. Must use the same email address used on the customers account at the time the product being reviewed was ordered.

HTTP request

POST
/wp-json/cocart/v1/products/reviews

Example of how to create a product review:

curl -X POST https://example.com/wp-json/cocart/v1/products/reviews \
    -u consumer_key:consumer_secret \
    -H "Content-Type: application/json" \
    -d '{
    "product_id": 22,
    "review": "Nice album!",
    "reviewer": "John Doe",
    "reviewer_email": "john.doe@example.com",
    "rating": 5
}'
CoCart.post("products/reviews", {
  product_id: "22",
  review: "Nice album!",
  reviewer: "John Doe",
  reviewer_email: "john.doe@example.com",
  rating: 5
})
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/add-item",
  method: "POST",
  data: JSON.stringify({
    "product_id": "22",
    "review": "Nice album!",
    "reviewer": "John Doe",
    "reviewer_email": "john.doe@example.com",
    "rating": 5
  }),
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

$args = array(
  'product_id' => '22',
  'review' => 'Nice album!',
  'reviewer' => 'John Doe',
  'reviewer_email' => 'john.doe@example.com',
  'rating' => 5
);

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/add-item",
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => $args,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$args = array(
  'headers' => array(
    'Content-Type' => 'application/json; charset=utf-8',
  ),
  'body' => wp_json_encode( [
    'product_id' => '22',
    'review' => 'Nice album!',
    'reviewer' => 'John Doe',
    'reviewer_email' => 'john.doe@example.com',
    'rating' => 5
  ] ),
  'timeout' => 30
);

$response = wp_remote_post( 'https://example.com/wp-json/cocart/v1/add-item', $args );
$body = wp_remote_retrieve_body( $response );
{
    "id": 22,
    "date_created": "2018-10-18T17:59:17",
    "date_created_gmt": "2018-10-18T20:59:17",
    "product_id": 22,
    "status": "approved",
    "reviewer": "John Doe",
    "reviewer_email": "john.doe@example.com",
    "review": "Nice album!",
    "rating": 5,
    "verified": false,
    "reviewer_avatar_urls": {
        "24": "https://secure.gravatar.com/avatar/8eb1b522f60d11fa897de1dc6351b7e8?s=24&d=mm&r=g",
        "48": "https://secure.gravatar.com/avatar/8eb1b522f60d11fa897de1dc6351b7e8?s=48&d=mm&r=g",
        "96": "https://secure.gravatar.com/avatar/8eb1b522f60d11fa897de1dc6351b7e8?s=96&d=mm&r=g"
    },
    "_links": {
        "self": [
            {
                "href": "https://example.com/wp-json/cocart/v1/products/reviews/22"
            }
        ],
        "collection": [
            {
                "href": "https://example.com/wp-json/cocart/v1/products/reviews"
            }
        ],
        "up": [
            {
                "href": "https://example.com/wp-json/cocart/v1/products/22"
            }
        ]
    }
}

Retrieve a product review

This API lets you retrieve a product review by ID.

GET
/wp-json/cocart/v1/products/reviews/<id>
curl -X GET https://example.com/wp-json/cocart/v1/products/reviews/22 \
  -H "Content-Type: application/json" \
CoCart.get("products/reviews/22")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products/reviews/22",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products/reviews/22",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products/reviews/22' );
$body = wp_remote_retrieve_body( $response );
{
    "id": 22,
    "date_created": "2018-10-18T17:59:17",
    "date_created_gmt": "2018-10-18T20:59:17",
    "product_id": 22,
    "status": "approved",
    "reviewer": "John Doe",
    "review": "Nice album!",
    "rating": 5,
    "verified": false,
    "reviewer_avatar_urls": {
        "24": "https://secure.gravatar.com/avatar/8eb1b522f60d11fa897de1dc6351b7e8?s=24&d=mm&r=g",
        "48": "https://secure.gravatar.com/avatar/8eb1b522f60d11fa897de1dc6351b7e8?s=48&d=mm&r=g",
        "96": "https://secure.gravatar.com/avatar/8eb1b522f60d11fa897de1dc6351b7e8?s=96&d=mm&r=g"
    },
    "_links": {
        "self": [
            {
                "href": "https://example.com/wp-json/cocart/v1/products/reviews/22"
            }
        ],
        "collection": [
            {
                "href": "https://example.com/wp-json/cocart/v1/products/reviews"
            }
        ],
        "up": [
            {
                "href": "https://example.com/wp-json/cocart/v1/products/22"
            }
        ]
    }
}

List all product reviews

This API lets you retrieve all product reviews.

GET
/wp-json/cocart/v1/products/reviews
curl -X GET https://example.com/wp-json/cocart/v1/products/reviews \
  -H "Content-Type: application/json" \
CoCart.get("products/reviews")
.then((response) => {
  // Successful request
  console.log("Response Status:", response.status);
  console.log("Response Headers:", response.headers);
  console.log("Response Data:", response.data);
})
.catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log("Response Status:", error.response.status);
  console.log("Response Headers:", error.response.headers);
  console.log("Response Data:", error.response.data);
})
.finally(() => {
  // Always executed.
});
$.ajax({
  url: "https://example.com/wp-json/cocart/v1/products/reviews",
  method: "GET",
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  complete: function (response) {
    console.log(response);
  }
});
<?php
$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_URL => "https://example.com/wp-json/cocart/v1/products/reviews",
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'User-Agent: CoCart API/v1',
  )
) );

$response = curl_exec($curl);

curl_close($curl);

echo $response;
<?php
$response = wp_remote_get( 'https://example.com/wp-json/cocart/v1/products/reviews' );
$body = wp_remote_retrieve_body( $response );
[
    {
        "id": 22,
        "date_created": "2018-10-18T17:59:17",
        "date_created_gmt": "2018-10-18T20:59:17",
        "product_id": 22,
        "status": "approved",
        "reviewer": "John Doe",
        "review": "<p>Nice album!</p>\n",
        "rating": 5,
        "verified": false,
        "reviewer_avatar_urls": {
            "24": "https://secure.gravatar.com/avatar/8eb1b522f60d11fa897de1dc6351b7e8?s=24&d=mm&r=g",
            "48": "https://secure.gravatar.com/avatar/8eb1b522f60d11fa897de1dc6351b7e8?s=48&d=mm&r=g",
            "96": "https://secure.gravatar.com/avatar/8eb1b522f60d11fa897de1dc6351b7e8?s=96&d=mm&r=g"
        },
        "_links": {
            "self": [
                {
                    "href": "https://example.com/wp-json/cocart/v1/products/reviews/22"
                }
            ],
            "collection": [
                {
                    "href": "https://example.com/wp-json/cocart/v1/products/reviews"
                }
            ],
            "up": [
                {
                    "href": "https://example.com/wp-json/cocart/v1/products/22"
                }
            ]
        }
    },
    {
        "id": 20,
        "date_created": "2018-09-08T21:47:19",
        "date_created_gmt": "2018-09-09T00:47:19",
        "product_id": 31,
        "status": "approved",
        "reviewer": "Claudio Sanches",
        "review": "<p>Now works just fine.</p>\n",
        "rating": 1,
        "verified": true,
        "reviewer_avatar_urls": {
            "24": "https://secure.gravatar.com/avatar/908480753c07509e76322dc17d305c8b?s=24&d=mm&r=g",
            "48": "https://secure.gravatar.com/avatar/908480753c07509e76322dc17d305c8b?s=48&d=mm&r=g",
            "96": "https://secure.gravatar.com/avatar/908480753c07509e76322dc17d305c8b?s=96&d=mm&r=g"
        },
        "_links": {
            "self": [
                {
                    "href": "https://example.com/wp-json/cocart/v1/products/reviews/20"
                }
            ],
            "collection": [
                {
                    "href": "https://example.com/wp-json/cocart/v1/products/reviews"
                }
            ],
            "up": [
                {
                    "href": "https://example.com/wp-json/cocart/v1/products/31"
                }
            ],
            "reviewer": [
                {
                    "embeddable": true,
                    "href": "https://example.com/wp-json/wp/v2/users/1"
                }
            ]
        }
    }
]

Available parameters

Parameter Type Description
context string Scope under which the request is made; determines fields present in response. Options: view and edit. Default is view.
page integer Current page of the collection. Default is 1.
per_page integer Maximum number of items to be returned in result set. Default is 10.
search string Limit results to those matching a string.
after string Limit response to reviews published after a given ISO8601 compliant date.
before string Limit response to reviews published before a given ISO8601 compliant date.
exclude array Ensure result set excludes specific ids.
include array Limit result set to specific ids.
offset integer Offset the result set by a specific number of items.
order string Order sort attribute ascending or descending. Options: asc and desc. Default is desc.
orderby string Sort collection by resource attribute. Options: date, date_gmt, id, slug, include and product. Default is date_gmt.
reviewer array Limit result set to reviews assigned to specific user IDs.
reviewer_exclude array Ensure result set excludes reviews assigned to specific user IDs.
reviewer_email array Limit result set to that from a specific author email.
product array Limit result set to reviews assigned to specific product IDs.
status string Limit result set to reviews assigned a specific status. Options: all, hold and approved. Default is approved.
{
    "id": 20,
    "date_created": "2018-09-08T21:47:19",
    "date_created_gmt": "2018-09-09T00:47:19",
    "product_id": 31,
    "status": "approved",
    "reviewer": "Claudio Sanches",
    "review": "Now works just fine.",
    "rating": 5,
    "verified": true,
    "reviewer_avatar_urls": {
        "24": "https://secure.gravatar.com/avatar/908480753c07509e76322dc17d305c8b?s=24&d=mm&r=g",
        "48": "https://secure.gravatar.com/avatar/908480753c07509e76322dc17d305c8b?s=48&d=mm&r=g",
        "96": "https://secure.gravatar.com/avatar/908480753c07509e76322dc17d305c8b?s=96&d=mm&r=g"
    },
    "_links": {
        "self": [
            {
                "href": "https://example.com/wp-json/cocart/v1/products/reviews/20"
            }
        ],
        "collection": [
            {
                "href": "https://example.com/wp-json/cocart/v1/products/reviews"
            }
        ],
        "up": [
            {
                "href": "https://example.com/wp-json/cocart/v1/products/31"
            }
        ],
        "reviewer": [
            {
                "embeddable": true,
                "href": "https://example.com/wp-json/wp/v2/users/1"
            }
        ]
    }
}

WooCommerce Extensions

GitHub Mark Logo Edit on GitHub

These extensions either support CoCart Products or is supported in CoCart Products.

Mix and Match Products

Selling cases of wine? A dozen donuts? Fruit baskets? Six-packs of T-shirts? Mix and Match Products is ideal for offering similar products in bulk containers. Perfect for encouraging customers to buy in bulk without forcing them to buy items that don’t interest them.

Retrieve a product

Any Mix and Match Product will return additional product data under a new array variable mnm_data.

{
    "id": 1102,
    "name": "Mix and Match Products",
    "slug": "mix-and-match-products",
    "permalink": "https://example.com/product/mix-and-match-products/",
    "date_created": "2019-10-03T21:41:45",
    "date_created_gmt": "2019-10-03T19:41:45",
    "date_modified": "2020-07-15T21:53:43",
    "date_modified_gmt": "2020-07-15T19:53:43",
    "type": "mix-and-match",
    "featured": false,
    "catalog_visibility": "visible",
    "description": "",
    "short_description": "",
    "sku": "",
    "price": "£2.00",
    "regular_price": "£2.00",
    "sale_price": "",
    "date_on_sale_from": null,
    "date_on_sale_from_gmt": null,
    "date_on_sale_to": null,
    "date_on_sale_to_gmt": null,
    "on_sale": true,
    "purchasable": true,
    "total_sales": 6,
    "virtual": false,
    "downloadable": false,
    "external_url": "",
    "button_text": "",
    "manage_stock": false,
    "stock_quantity": null,
    "in_stock": true,
    "stock_status": "instock",
    "backorders": "no",
    "backorders_allowed": false,
    "backordered": false,
    "sold_individually": false,
    "weight": "",
    "dimensions": {
        "length": "",
        "width": "",
        "height": ""
    },
    "shipping_required": true,
    "reviews_allowed": true,
    "average_rating": "0",
    "rating_count": 0,
    "review_count": 0,
    "rating_html": "",
    "reviews": [],
    "related_ids": [
        1122,
        1992,
        1003,
        1957,
        1888
    ],
    "upsell_ids": [],
    "cross_sell_ids": [],
    "parent_id": 0,
    "categories": [
        {
            "id": 42,
            "name": "Food",
            "slug": "food"
        }
    ],
    "tags": [],
    "images": [
        {
            "id": 0,
            "date_created": "2020-07-25T20:45:15",
            "date_created_gmt": "2020-07-25T16:45:15",
            "date_modified": "2020-07-25T20:45:15",
            "date_modified_gmt": "2020-07-25T16:45:15",
            "src": {
                "thumbnail": "https://example.com/wp-content/uploads/woocommerce-placeholder-150x150.png",
                "medium": "https://example.com/wp-content/uploads/woocommerce-placeholder-300x300.png",
                "medium_large": "https://example.com/wp-content/uploads/woocommerce-placeholder-768x768.png",
                "large": "https://example.com/wp-content/uploads/woocommerce-placeholder-1024x1024.png",
                "1536x1536": "https://example.com/wp-content/uploads/woocommerce-placeholder.png",
                "2048x2048": "https://example.com/wp-content/uploads/woocommerce-placeholder.png",
                "woocommerce_thumbnail": "https://example.com/wp-content/uploads/woocommerce-placeholder-324x324.png",
                "woocommerce_single": "https://example.com/wp-content/uploads/woocommerce-placeholder-416x416.png",
                "woocommerce_gallery_thumbnail": "https://example.com/wp-content/uploads/woocommerce-placeholder-100x100.png",
                "shop_catalog": "https://example.com/wp-content/uploads/woocommerce-placeholder-324x324.png",
                "shop_single": "https://example.com/wp-content/uploads/woocommerce-placeholder-416x416.png",
                "shop_thumbnail": "https://example.com/wp-content/uploads/woocommerce-placeholder-100x100.png",
                "full": "https://example.com/wp-content/uploads/woocommerce-placeholder.png",
                "custom": "https://example.com/wp-content/uploads/woocommerce-placeholder.png"
            },
            "name": "Placeholder",
            "alt": "Placeholder",
            "position": 0
        }
    ],
    "attributes": [],
    "default_attributes": [],
    "variations": [],
    "grouped_products": [],
    "menu_order": 0,
    "meta_data": [],
    "mnm_data": {
        "base_raw_price": 2,
        "base_raw_regular_price": 2,
        "base_raw_sale_price": "",
        "base_price": "£2.00",
        "base_regular_price": "£2.00",
        "base_sale_price": "£0.00",
        "has_discount": true,
        "min_raw_price": 4.5671,
        "min_raw_regular_price": 4.58,
        "max_raw_price": 9.7013,
        "max_raw_regular_price": 9.74,
        "min_price": "£4.57",
        "min_regular_price": "£4.58",
        "max_price": "£9.70",
        "max_regular_price": "£9.74",
        "min_container_size": 2,
        "max_container_size": 6,
        "products": [
            {
                "child_id": 987,
                "product_id": 987,
                "variation_id": 0,
                "name": "Cupcake",
                "raw_price": "1.28355",
                "raw_regular_price": "1.29",
                "raw_sale_price": "1.28355",
                "price": "£1.28",
                "regular_price": "£1.29",
                "sale_price": "£1.28",
                "on_sale": true
            },
            {
                "child_id": 1001,
                "product_id": 1001,
                "variation_id": 0,
                "name": "Turquoise Cupcake",
                "raw_price": "1.28355",
                "raw_regular_price": "1.29",
                "raw_sale_price": "1.28355",
                "price": "£1.28",
                "regular_price": "£1.29",
                "sale_price": "£1.28",
                "on_sale": true
            },
            {
                "child_id": 1003,
                "product_id": 1003,
                "variation_id": 0,
                "name": "Buttercup and Bumblebee Cupcakes",
                "raw_price": "1.28355",
                "raw_regular_price": "1.29",
                "raw_sale_price": "1.28355",
                "price": "£1.28",
                "regular_price": "£1.29",
                "sale_price": "£1.28",
                "on_sale": true
            }
        ],
        "per_product_pricing": true,
        "per_product_discount": 0.5,
        "per_product_shipping": true
    },
    "_links": {
        "self": [
            {
                "permalink": "https://example.com/product/mix-and-match-products/",
                "href": "https://example.com/wp-json/cocart/v1/products/1102"
            }
        ],
        "collection": [
            {
                "permalink": "https://example.com/shop/",
                "href": "https://example.com/wp-json/cocart/v1/products"
            }
        ]
    }
}

Libraries

GitHub Mark Logo Edit on GitHub

npm install --save @cocart/cocart-rest-api

// import CoCartAPI from "@cocart/cocart-rest-api"; // Supports ESM
const CoCartAPI = require("@cocart/cocart-rest-api").default;

const CoCart = new CoCartAPI({
  url: "https://example.com",
  version: "cocart/v1"
});

Tools

GitHub Mark Logo Edit on GitHub

Some useful tools you can use to access the API include:

If you use Postman you can use these collections made ready for you.

Learn more

Learn more about the REST API by checking the official WordPress REST API documentation.

Changelog

The Documentation is updated only when needed. Below is the changelog for "CoCart Products" documentation that matches with the version of the plugin release.

Doc Version 0.4

Doc Version 0.3

Doc Version 0.2 - Plugin Release v1.0.0

Doc Version 0.1 - Plugin Release v1.0.0