Akinon Release Notes (05/26/2025) are now live! Click here to learn what's new.
LogoLogo
API Reference
  • Home
  • Quick Start
  • Tutorials
  • Technical Guides
  • Release Notes
  • Glossary
  • Welcome to Akinon Technical Guides
  • ACC
    • ACC CLI
    • Create Application via CLI
    • Deploy Environment Variables
    • App Store for Developers
  • Omnitron
    • Product Types
    • Product Categorization
    • Splitting a Merged Order Item
  • Commerce
    • Shipping Rules Calculator
    • Data Source Shipping Options
    • Attribute Based Shipping Options
    • Filtering Products
    • Conversation & Messages
    • Sitemap Configuration
    • Weight-Based Product Sales
    • Group Attribute Sets
    • Contract Management
    • Find in Store for Whippy Ware
    • Plugins
    • Remote Price
    • E-mail Templates
    • Loyalty Accounts
    • Search Structure
    • User Segmentation & Rules
    • Configuring User Segmentation
    • Promotions
    • Email Redirection in Multi-Frontend Structure
  • OMS
    • Getting Started with OMS
    • Basic Setup
    • Scenarios
    • Capacity Feature
    • Package Management
      • Packages
      • Transfer
      • States
    • Commands
      • Packages
        • Package Command Parameters
        • DeAllocate Package Reservations Command
        • Channel Based Complete Packaging without Shipment Command
        • Complete Packaging with Shipment Command
        • Complete Packaging without Shipment Command
        • Package Refuse with Denial Reason Command
        • Product Not Found & Wrong Product Command
        • Product Not Found & Wrong Product Command Advanced
        • Package Packed for Refund Command
        • Block The Package For Action Command
        • Unblock the Package For Action Command
        • Update The Package’s Invoice
        • Manual Planning Command
      • Transfer
        • Transfer Order Advanced Command
        • Product for Transfer Not Found & Wrong Product Command
        • Transfer Delivered Command
        • Transfer Dispatch Command
        • Transfer Ready for Dispatch Command
        • Transfer Out Of Stock
      • Shipment
        • Shipment Order Command
        • Package Advanced Shipment Command
        • Ship The Package Command
        • Ship The Package without Shipment Integration Command
        • Update The Package’s Shipment Status Command
        • Update Shipment Info of Package Command
    • Inventory Locations & Engine
      • Properties & Domain Relation
      • Customization
      • Inventory Engine
    • Fulfillment
      • Shipments
      • Invoice Integration
    • Webhooks
      • Webhook Examples
        • Order Webhook
        • Package Webhook
        • Shipment Webhook
        • Stock Location Webhook
        • Transfer Webhook
    • Integrating OMS with Seller Center
  • Instore
    • Getting Started
    • Cash Register Integration
    • OTP (One Time Password) Process
    • Services
      • Password Reset Services
  • Marketplace Dashboard
    • N11 Marketplace Setup Configurations
    • Trendyol Marketplace Setup Configurations
    • Walmart Marketplace Setup Configurations
    • Amazon Marketplace Setup Configurations
    • Hepsiburada Marketplace Setup Configurations
    • Fashfed Marketplace Setup Configurations
    • Mono Marketplace Setup Configurations
    • Package Splitting Flow
    • Marketplace Dashboard Flow Trigger
  • Project Zero
    • Django
      • Basic Setup
      • Project Structure
        • Templates & Components
        • Private Dependencies
        • Omnife Project Submodule
        • Webpack
        • ESLint Rules
        • Bundles
        • Multilanguage & Translation
        • Environmental File
        • Custom Error Pages
        • Icon Font
      • Page Types
        • Static Pages & Flatpages
        • Account Page
          • Template Rendering in Account Pages
          • Forms & Validation
        • Basket Page
          • Redux Basket State
          • Basket Page - View
        • Checkout
          • Redux Checkout State
          • View & Template Rendering
          • Masking & Validation
      • Theming & Styling
      • Widgets
      • SEO Management
      • Extending Project Zero
    • Next.js
      • Basic Setup
      • Deployment
      • Static Assets
      • Plugins
      • Widgets
      • Icons
      • Localization
      • SEO Management
      • Advanced Usage
      • Data Fetching
        • Client
          • Account
          • Address
          • Basket
          • Checkout
          • Misc
          • Product
          • User
          • Wishlist
        • Server
          • Category
          • Flat Page
          • List
          • Menu
          • Product
          • SEO
          • Special Page
          • Widget
  • App Maker
    • Setup Your Environment
    • Plugin Quickstart
    • Create Project
    • Setup Existing Project
    • Deploy Project
    • Users and Roles
    • Add Public Key
    • App Maker CLI
    • Create App on Stores
      • Creating App on Apple App Store
      • Creating App on Google Play Store
    • Mobile App Framework
      • Configuration
      • Framework
      • Project Structure
        • Structure
        • Data Containers
        • Pages
      • Dependency Integration
        • Plugins
        • Akinon Plugin Adapter
  • Akifast
    • HPP
      • Getting Started
      • Authorization
      • Payment Session Creation
        • Key Points Before Creating a Payment Session
        • Creating Payment Session
        • Redirecting to the Payment Page
        • Errors Encountered During Payment Session Creation
      • Merchant Services
        • Shipping Query URL
        • Agreement Query URL
        • Other URLs
  • B2B
    • Getting Started
    • B2B Setup
  • Adds-on
    • Invoicer
      • Introduction
      • Invoice & Pay On Delivery Service
  • Channel App Template
    • Introduction
    • Installation and Usage
    • Development Steps
      • Folder Structure
      • Starting Step
      • Encoding the Sales Channel
        • Introduction
        • Setup
        • Products
        • Product Price
        • Product Stock
        • Product Image
        • Orders
        • Product Data
      • Adding a New Command to Akinon
      • Listening for External Requests
    • Architecture
      • Introduction
      • Integration
      • Services (Flows)
        • Introduction
        • Product Service
        • Price Service
        • Stock Service
        • Image Service
        • Order Service
  • Multi Regional Settings
    • Multi Regional Settings
