Deprecated: Creation of dynamic property wpdb::$categories is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$post2cat is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$link2cat is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Warning: file_exists(): open_basedir restriction in effect. File(/var/www/efs/wp-content/plugins/memcached-is-your-friend/memcached-class-object-cache.php) is not within the allowed path(s): (/www/logichop_469/public:/www/logichop_469/mysqleditor:/www/logichop_469/web:/www/logichop_469/deploy:/www/logichop_469/deployment:/www/logichop_469/deployments:/www/logichop_469/tmp:/usr/share:/tmp:/dev/urandom) in /www/logichop_469/public/wp-content/object-cache.php on line 50

Deprecated: Return type of WP_Theme::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-theme.php on line 554

Deprecated: Return type of WP_Theme::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-theme.php on line 595

Deprecated: Return type of WP_Theme::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-theme.php on line 535

Deprecated: Return type of WP_Theme::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-theme.php on line 544

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-includes/comment-template.php on line 1745

Deprecated: Return type of WP_REST_Request::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/rest-api/class-wp-rest-request.php on line 960

Deprecated: Return type of WP_REST_Request::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/rest-api/class-wp-rest-request.php on line 980

Deprecated: Return type of WP_REST_Request::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/rest-api/class-wp-rest-request.php on line 992

Deprecated: Return type of WP_REST_Request::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/rest-api/class-wp-rest-request.php on line 1003

Deprecated: Return type of WP_Block_List::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 151

Deprecated: Return type of WP_Block_List::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 175

Deprecated: Return type of WP_Block_List::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 164

Deprecated: Return type of WP_Block_List::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 186

Deprecated: Return type of WP_Block_List::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 138

Deprecated: Return type of WP_Block_List::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 75

Deprecated: Return type of WP_Block_List::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 89

