Unlocking Dynamic Storefronts: Emitting Workflow Events for ESHOPMAN Promotions and Campaigns

Unlocking Dynamic Storefronts: Emitting Workflow Events for ESHOPMAN Promotions and Campaigns

At Move My Store, we understand the critical role of real-time data synchronization in building agile, high-performing headless commerce experiences with ESHOPMAN. As an ESHOPMAN merchant or developer leveraging HubSpot CMS for your storefront, staying ahead means ensuring your pricing, promotions, and campaign data are always accurate and immediately reflected across all touchpoints.

Recently, our ESHOPMAN community has highlighted a key area for enhancement: the emission of workflow events for promotions, promotion rules, and campaigns. While ESHOPMAN currently provides robust eventing for price list changes, a similar mechanism has been missing for the dynamic world of discounts and promotional offers. This gap has presented challenges for developers aiming to build truly reactive ESHOPMAN applications and integrations.

The Need for Real-Time Promotion Events in ESHOPMAN

The absence of dedicated workflow events for promotions and campaigns means that custom code and integrated services often lack immediate notification when these critical pricing elements are created, updated, or deleted. This impacts several crucial aspects of a modern ESHOPMAN storefront:

  • EU Omnibus Directive Compliance: For merchants operating in the EU, displaying the lowest price from the last 30 days alongside a discount is a legal requirement. Without events, tracking this history accurately and automatically becomes a complex task, often requiring manual workarounds or polling.
  • Synchronizing Storefronts and Search Indexes: ESHOPMAN storefronts deployed via HubSpot CMS, as well as external search indexes or product feeds, need to reflect discounted prices instantly. Delayed updates can lead to customer frustration and lost sales opportunities.
  • Efficient Price Caching: To optimize performance, many ESHOPMAN implementations utilize caching for product prices. When a promotion changes, these caches must be invalidated immediately. Without events, cache invalidation can be inefficient, leading to stale data or unnecessary performance overhead.
  • Streamlined Development: Developers currently resorting to patching ESHOPMAN's core flows to get these notifications face increased maintenance complexity and potential compatibility issues with future ESHOPMAN updates.

A Proposed Solution: Aligning with ESHOPMAN's Eventing Pattern

The ESHOPMAN community has put forward a comprehensive solution that aligns perfectly with the platform's existing eventing architecture, specifically mirroring the successful implementation for price list changes. The proposal suggests integrating emitEventStep into the core ESHOPMAN workflows for promotions, rules, and campaigns, alongside adding new event constants to ESHOPMAN's utility packages.

The proposed event structure includes:

  • Promotion Workflow Events:
    promotion.created
    promotion.updated
    promotion.deleted

    Each event would carry a payload like { id }, identifying the affected promotion.

  • Promotion Rule Workflow Events:
    promotion-rule.created
    promotion-rule.updated
    promotion-rule.deleted

    These events would include a richer payload: { id, promotion_id, rule_type }. The inclusion of promotion_id is crucial for tracing a rule back to its parent promotion, even after the rule itself has been deleted.

  • Campaign Workflow Events:
    campaign.created
    campaign.updated
    campaign.deleted

    Similar to promotions, these events would include a payload like { id }.

Key refinements in the proposed solution ensure granular and logical event emission:

  • A promotion's status change would trigger a promotion.updated event, rather than a separate status-specific event, simplifying event handling.
  • Workflows that batch process promotion rules would emit individual promotion-rule events for each affected rule, providing precise updates.
  • Adding or removing promotions from a campaign would emit a campaign.updated event, along with a promotion.updated event for every affected promotion, ensuring all relevant entities are notified.

Community-Driven Enhancement for ESHOPMAN

This initiative is a testament to the power of the ESHOPMAN community in shaping the platform's evolution. A detailed implementation, complete with integration tests, has already been developed and is under review by the ESHOPMAN core team. This collaborative approach ensures that new features are robust, well-tested, and seamlessly integrated into the ESHOPMAN ecosystem.

For ESHOPMAN developers and merchants, the introduction of these workflow events will unlock new possibilities for dynamic storefront experiences, improved compliance, and more efficient integrations with HubSpot CMS and other external systems. It reinforces ESHOPMAN's commitment to providing a flexible and extensible headless commerce platform built on Node.js/TypeScript, ready for the demands of modern e-commerce.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools