LogoLogo
HomepageCase studiesBook a demo
User Guide
User Guide
  • Welcome to Open Loyalty!
  • What's New
    • 2024
    • 2023
    • 2022
  • What's Next
  • Technical Guide
  • Main Features
    • Global Management
      • Analytics
      • Settings
      • Config Duplication
      • Usage
    • Dashboard
      • General Overview
      • Units Wallet Overview
      • Additional Metrics
      • Members by Tiers
    • Members
      • Member List
        • Configuration
        • Creating Members
        • Managing Members
        • Removing Members
      • Segments
        • Creating Segments
        • Managing Segments
        • Segment Conditions
      • Referred Members
    • Campaigns
      • Creating Campaigns
        • Return Campaign
        • Referral Campaign
        • Time-Based Campaign
        • Redemption Code Campaign
        • Internal event - Achievement progressed
        • Percent value distribution
      • Managing Campaigns
      • Campaign Simulation
      • Follow-up Campaigns
    • Custom Events
      • Custom Event Schemas
    • Transactions
      • Adding Transactions
      • Managing Transactions
      • Channels
    • Tiers
      • Adding Tiers
      • Managing Tiers
      • Tiers Configuration
      • Tier Benefits
    • Wallets
      • Wallet Types and Configuration
      • Unit Transfers
        • Creating Unit Transfers
        • Importing Unit Transfers
        • Managing Unit Transfers
    • Achievements
      • Creating Achievement
      • Managing Achievements
      • Follow up Achievements
    • Rewards
      • Reward List
        • Rewards Configuration
        • Creating Reward
        • Reward Types
        • Units Conversion Coupon
        • Adding Coupons
        • Reward Flow
      • Reward Fulfillment
      • Reward Categories
    • Webhooks
      • How to Configure a Webhook
      • What Triggers a Webhook
      • Expiring Notifications
    • Collections
    • Imports / Exports
      • Imports
        • Sample Import Files
      • Exports
        • UI Data Exports
        • Configuration Exports
        • S3 Bucket Exports
    • Settings
      • Roles
      • Admins
        • System Logs
      • Tenants
      • Translations
    • Expressions
      • Attributes List
      • Operators
      • Custom Functions
      • Expression Examples
      • Sample Use Cases
        • Using Member Custom Attributes
        • Complex Effects (if, else)
        • Excluding Members
        • Elapsed Time Conditions
        • Using Additional Dates for Calculations
        • Register on Birthday
        • Transaction on Birthday
        • Tier Upgrade or Downgrade
  • Sample Setups
    • Good Practices
    • Pay with Points
    • Promo and Discounts in Cart
    • Sample Campaigns
      • #1 Earn 1 point for every $1 spent
      • #2 Earn 2x points when shopping on Monday morning
      • #3 Earn 1 stamp for every transaction
      • #4 Buy product ACME 123 and earn 100 points
      • #5 Refer a friend and get 100 points
      • #6 Refer 5 friends and get a $50 off coupon for the next purchase
      • #7 Register to the program and get 50 bonus points
      • #8 Get 30 bonus points for your first transaction in the loyalty program
      • #9 Cashback campaign
      • #10 Product meets selected criteria
    • Sample Achievements
      • #1 Celebrate summer - Buy 5 times between June and August
      • #2 Place 10 Orders above 50€ - Complete 10 transactions, for more than 50€ each
      • #3 Ambitious player - Log in to the game 3 times per week for 8 consecutive weeks
      • #4 SKU 'ABC' configuration - Spend total of 100$ on products with SKU 'ABC132' in September
      • #5 Workout track -Track a workout of at least 30 minutes for 5 days in a row
      • #6 4 referees made the transactions for 2 consecutive weeks
      • #7 2 referees made a transaction configuration
  • FAQ
    • Configuration Migration
    • Custom Attributes
    • Achievements
    • GDPR
    • Opt-Out
    • Referral Programs
    • Returns and Cancellations
    • Timezones
Powered by GitBook
On this page
  • Overview of the Workflow
  • Sample Campaign Setup
  • API Endpoints Used
  • Campaign Simulation
  • Finalizing Transaction
  • Diagram of the Workflow
  • Important Notes

Was this helpful?

  1. Sample Setups

Promo and Discounts in Cart

This guide describes how to implement promo or discount calculations for items in the cart using Open Loyalty.

While Open Loyalty does not include a built-in promotion engine, it supports simulating promotions and discounts via campaign simulations. This approach enables dynamic value coupons or units that are leveraged during the checkout process without being consumed in real transactions.

Overview of the Workflow

