Using Logic Hop with WooCommerce

Note: WooCommerce functionality requires the Logic Hop WooCommerce Add-on.

WooCommerce & Logic Hop

Logic Hop integrates with WooCommerce to provide personalization using WooCommerce data. You can easily create conditions and display WooCommerce data to create an engaging, personalized experience.

WooCommerce data such as products viewed, categories viewed, purchase history and shopping cart contents can be used in Logic Hop Conditions to determine what content to display and when to display it.

WooCommerce Quick Start Guide

Here’s a simple example that checks if your visitor has products in their cart – If they do, the number of items is displayed. If they don’t, they’ll see a “your cart is empty” message.

Step 1

Create a new page titled “WooCommerce Test”

Step 2

Add the following Shortcode or Javascript:

<!-- Use shortcodes when Javascript Tracking is not enabled -->
[logichop_condition id="woocommerce_cart_empty" condition="woocommerce_cart_empty"]
<h2>Your cart is empty.</h2>
[/logichop_condition]
[logichop_condition id="woocommerce_cart_full" condition="woocommerce_cart_full"]
<h2>Number of items in your cart: [logichop_data var='WooCommerce.Cart']</h2>
[/logichop_condition]

<!-- Use this code when Javascript Tracking & Javascript Variables are enabled -->
<div class="logichop-js" data-cid="woocommerce_cart_empty" style="display: none;" data-event="show">
<h2>Your cart is empty.</h2>
</div>
<div class="logichop-js" data-cid="woocommerce_cart_full" style="display: none;" data-event="show">
<h2 class="logichop-js" data-var="WooCommerce.Cart" data-type="append" data-event="show">Number of items in your cart: </h2>
</div>

Step 3

That’s all there is to it! Now view the page with and without products in your cart to see the messaging in action.

Configuring WooCommerce

Download and install the WooCommerce Add-on, then click Activate. That’s it!

Click here for Add-on installation instructions.

WooCommerce Add-on Activated

Displaying WooCommerce Data

Logic Hop provides a variety of integration points for WooCommerce including WooCommerce user data display within WordPress content using Shortcodes, Javascript or PHP.

Display WooCommerce Data with Shortcodes

Shortcodes can be added from the Logic Hop tool in the WordPress Page/Post editor. Click the Data tab, select a value and click “Insert Shortcode”.

WooCommerce Data Shortcode

The Logic Hop Data Shortcode is a single block of code which appears as:

[logichop_data var="WooCommerce.Customer.FirstName"]

If the data is available for the user, it will be displayed on the page. Shortcodes can be nested within HTML tags and also within Logic Hop Condition Shortcodes.

To check if data is available before display, use the default Condition Customer Data Available:

<!-- Use shortcodes when Javascript Tracking is not enabled -->
[logichop_condition id="woocommerce_customer" condition="woocommerce_customer"]
<h2>Welcome back [logichop_data var="WooCommerce.Customer.FirstName"]!</h2>
[/logichop_condition]

Display WooCommerce Data with Javascript

Javascript variables can be added from the Logic Hop tool in the WordPress Page/Post editor. Click the Data tab, select a value and click “Insert Variable Javascript”.

The Logic Hop Javascript Variable is a single block of code which appears as:

<span class="logichop-js" data-var="WooCommerce.Customer.FirstName" data-event="show"></span>

To check if data is available before display, use the default Condition Customer Data Available:

<!-- Use this code when Javascript Tracking & Javascript Variables are enabled -->
<div class="logichop-js" data-cid="woocommerce_customer" style="display: none;" data-event="show">
<h2 class="logichop-js" data-var="WooCommerce.Customer.FirstName" data-type="append" data-event="show">Hello </h2>
</div>

WooCommerce Data via PHP

WooCommerce data can be accessed via PHP for use in themes. Pass the variable name as a string into the $logichop->get_data() function.

Echo WooCommerce data via PHP:

global $logichop;
$logichop->get_data('WooCommerce.Customer.FirstName');

Return WooCommerce data via PHP:

global $logichop;
$logichop->get_data('WooCommerce.Customer.FirstName', false);

A list of Logic Hop variables can be viewed on the Condition Type & Operator Reference page.

Using WooCommerce with Conditions

WooCommerce activity and data can be used as parameters in Logic Hop Conditions. Default Conditions are provided for common scenarios and are accessible from the Logic Hop tool palette in the Page/Post editor.

WooCommerce Default Conditions

  • WooCommerce Shopping Cart is Empty
    • If the cart is empty
  • WooCommerce Shopping Cart has Products
    • If the cart is not empty
  • WooCommerce Customer Data Available
    • If customer data is available
    • Useful when displaying user data
  • WooCommerce Paying Customer
    • If the user is a paying customer

WooCommerce Default Conditions

The Logic Hop Condition Builder will display all WooCommerce types available for use. Each can be used alone to create custom Conditions or combined with others for complex logic.

WooCommerce Condition Types

  • WooCommerce Shopping Cart
    • Is the cart empty or does it have products
  • WooCommerce Customer Data Available
    • Is customer data available
  • WooCommerce Paying Customer
    • Is this a paying customer
  • WooCommerce Orders
    • The number of orders the visitor has made
  • WooCommerce Total Spend
    • The total amount of money the visitor has spent
  • WooCommerce Product in Cart
    • Is a specific product in the cart
  • WooCommerce Product Views – All Visits
    • Has a specific product been viewed during any visit
    • Note: Storing data beyond the current visit requires a data plan
  • WooCommerce Product Views – Current Session
    • Has a specific product been viewed during the current session
  • WooCommerce Product Purchased
    • Has a specific product been purchased
  • WooCommerce Product in Category
    • Is a product in a specific category
  • WooCommerce Category Views – All Visits
    • Has a category been viewed during any visit
    • Note: Storing data beyond the current visit requires a data plan
  • WooCommerce Category Views – Current Session
    • Has a category been viewed during the current session
  • WooCommerce Purchase from Category
    • Has a purchase been made from a specific category
  • WooCommerce Product has Tag
    • Does the product have a specific tag
  • WooCommerce Tag Views – All Visits
    • Has a tag been viewed during any visit
    • Note: Storing data beyond the current visit requires a data plan
  • WooCommerce Tag Views – Current Session
    • Has a tag been viewed during the current session