REST API
The REST API has had small changes that affect the schema and default behaviors of all API. Please review the API Reference and check if an endpoint has been tagged “Updated”.
- Avatars only return if requested now when using the login endpoint.
- Store API now returns array of CoCart versions installed not just the core version.
- Product meta will not return by default. To improve security and prevent PII from exposure, meta must now be whitelisted instead using the new filter
cocart_products_allowed_meta_keys. - Variation data for items is moved above item totals when fetching the cart.
- The quantity parameter when adding an item now accepts both a
numericor anarrayvalue allowing to extend support for other product types that are a container of other grouped products. - Product Categories changed
image_srcfrom a single thumbnail to return all image sizes available. Schema updated to match. - Product reviews was updated to support better query parameters. Affects both API versions. Schema updated to match.
- Feature: Load Cart from Session has been rewritten to support both guest and registered customers.
Returned Headers
The following returned headers have also been renamed. Better for security reasons.| Previous Header | New Header |
|---|---|
| CoCart-API-Cart-Key | Cart-Key |
| CoCart-Timestamp | Timestamp |
| CoCart-API-Cart-Expiring | Cart-Expiring |
| CoCart-API-Cart-Expiration | Cart-Expiration |
Action Hooks
The following action hooks have changed.| Action Hook | Change |
|---|---|
cocart_item_restored | Added the request object as the first parameter. |
cocart_item_removed | Added the request object as the first parameter. |
cocart_item_added_updated_in_cart | Moved the request object parameter to be first. |
cocart_item_added_to_cart | Moved the request object parameter to be first. |
Filters
- Filter
cocart_cart_item_quantityhas changed the order of the$cart_itemand$item_keyparameter for consistency with other filters.
Plugin
-
The text domain a.k.a the plugin slug, has changed from
cart-rest-api-for-woocommercetococart-core. This affects any translations including custom. If you did a custom translation you will need to rename the text domain to match. - The plugin will deactivate the legacy core version if one is found installed and active. If you try to activate legacy version while the new core version is active it will deactivate. Recommend deleting.
Deprecations
- The response class
CoCart_Responseis deprecated. New utility response classes have been created for better utilization. - Function
cocart_prepare_money_response()is replaced with functioncocart_format_money().
cocart_load_cart_overridecocart_load_cartcocart_merge_cart_contentcocart_cart_loaded_successful_messagecocart_use_cookie_monstercocart_filter_request_datacocart_products_ignore_private_meta_keyscocart_return_default_responsecocart_{$endpoint}_response
For Developers
- The main cart controller
CoCart_REST_Cart_V2_Controllerfor API v2 now extends a new abstract controllerCoCart_REST_Cart_Controllerfor the cart.
This allows to better extend the cart API rather than the whole cart controller.
- The following endpoints for Cart API v2:
cart/add-item,cart/add-items,cart/calculatenow extendCoCart_REST_Cart_V2_Controllerinstead of the Cart API v1 controller.
This allows us to deprecate API v1 in the future. Still working on disconnecting Products API v2 from v1.