The workflow for applying cart discounts and promotions involves the following key steps:

  1. Adding Items to the Cart The customer selects items and adds them to the shopping cart.

  2. Simulating Promotion Effects

    • The integration layer sends a simulation request with the transaction to calculate applicable promotions and discounts.

    • This is done by sending a request to Open Loyalty's POST /api/{storeCode}/campaign/simulate endpoint.

    • The transaction uses a defined label (e.g., type : simulation) to distinguish these transactions as non-final and ensure they do not trigger actual rewards.

  3. Displaying Discounts and Reduced Prices

    • The system processes the response, which includes campaign effects like discounts in the form of dynamic value coupons or units.

    • The integration layer applies these effects to adjust the cart's total and display the reduced price to the customer.

    • Optionally, it can display the rewards the customer would earn upon completing the transaction.

  4. Completing the Transaction

    • After the customer confirms the payment, the transaction is finalized and sent to Open Loyalty using the POST /api/{storeCode}/transaction endpoint (without the simulation label).

    • This triggers campaign effects such as rewards and units granting.

  5. Post-Transaction Notifications

    • Open Loyalty responds with a transaction ID and triggers a webhook (e.g., CampaignEffectWasApplied) to notify about campaign effects.

    • The customer is informed about the benefits earned from the transaction.


Sample Campaign Setup

To set up a campaign specifically for promo simulation purposes, you can create a campaign in Open Loyalty designed to calculate discounts dynamically.

Basic Setup for Promo Simulation Campaign

At a minimum, the campaign must include, for each rule, the condition Custom attribute has at least one custom attribute type:simulation. This ensures that the campaign is only used for simulation purposes and will not be triggered or grant rewards for completed transactions.

You can add additional conditions based on your specific needs to refine the campaign rules. Once the conditions are set, define the campaign effect using units or a predefined dynamic value coupon. The effect should retrieve either:

  1. The discount value For example, if the discount is 10% and applies when the cart value is at least £200, use the formula: transaction.grossValue * 0.1 This will return the discount value (£20 in this case).

  2. The total value after discount Using the same example, you can set the formula: transaction.grossValue * 0.9 This will return the discounted total (£180 in this case).

By customizing the conditions and effects, you can simulate any promo scenario, ensuring accurate discount calculations for your customers during checkout.


API Endpoints Used

Campaign Simulation

Endpoint: POST /api/{storeCode}/campaign/simulate Purpose: Simulate the transaction to calculate promo effects. Key Response Data: Campaign effects such as discounts or units that can be tracked for promos applied.

Sample payload:

{
    "simulate": {
        "customer": {
            "email": "example@example.com"
        },
        "transaction": {
            "purchasedAt": "2024-12-23 12:00+01:00",
            "documentNumber": "HDKA_2024",
            "labels": [
                {
                    "key": "type",
                    "value": "simulation"
                }
            ],
            "items": [
                {
                    "name": "Book Bundle",
                    "sku": "1001C",
                    "grossValue": 200,
                    "highPrecisionQuantity": 2
                }
            ]
        },
        "trigger": "transaction"
    }
}
```

Sample response:

{
    "effects": [
        {
            "type": "give_reward",
            "campaign": {
                "campaignId": "737b4a04-f03e-4441-99c3-f0f6b527c52e",
                ...
                "name": "Simulation Campaign",
                ...
            },
            "target": "self",
            "rewardId": "a2cd2a4b-5c98-4c04-8fb7-f500d0836ab2",
            
        },
        {
            "type": "give_points",
            "campaign": {
                "campaignId": "737b4a04-f03e-4441-99c3-f0f6b527c52e",
                ...
                "name": "Simulation Campaign",
                ...
            },
            "target": "self",
            
            "wallet": "default",
            "expression": "<#>transaction.grossValue</#>  *0.9"
        }
    ],
    "evaluationWarnings": []
}
```

Finalizing Transaction

Endpoint: POST /api/{storeCode}/transaction Purpose: Complete the transaction and trigger campaign rewards. Key Response Data: Transaction ID


Diagram of the Workflow


Important Notes

  • Simulation Transactions The simulation feature allows you to calculate discounts and promotions dynamically without using the associated rewards (e.g., coupons or units). These units are purely for simulation purposes and are not consumed or redeemed.

  • Integration Layer's Role The final cart amount and discount application are managed by the integration layer. Open Loyalty provides the simulation data, while the integration layer handles the logic to calculate and display the adjusted price.

This setup enables seamless discount simulations in the cart while leveraging Open Loyalty's campaign features. It requires minimal customization and provides a flexible framework for promo calculations.

Last updated 4 months ago

Was this helpful?