General hooks
This page lists the 7 hooks of this group. Each entry shows its type, the version it arrived in, where it runs, its arguments and a starting point.
addochat_added_to_cartaddochat_admin_languageaddochat_cart_itemaddochat_rule_matchesaddochat_tracking_allowedaddochat_visit_recordedaddochat_visit_url
addochat_added_to_cart
ActionSince 0.2.0 Runs in src/Cart/Cart.php.
Fires when the widget put a product of the chat in the cart of the visitor.
| Argument | Type | Description |
|---|---|---|
$conversation | array<string, mixed> | Conversation row. |
$product | int | Product or variation id. |
$qty | int | Quantity. |
$message_id | int | Message with the offer. |
add_action( 'addochat_added_to_cart', function ( $conversation, $product, $qty, $message_id ) {
// ...
}, 10, 4 );
addochat_admin_language
FilterSince 0.1.0 Runs in src/Support/Language.php.
Filters the language the settings screen shows texts for. '' shows every language. For language plugins other than Polylang and WPML.
| Argument | Type | Description |
|---|---|---|
$locale | string | Locale chosen in the admin, '' for all languages. |
add_filter( 'addochat_admin_language', function ( $locale ) {
return $locale;
} );
addochat_cart_item
FilterSince 0.2.0 Runs in src/Cart/Products.php.
Filters a product the chat offers for the cart (by the assistant or a rule). Change the quantity or set add to false to only link to the product, or return null to leave the product out.
| Argument | Type | Description |
|---|---|---|
$item | array<string, mixed>|null | product (id), qty, title, text, price, image, url, add (bool). |
$product | \WC_Product | The product. |
add_filter( 'addochat_cart_item', function ( $item, $product ) {
return $item;
}, 10, 2 );
addochat_rule_matches
FilterSince 0.2.0 Runs in src/Rules/Rules.php.
Filters whether a rule matches, for example to add a condition of your own (stored in the rule by a filter on the settings, or decided from the context).
| Argument | Type | Description |
|---|---|---|
$matched | bool | Whether the conditions of AddoChat hold (false when the rule has none). |
$rule | array<string, mixed> | Rule. |
$context | array<string, mixed> | message, first, page, language, logged_in, settings. |
add_filter( 'addochat_rule_matches', function ( $matched, $rule, $context ) {
return $matched;
}, 10, 3 );
addochat_tracking_allowed
FilterSince 0.2.0 Runs in src/Visits/Route.php.
Filters whether this page view is stored. The consent the browser checks (WP Consent API) comes first; use this filter for a consent tool of your own, or to skip some visitors.
| Argument | Type | Description |
|---|---|---|
$allowed | bool | Whether the view is stored. Default true. |
$context | array<string, mixed> | url, title and mode (consent or always). |
add_filter( 'addochat_tracking_allowed', function ( $allowed, $context ) {
return $allowed;
}, 10, 2 );
addochat_visit_recorded
ActionSince 0.2.0 Runs in src/Visits/Route.php.
Fires after a new page view was stored (not on its heartbeats).
| Argument | Type | Description |
|---|---|---|
$visit | array<string, mixed> | The view: url, title, referrer, entered_at and more. |
$conversation_id | int | Conversation of the visitor, 0 for none. |
add_action( 'addochat_visit_recorded', function ( $visit, $conversation_id ) {
// ...
}, 10, 2 );
addochat_visit_url
FilterSince 0.2.0 Runs in src/Visits/Route.php.
Filters the address of a page view before it is stored. Return '' to store nothing for this page, or a shorter address (for example without the order number of a thank-you page).
| Argument | Type | Description |
|---|---|---|
$url | string | Address of this site, without fragment and without key, token and campaign arguments. |
add_filter( 'addochat_visit_url', function ( $url ) {
return $url;
} );