Deprecated: Return type of WP_Block_List::offsetSet($index, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 110

Deprecated: Return type of WP_Block_List::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 127

Deprecated: Return type of WP_Block_List::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 199

Deprecated: Return type of Pimple\Container::offsetExists($id) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/wp-tools-gravity-forms-divi-module-premium/vendor/pimple/pimple/src/Pimple/Container.php on line 133

Deprecated: Return type of Pimple\Container::offsetGet($id) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/wp-tools-gravity-forms-divi-module-premium/vendor/pimple/pimple/src/Pimple/Container.php on line 98

Deprecated: Return type of Pimple\Container::offsetSet($id, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/wp-tools-gravity-forms-divi-module-premium/vendor/pimple/pimple/src/Pimple/Container.php on line 79

Deprecated: Return type of Pimple\Container::offsetUnset($id) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/wp-tools-gravity-forms-divi-module-premium/vendor/pimple/pimple/src/Pimple/Container.php on line 143

Deprecated: Return type of Gravity_Forms\Gravity_Forms\External_API\GF_API_Response::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/external-api/class-gf-api-response.php on line 179

Deprecated: version_compare(): Passing null to parameter #1 ($version1) of type string is deprecated in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/addon/class-gf-addon.php on line 5755

Deprecated: Return type of GF_Field::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/fields/class-gf-field.php on line 93

Deprecated: Return type of GF_Field::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/fields/class-gf-field.php on line 99

Deprecated: Return type of GF_Field::offsetSet($offset, $data) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/fields/class-gf-field.php on line 108

Deprecated: Return type of GF_Field::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/fields/class-gf-field.php on line 117

Warning: The magic method AffiliateWP_Allow_Own_Referrals::__wakeup() must have public visibility in /www/logichop_469/public/wp-content/plugins/affiliatewp-allow-own-referrals/includes/class-affiliatewp-allow-own-referrals.php on line 131

Deprecated: Creation of dynamic property Cookie_Law_Info_Cli_Policy_Generator::$plugin_name is deprecated in /www/logichop_469/public/wp-content/plugins/cookie-law-info/admin/modules/cli-policy-generator/cli-policy-generator.php on line 176

Deprecated: Use of "self" in callables is deprecated in /www/logichop_469/public/wp-content/plugins/cookie-law-info/includes/class-cookie-law-info.php on line 606

Warning: Private methods cannot be final as they are never overridden by other classes in /www/logichop_469/public/wp-content/plugins/df-gravityforms-divi-plugin-premium/kirki/packages/kirki-framework/compatibility/src/Control.php on line 67

Warning: Private methods cannot be final as they are never overridden by other classes in /www/logichop_469/public/wp-content/plugins/df-gravityforms-divi-plugin-premium/kirki/packages/kirki-framework/compatibility/src/Control.php on line 103

Deprecated: Creation of dynamic property Kirki\Compatibility\Framework::$modules is deprecated in /www/logichop_469/public/wp-content/plugins/df-gravityforms-divi-plugin-premium/kirki/kirki.php on line 68

Deprecated: Optional parameter $text declared before required parameter $cart_item_key is implicitly treated as a required parameter in /www/logichop_469/public/wp-content/plugins/logichop-subscription-conduit/logichop-subscription-conduit.php on line 323

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$customizations is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 136

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$ws_subscribe_enable is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 153

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$ws_smtp_enable is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 154

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$ws_template_enable is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 156

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$ws_sms_enable is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 157

Deprecated: Creation of dynamic property WOO_SL_functions::$query_vars is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-software-license/include/class.sl.functions.php on line 35

Deprecated: Creation of dynamic property WOO_SL::$licence is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-software-license/include/class.sl.php on line 21

Deprecated: Creation of dynamic property WCS_Retry_Admin::$setting_id is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-subscriptions/includes/payment-retry/admin/class-wcs-retry-admin.php on line 22

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/SchemaController.php on line 66

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/SchemaController.php on line 69

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/RoutesController.php on line 86

Deprecated: Creation of dynamic property wpdb::$payment_tokenmeta is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$order_itemmeta is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$wc_product_meta_lookup is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$wc_tax_rate_classes is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$wc_reserved_stock is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/includes/wc-core-functions.php on line 1705

Deprecated: Creation of dynamic property WooCommerce::$api is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/includes/class-woocommerce.php on line 554

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Internal/DownloadPermissionsAdjuster.php on line 157

Deprecated: Creation of dynamic property Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostToOrderTableMigrator::$table_names is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/PostToOrderTableMigrator.php on line 25

Deprecated: Creation of dynamic property Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostToOrderAddressTableMigrator::$table_names is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/PostToOrderAddressTableMigrator.php on line 42

Deprecated: Creation of dynamic property Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostToOrderOpTableMigrator::$table_names is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/PostToOrderOpTableMigrator.php on line 26

Deprecated: Creation of dynamic property Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostMetaToOrderMetaMigrator::$table_names is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/PostMetaToOrderMetaMigrator.php on line 43
Extending Logic Hop - Logic Hop

Extending Logic Hop

Quick Reference

Overview

Logic Hop offers a number of add-on integrations to connect third-party services such as Google Analytics, Drip and WooCommerce to provide personalization through conditions, goals and data display. We are constantly working to add new integrations so if there’s one you’d like to see, please contact us and let us know.

If you’re interested in building your own integration a great starting point is to download one of our existing add-ons and modify the code to work for your needs.

With Logic Hop 3.1.5 we’ve added functionality to make it easier to directly integrate data without an add-on integration through our Custom Object functionality.

Custom Post Types

Logic Hop supports Custom Post Types as of version 3.2.1.

Adding a Custom Post Type makes Custom Post data available for:

  • The current session
  • Future site visits

Custom Post data is stored in the Page variable and Pages and PagesSession arrays of the Logic Hop data variable.

Learn more about the Logic Hop data variable

Custom Post data can be used in Logic Hop Conditions with any Condition Type that supports page data.

Learn more about Condition Types

Enabling a Custom Post Type

To enable a Custom Post Type for use within Logic Hop you must add the post type using both PHP and Javascript (for the Condition Builder).

Javascript Code

Create a file within your theme folder named logichop-cpt.js with the following code, replacing your-custom-post-type with the post type of your Custom Post Type:

if (typeof logicHopCB !== 'undefined') {
    logicHopCB.addPostType('your-custom-post-type');
}

Multiple post types can be enabled by adding additional lines of logicHopCB.addPostType(‘custom-post-type’);

PHP Code

Add the following PHP Code to your functions.php file, replacing your-custom-post-type with the post type of your Custom Post Type:

function logic_hop_enable_cpt ( $types ) {
    $types[] = 'your-custom-post-type';
    return $types;
}
add_filter( 'logichop_update_data_post_types', 'logic_hop_enable_cpt' );

function logic_hop_enqueue_cpt_scripts () {
    wp_enqueue_script( 'logichop-cpt', get_stylesheet_directory_uri() . '/logichop-cpt.js', array( 'logichop' ) );
}
add_action( 'admin_enqueue_scripts', 'logic_hop_enqueue_cpt_scripts' );

Multiple post types can be enabled by adding additional lines of $types[] = ‘custom-post-type’;

Custom Taxonomies

Logic Hop supports Custom Taxonomies as of version 3.2.1.

Adding a Custom Taxonomy makes Taxonomy data available for:

  • The current session
  • Future site visits

Custom Taxonomies are stored in the Tag or Category variables and Categories and CategoriesSession or Tags and TagsSession arrays of the Logic Hop data variable.

Learn more about the Logic Hop data variable

Custom Taxonomy data can be used in Logic Hop Conditions with any Condition Type that supports tag or category data.

Learn more about Condition Types

Enabling a Custom Taxonomy

To enable a Custom Taxonomy for use within Logic Hop you must add the taxonomy using PHP (for the Condition Builder).

PHP Code

Categories

Add the following PHP Code to your functions.php file to add custom categories:

function logic_hop_enable_custom_categories ( $types ) {
    $types[] = 'your-custom-category';
    return $types;
}
add_filter( 'logichop_update_data_categories', 'logic_hop_enable_custom_categories' );

Multiple categories can be enabled by adding additional lines of $types[] = ‘your-custom-category’;.

Tags

Add the following PHP Code to your functions.php file to add custom tags:

function logic_hop_enable_custom_tags ( $types ) {
    $types[] = 'your-custom-tag';
    return $types;
}
add_filter( 'logichop_update_data_tags', 'logic_hop_enable_custom_tags' );

Multiple tags can be enabled by adding additional lines of $types[] = ‘your-custom-tag’;

Logic Hop Custom Object

The Logic Hop Custom Object is an empty container within the Logic Hop dataset to which you can read and write data. This data is available for individual users during their session on your website.

The Custom Object has no persistence beyond the current session, and if needed on repeat visits, you can associate specific users with their unique Logic Hop UID. User sessions end when the user quits their browser or after a period of inactivity – Typically twenty minutes.

Custom Object data is never sent to or stored in the Logic Hop database, so you can use it any way you see fit.

Note: Logic Hop stores temporary data in PHP sessions so it is important to take the amount of data into consideration. Smaller bits of data, such as numeric IDs, which can be looked up against other systems are typically ideal.

Store Custom Object Data with PHP

Storing data in the Custom Object with PHP is done using the logichop_update_data hook to pass your key and data into the $logichop->set_data( key, data ) method.

The following code adds an object to the key ‘my_key’:

function my_custom_stuff () {
    global $logichop;

    $my_data = new stdclass();
    $my_data->user_gender = 'female';
    $my_data->user_age = 42;

    $logichop->set_data( 'my_key', $my_data );
}
add_action( 'logichop_update_data', 'my_custom_stuff', 10, 2 );

Once your data has been stored in the Custom Object it is immediately accessible for use in conditions and display. The data can also be retrieved with Javascript or PHP.

Note: Custom Object keys must be a valid PHP variable name.

Learn how to viewed stored variables for testing.

Retrieve Custom Object Data with PHP

Custom Object data can be retrieved with PHP in the same manner as any Logic Hop data.

Return Data

global $logichop;
$logichop->get_data( 'LeadScore', false );

Echo Data

global $logichop;
$logichop->get_data( 'LeadScore', true );

Note that custom variables must be prefixed with ‘Custom’ when accessing them through get_data or echo_data:

$logichop->set_data( 'MyVariable', $some_data ); // set custom data
$logichop->get_data( 'Custom.MyVariable' ); // access custom data

Learn more about Logic Hop PHP.

Learn more about Logic Hop data variables.

Retrieve Custom Object Data with Javascript

Custom Object data can be retrieved with Javascript in the same manner as any Logic Hop data.

Return Logic Hop data via Javascript:

var my_key = logichop_var('Custom.my_key');

Learn more about Javascript Variables

Display Custom Object Data with Logic Tags

Similar to standard Data Logic Tags, Custom Object Logic Tags can be used to display content within pages and posts.

The following will display the user’s age’:

{{ var: Custom.my_key.user_age }}

Learn more about Data Logic Tags.

Evaluate Custom Object Data with Conditions

Logic Hop provides Custom Object Condition Types within the Logic Hop Condition Builder. These can be used to evaluate Custom Object data and personalize content based on the results.

Custom Object Condition

Condition Types

  • Custom Data Object
    • Is the Custom Data Object variable set to a specific value.
  • Custom Data Object Contains
    • Does the Custom Data Object variable contain a specific value.

Learn more about conditions.

User Data Action

Logic Hop provides a WordPress Action logichop_user_data_set that is triggered at various times user data is available, specifically:

  • When the user first visits your site
  • When the user logs in
  • When the user logs out

When triggered, the logichop_user_data_set action passes along the current WP_User instance and can be used in the following manner:

function your_function ( $user ) {
    // Your Code Here
}
add_action( 'logichop_user_data_set', 'your_function', 10, 1 );

This can be used in conjunction with the Logic Hop Custom Object to make user data from third-party plugins available for use in Logic Hop Conditions or with Logic Tags. The following is an example of adding user data to the Custom Object:

function your_user_data_function ( $user ) {
    global $logichop;

    $my_data = new stdclass();
    $my_data->user_gender = 'female';
    $my_data->user_age = 42;

    $logichop->set_data( 'my_key', $my_data );
}
add_action( 'logichop_user_data_set', 'your_user_data_function', 10, 1 );