Expression of Interest

The Expression of Interest system allows customers to register their interest in out-of-stock products. When products are restocked, the system automatically notifies registered customers via email. This guide covers implementation, configuration, and customization of the EOI feature.

System Overview

EOI provides a complete workflow for managing customer interest in out-of-stock products:

Configuration

Enable EOI Feature

To activate the Expression of Interest feature:

  1. Navigate to Core dna admin
  2. Go to Catalogues module → Configure → Manage Configuration
  3. Enable the "Allow Expression Of Interest" switch

Template Implementation

Required Templates

Two main templates are required in your site directory:

sitedir/modules/prodcatalogue/templates/main_product_interest.html sitedir/modules/prodcatalogue/templates/product_interest.html
Note: If these templates are not found, Core dna will use default templates.

Product Interest Template

Example implementation of product_interest.html:

<{if !empty($products)}>

        <{foreach from=$products item="product"}>
          <{$product->getName()}>
        <{/foreach}>
        <{foreach from=$variants item="variant"}>
          <{$variant->getText()}>
        <{/foreach}>
    


Product name
<{$product->getName()}>
<{$variant->getText()}>
<{/if}>

Main Product Interest Template

Example implementation of main_product_interest.html:

Hello,

These products are now back in stock!



*|productsHtml|*


Thank you,

<{$centre->getName()}>
Template Integration: Use the keyword *|productsHtml|* to include the product_interest.html template. The product_interest template has access to $products, $variants, and $centre array/object.

Implementing the Registration Form

Display Block Function

Use this block function to display the 'Register Your Interest' form:

<{if $allow_eoi && $product->getQty() <= 0}>
    <{show_block module='prodcatalogue'
    block='show_product_interest'
    product_id=$product->getID()
    template_name="block_show_product_interest"}>
<{/if}>

Registration Form Template

Create block_show_product_interest.html in your templates directory with this implementation:

<div style="width: 400px">
    Register your interest for product: <{$product->getName()}><br>
    <label for="email">Email:</label>
    <input type="text" 
           name="eoi_email" 
           id="eoi_email" 
           onkeyup='if (jQuery("#eoi_email").val()) { jQuery("#eoi_message").html(""); }' 
           placeholder="Enter your email">
    <div id="eoi_message"></div>
    <button type="button" 
            onclick="submitExpressionOfIntrest(<{$product->getID()}>)">
        Submit
    </button>
</div>

<script>
    function submitExpressionOfIntrest(productId) {
        var productId = productId || null;
        var email = jQuery('#eoi_email').val();

        if(!email) {
            jQuery("#eoi_message").html('Please enter an email address');
            return;
        }
        if (!productId) {
            jQuery("#eoi_message").html('There was an error');
            return;
        }

        jQuery.ajax({
            url: "/index.php?action=prodcatalogue&form_name=register_interest&type=json",
            type: 'POST',
            beforeSend: function(xhr) {
                xhr.setRequestHeader('X-CSRF-Token', '<{$eoi_csfrtoken}>');
            },
            data: {
                email: email,
                product_id: productId,
                variant_id: variantId
            }
        }).success(function(response) {
            if (response.success) {
                jQuery("#eoi_email").val('');
                jQuery("#eoi_message").html(response.message);
            } else {
                jQuery("#eoi_message").html(response.message);
            }
        });
    }
</script>
Security Note: CSRF security checking is performed on form submission. Failed checks will result in a 401 forbidden response.

Email Notification System

Setting Up Notifications

  1. Navigate to the Hooks module (Cog Wheel → Hooks)
  2. Add a new Hook
  3. Select the ExpressionOfInterestNotification event
Event Triggers: The event is triggered when a product's stock changes from zero to positive and has waiting customers.

Email Template Example

<p>HI <{$user->getFirstname()}>, 
    <strong><{$product->getName()}></strong> 
    PRODUCT IS BACK IN STOCK</p>

Removing Users from Wait List

Create an "Evaluate Template" action with this code to remove notified users:

<!-- Use getField(email) for guest compatibility -->
<{$product->removeExpressionOfInterestByEmail($user->getField('email'))}>
Important: This removal action is crucial to prevent duplicate notifications. Without it, users will receive notifications each time the event triggers.

Response Handling

Success Response

{"success":true,"message":"Your interest submitted successfully"}

Duplicate Registration Response

{"success":false,"message":"This email has already registered for this product"}

Best Practices