Core v5 is still in development so some feature, filter, hook or ability may change before it’s released.
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
numeric
or anarray
value allowing to extend support for other product types that are a container of other grouped products. - Product Categories changed
image_src
from 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_quantity
has changed the order of the$cart_item
and$item_key
parameter for consistency with other filters.
Plugin
-
The text domain a.k.a the plugin slug, has changed from
cart-rest-api-for-woocommerce
tococart-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.
If you have the
COCART_REMOVE_ALL_DATA
constant set to true. Recommend setting it to false before uninstalling the legacy version from your WordPress dashboard to prevent any issues. Otherwise, use FTP to delete the legacy plugin instead.Deprecations
Developer ImpactIf you have extended CoCart or used any public functions within CoCart for your own API endpoints. Please check the deprecated list below.
- The response class
CoCart_Response
is 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_override
cocart_load_cart
cocart_merge_cart_content
cocart_cart_loaded_successful_message
cocart_use_cookie_monster
cocart_filter_request_data
cocart_products_ignore_private_meta_keys
cocart_return_default_response
cocart_{$endpoint}_response
For Developers
- The main cart controller
CoCart_REST_Cart_V2_Controller
for API v2 now extends a new abstract controllerCoCart_REST_Cart_Controller
for 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/calculate
now extendCoCart_REST_Cart_V2_Controller
instead 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.