Skip to main content
Each action hook is documented below with its description and usage example.

Installation Hooks

cocart_init

Fires once the CoCart plugin has finished loading.
Made available since v3.0.0
Usage
Search cocart_init in repository

cocart_updated

Runs after CoCart has been updated.
Made available since v1.2.0
Usage
Search cocart_updated in repository

cocart_installed

Runs after CoCart has been installed.
Made available since v1.2.0
Usage
Search cocart_installed in repository

Session Management

cocart_after_session_saved_data

Fires after session data is saved.
Made available since v4.2.0
Parameters
int
Customer ID.
array
Cart data.
int
Cart expiration.
string
Cart source.
Usage
Search cocart_after_session_saved_data in repository

cocart_load_cart_override

Manipulate the overriding cart before it is set in session.
Made available since v2.1.0
Usage
Search cocart_load_cart_override in repository

cocart_load_cart

Manipulate the merged cart before it is set in session.
Made available since v2.1.0
Usage
Search cocart_load_cart in repository

cocart_cart_loaded

Fires once a cart has loaded. Can be used to trigger a webhook.
Made available since v3.8.0
Parameters
string
The cart key.
Usage
Search cocart_cart_loaded in repository

Cart Updates

cocart_update_cart_before_totals

Fires before the cart has updated via a callback, but before cart totals are re-calculated.
Made available since v4.1.0
Parameters
WP_REST_Request
The request object.
object
The cart controller.
Usage
Search cocart_update_cart_before_totals in repository

cocart_update_cart_after_totals

Fires after the cart has updated via a callback and the cart totals are re-calculated.
Made available since v4.1.0
Parameters
WP_REST_Request
The request object.
object
The cart controller.
Usage
Search cocart_update_cart_after_totals in repository

Cart Items Management

cocart_item_added_updated_in_cart

Fires if item was added again to the cart but updated the quantity.
Made available since v2.1.0
Parameters
string
Item key of the item added again.
array
Item added to cart again.
int
New quantity of the item.
Usage
Search cocart_item_added_updated_in_cart in repository

cocart_item_added_to_cart

Fires once an item has been added to cart.
Made available since v2.1.0
Parameters
string
Item key of the item added.
array
Item added to cart.
Usage
Search cocart_item_added_to_cart in repository

cocart_item_removed

Fires when an item is removed from the cart.
Made available since v2.0.0
Parameters
array
The cart item data.
Usage
Search cocart_item_removed in repository

cocart_item_restored

Fires when an item is restored to the cart.
Made available since v2.0.0
Parameters
array
The cart item data.
Usage
Search cocart_item_restored in repository

cocart_item_quantity_changed

Fires when the quantity of an item in the cart is changed.
Made available since v2.0.0
Parameters
string
Item key.
array
Item data.
Usage
Search cocart_item_quantity_changed in repository

Cart Operations

cocart_before_cart_emptied

Triggers before the cart is emptied.
Made available since v1.0.0
Usage
Search cocart_before_cart_emptied in repository

cocart_cart_emptied

Triggers once the cart is emptied.
Made available since v1.0.0
Usage
Search cocart_cart_emptied in repository

cocart_cart_cleared

Triggers once the cart is cleared.
Made available since v1.0.0
Usage
Search cocart_cart_cleared in repository

cocart_get_cart

Fires when the cart is retrieved.
Made available since v2.0.0
Parameters
array
Cart contents.
Usage
Search cocart_get_cart in repository

Extensions

cocart_register_extension_callback

Fires when an extension callback is registered.
Made available since v3.1.0
Parameters
CoCart_Cart_Extension
Instance of the CoCart_Cart_Extension class which exposes the CoCart_Cart_Extension::register() method.
Usage
Search cocart_register_extension_callback in repository

Product Reviews

cocart_insert_product_review

Fires after a comment is created via the REST API.
Made available since v2.0.0
Parameters
WP_Comment
Inserted comment object.
WP_REST_Request
The request object.
bool
True when creating a comment, false when updating.
Usage
Search cocart_insert_product_review in repository

Deprecated

cocart_update_cart_before_totals

Deprecated: 4.1.0 Replaced with cocart_update_cart_before_totals hook.
Fires after the cart has updated via a callback.
Made available since v3.1.0
Usage
Search cocart_update_cart_before_totals in repository