LokiCheckout_AbTesting
A/B testing module for Loki Checkout skins, allowing merchants to test multiple checkout skins automatically.
Features
- Multi-skin selection: Select 2 or more Loki Checkout skins for A/B testing
- Two algorithms:
- Sequential: Cycles through skins consistently per checkout session
- Random: Randomly selects a skin for each checkout session
- Automatic activation: Enables when 2+ skins are configured
- Store-view specific: Different A/B tests per store view
- Graceful fallbacks: Returns to standard skin selection if configuration is invalid
JavaScript adaption
Note that this module allows for changing the skin dynamically in the frontend. It does not provide tracking of the actual skin used, for further analysis. For this, a JavaScript mechanism like Google Analytics can be applied, which should be configured to track the skin used. The current skin can be accessed via Alpine.js:
Alpine.store('LokiCheckout').currentSkin
Configuration
Navigate to: Stores → Configuration → Loki → Loki Checkout → A/B Testing
Configuration Options
-
Loki Checkout Skins (multiselect)
- Select at least 2 skins to activate A/B testing
- Available skins are pulled from
loki_checkout.xmlconfigurations - Config path:
loki_checkout/ab_testing/skins
-
Skin Selection Algorithm (dropdown)
- Sequential: Cycles through skins per checkout session (quote-based)
- Random: Randomly selects skin each time
- Config path:
loki_checkout/ab_testing/algorithm - Default: Sequential
How It Works
Plugin Architecture
The module uses a DI plugin on LokiCheckout\Core\Config\Config::getSkin():
- Target:
LokiCheckout\Core\Config\Config::getSkin() - Type: Around plugin
- Sort order: 10
Skin Selection Logic
- Check if enabled: Requires 2+ skins configured
- Get skins & algorithm from configuration
- Apply algorithm:
- Sequential: Uses checkout session to maintain consistency
- First access: calculates index using
quoteId % skinCount - Stores in session as
loki_ab_testing_skin_index - Subsequent calls in same session return same skin
- First access: calculates index using
- Random: Uses
array_rand()to select random skin
- Sequential: Uses checkout session to maintain consistency
- Validate skin: Checks skin exists in
XmlConfig::getSkins() - Fallback: Returns original
Config::getSkin()result if any issues
Session Storage
- Key:
loki_ab_testing_skin_index - Scope: Checkout session (Magento\Checkout\Model\Session)
- Type: Integer (array index)
- Purpose: Maintains skin consistency within checkout session
File Structure
app/code/LokiCheckout/AbTesting/
├── registration.php # Module registration
├── etc/
│ ├── module.xml # Module declaration (depends on LokiCheckout_Core)
│ ├── di.xml # Plugin configuration
│ └── adminhtml/
│ └── system.xml # Admin configuration UI
├── Config/
│ ├── Config.php # Config helper class
│ └── Source/
│ └── AlgorithmOptions.php # Algorithm dropdown options
└── Plugin/
└── ConfigSkinPlugin.php # Around plugin for Config::getSkin()
Installation
The module was installed on 2026-05-18:
cd /data/html/m2-loki-hyva docker-compose exec -T php-fpm bin/magento module:enable LokiCheckout_AbTesting docker-compose exec -T php-fpm bin/magento setup:upgrade docker-compose exec -T php-fpm bin/magento cache:flush
Dependencies
- LokiCheckout_Core: Required (provides Config class, SkinOptions, XmlConfig)
- Magento_Checkout: Required (provides CheckoutSession)
- Magento_Store: Required (provides ScopeConfigInterface)
Usage Example
Admin Configuration
- Navigate to: Stores → Configuration → Loki → Loki Checkout → A/B Testing
- In "Loki Checkout Skins", select 2+ skins (e.g., "default" and "onestep")
- In "Skin Selection Algorithm", choose "Sequential" or "Random"
- Save configuration
- Clear cache
Expected Behavior
With Sequential Algorithm:
- Customer 1 (quote ID 1): Gets skin at index 1 % 2 = 1 (e.g., "onestep")
- Customer 1 (continues session): Still gets "onestep"
- Customer 2 (quote ID 2): Gets skin at index 2 % 2 = 0 (e.g., "default")
- Customer 3 (quote ID 3): Gets skin at index 3 % 2 = 1 (e.g., "onestep")
With Random Algorithm:
- Each checkout session gets a random skin from the configured list
- Skin changes randomly between sessions
Disabling A/B Testing
To disable A/B testing:
- Select fewer than 2 skins in the configuration, OR
- Clear the "Loki Checkout Skins" field entirely
The module will automatically fall back to the standard skin selection from loki_checkout/general/theme.
Technical Details
Configuration Paths
| Setting | Path | Type | Scope |
|-----------|--------------------------------------|------|-------|
| Skins | loki_checkout/ab_testing/skins | multiselect (comma-separated) | Store view |
| Algorithm | loki_checkout/ab_testing/algorithm | select | Store view |
Constants
AlgorithmOptions.php:
ALGORITHM_SEQUENTIAL = 'sequential'ALGORITHM_RANDOM = 'random'
ConfigSkinPlugin.php:
SESSION_KEY_SKIN_INDEX = 'loki_ab_testing_skin_index'
Error Handling
The plugin includes multiple fallback layers:
- Not enabled (< 2 skins): Returns
$proceed()(original skin) - Invalid skin selected: Returns
$proceed()(original skin) - Session exception: Falls back to first skin in list
- Any other error: Returns
$proceed()(original skin)
Testing Scenarios
Test Case 1: Disabled (< 2 skins)
- Config: 0 or 1 skin selected
- Expected: Original skin from
loki_checkout/general/theme
Test Case 2: Sequential Algorithm
- Config: 2+ skins, algorithm = "sequential"
- Expected: Skin consistent within same checkout session
Test Case 3: Random Algorithm
- Config: 2+ skins, algorithm = "random"
- Expected: Different skins across different sessions
Test Case 4: Invalid Skin
- Config: 2 skins, one doesn't exist in loki_checkout.xml
- Expected: Falls back to original skin (no errors)
Future Enhancements
Possible v2 features (not implemented):
- Analytics tracking (which skin per order)
- Weighted distribution (e.g., 70% skin A, 30% skin B)
- Time-based rotation
- User segment-based testing (logged-in vs guest)
- A/B test management dashboard
- Statistical significance calculation
Support
For getting support, create an Issue under the following project URL:
https://gitlab.yireo.com/loki-checkout/LokiCheckout_AbTesting.git
Configuration Options
The following options of this module can be configured via the Store Configuration:
loki_checkout/ab_testing/enabled
loki_checkout/ab_testing/skins
loki_checkout/ab_testing/algorithm
Module Dependencies
The following dependencies are declared in the module its `etc/module.xml` file:
LokiCheckout_Core
Loki_Base
Loki_Components
Loki_CssUtils
Loki_FieldComponents
Loki_MapComponents
Magento_Backend
Magento_Catalog
Magento_CatalogInventory
Magento_Checkout
Magento_CheckoutAgreements
Magento_Config
Magento_Customer
Magento_Directory
Magento_Eav
Magento_Newsletter
Magento_Payment
Magento_Quote
Magento_Sales
Magento_SalesRule
Magento_Shipping
Magento_Store
Magento_Tax
Magento_Theme
Magento_Vault
Yireo_CspUtilities
Composer details
LokiCheckout_AbTestingloki-checkout/magento2-ab-testing
loki-checkout/magento2-core: ^2.3
magento/framework: ^103.0
magento/module-backend: ^102.0
magento/module-checkout: ^100.4
magento/module-config: ^101.2
magento/module-store: ^101.1
Releases
| 1.0.1 | 24 June 2026 |
| 1.0.0 | 24 June 2026 |
Changelog
[1.0.1] - 01 June 2026
Fixed
- Add
enabledflag to configuration - Rename
themetoskin - Add JS API to README
[1.0.0] - 18 May 2026
- Initial version