Powered by GitBook

© 2025 Akinon. All rights reserved.

On this page
  • How It Works
  • Commerce Configuration
  • 1. Custom Account Adapter
  • 2. Valid Frontend IDs Setting
  • User Schema Configuration in Omnitron
  • Add frontend_id to the User Schema
  • Frontend Implementation
  • Email Template Implementation

Was this helpful?

  1. Commerce

Email Redirection in Multi-Frontend Structure

This guide describes the configuration required to enable frontend-aware email redirection in a Commerce environment with multiple frontend domains. In multi-tenant or multi-regional setups, users must receive emails with redirect links that point to the appropriate frontend based on their original interaction. This feature ensures that all links in transactional emails are correctly generated per the frontend that initiated the request.

In a traditional setup, email templates generate links using a static domain or path. In projects supporting multiple frontends (e.g., UAE, Kuwait), this approach causes inconsistencies, potentially redirecting users to the wrong site. For example, a user interacting with example.com/ae might receive an email containing a link to example.com/kw.

With this feature, frontend identification is embedded in each request via a custom header. The backend reads this information and uses it to generate the correct domain and path in email templates.

How It Works

  1. Frontend Identification: Every API request includes an x-frontend-id header that specifies which frontend initiated the request.

  2. Backend Context Injection: A custom account adapter captures this header and injects it into the template rendering context.

  3. Email Template Logic: The email template uses this context or fallback values from the user profile to determine the appropriate domain path.

  4. URL Generation: Email links are constructed dynamically, resulting in accurate redirection per user.

Commerce Configuration

1. Custom Account Adapter

To support frontend-aware context in all authentication operations (user registration, password reset, etc.), a custom account adapter must be used:

ACCOUNT_ADAPTER = 'omnishop.users.allauth_adapter.CustomDefaultAccountAdapter'

The CustomDefaultAccountAdapter reads the x-frontend-id from incoming HTTP requests and passes it as frontend_id in the rendering context. This makes it available within email templates and other processes requiring frontend-aware logic.

If you already have a custom adapter, make sure it inherits from or incorporates the same logic as CustomDefaultAccountAdapter.

2. Valid Frontend IDs Setting

The VALID_FRONTEND_IDS configuration defines all acceptable frontend identifiers used by the system. It prevents invalid or unknown frontend values from affecting link generation.

This setting is managed via dynamic settings and must follow the structure below:

VALID_FRONTEND_IDS = [
    {"id": "1", "name": "Kuwait Frontend"},
    {"id": "2x", "name": "UAE Frontend"},
    // Additional frontend entries
]

Field Definitions:

  • id: A unique string identifier (CharField) sent by the frontend in the x-frontend-id header. It is used for routing and URL generation.

  • name: A human-readable name for distinguishing frontend entries in configuration UIs. Not used in logic.

If an unknown or undefined id is provided, the backend will treat the frontend_id as None, which may affect the resulting URL paths in email templates.

User Schema Configuration in Omnitron

To persist the user’s frontend source, the frontend_id field must be added to the user schema in Omnitron. This allows email redirection logic to work even when the email is triggered by an external system (e.g., Omnitron).

Add frontend_id to the User Schema

curl --location --request PUT 'https://{omnitron_url}/api/v1/remote/1/schema_types/user/' \
--header 'authorization: Token YOUR_API_TOKEN_HERE' \
--header 'Content-Type: application/json' \
--data '{
   "schema": {
       "frontend_id": {
           "required": false,
           "data_type": "text",
           "key": "frontend_id",
           "label": "Frontend ID"
       }
       // include the rest of the schema as-is
   }
}'

Behavior:

  • When a user registers or makes an authenticated request from the frontend, the x-frontend-id value is automatically recorded in the user object under user.attributes.frontend_id.

  • This value becomes available in all contexts where user attributes are accessible, such as email templates triggered outside of the Commerce backend.

Frontend Implementation

Every frontend application that sends API requests to the backend must include the x-frontend-id HTTP header.

x-frontend-id: 1

This value must match one of the defined entries in the VALID_FRONTEND_IDS list. If it does not, backend logic will treat the frontend as undefined for email redirection purposes.

API Request Example:

Here is an example password reset request from a frontend application:

curl --location 'https://{commerce_url}/users/password/reset/' \
--header 'x-frontend-id: 1' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email": "example@example.com"
}'

In this request, x-frontend-id: 1 indicates the request originates from the Kuwait frontend, and links in the email will be tailored accordingly.

Email Template Implementation

To generate frontend-aware links in email templates, use both the incoming frontend_id from context and the fallback stored in user.attributes.frontend_id.

Example Snippet:

{# Get frontend ID from context or fallback to user attribute #}
{% set x_frontend_id = frontend_id or user.attributes.get("frontend_id") %}

{# Define dynamic path based on frontend ID #}
{% if x_frontend_id == "1" %}
    {% set dynamic_path = "/frontend_id_1" %}
{% elif x_frontend_id == "2x" %}
    {% set dynamic_path = "/frontend_id_2" %}
{% else %}
   {% set dynamic_path = "/defualt" %}
{% endif %}

{# Construct the final confirmation URL #}
{% set confirm_url = "https://" + current_site.domain + dynamic_path + url('account_confirm_email', key=key) %}

<a href="{{ confirm_url }}">{{ confirm_url }}</a>

Template Variables Explained:

  • frontend_id: Retrieved from the incoming request context, if available.

  • user.attributes.get("frontend_id"): Fallback value stored in the user schema, typically used when the email is triggered by the other system (e.g., Omnitron).

  • dynamic_path: A frontend-specific prefix that adjusts the final URL path. Dynamically determined based on the identified frontend_id.

    • If neither frontend_id from context nor user.attributes.frontend_id is available, a default path (/default) is applied to avoid broken URLs and ensure graceful degradation.

  • confirm_url: Final redirect URL combining domain, path, and endpoint.

To ensure robustness and prevent misrouted or invalid links in email templates, a fallback block should be explicitly defined in the template logic as shown below:

{% else %}
    {% set dynamic_path = "/default" %}
{% endif %}
PreviousPromotionsNextOMS

Last updated 3 days ago

Was this helpful?