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
- Skin per order: The skin is stored with the quote and the order, and shown in the Magento Admin
Skin per order
The skin used in the checkout (as returned by LokiCheckout\Core\Config\Config::getSkin()) is stored in the column loki_checkout_skin of the table loki_quote_extended (module Loki_QuoteExtended). This also happens when A/B testing is disabled. Once the order is placed, Loki_QuoteExtended links this row to the order.
The Loki Checkout Skin is shown:
- On the order detail page in the Magento Admin (Account Information)
- As a column (with a text filter) in the order grid of the Magento Admin
While A/B testing is enabled, a skin stored with the quote is reused (as long as it is still configured and valid). This keeps the skin stable for the entire checkout, also with the Random algorithm.
JavaScript adaption
Besides the skin stored with the order, a JavaScript mechanism like Google Analytics can be applied 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 a skin once per quote
- 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 - A skin already stored with the quote takes precedence over both algorithms
- 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 and order grid configuration │ ├── db_schema.xml # loki_quote_extended / sales_order_grid columns │ └── 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() ├── Skin/ │ └── QuoteSkinStorage.php # Stores the skin per quote ├── ViewModel/Adminhtml/ │ └── OrderSkinView.php # Skin label on the admin order page └── view/adminhtml/ # Order view block and order grid column
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)
- Loki_QuoteExtended: Required (stores the skin per quote and links it to the order)
- 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 quote gets a random skin from the configured list, which is then stored and reused
- 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):
- 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
Current status
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
Loki_QuoteExtended
Magento_AdminNotification
Magento_Backend
Magento_Catalog
Magento_CatalogInventory
Magento_Checkout
Magento_CheckoutAgreements
Magento_Cms
Magento_Config
Magento_Cron
Magento_Csp
Magento_Customer
Magento_Directory
Magento_Eav
Magento_Indexer
Magento_MediaStorage
Magento_Newsletter
Magento_Payment
Magento_Quote
Magento_Rule
Magento_Sales
Magento_SalesRule
Magento_SalesSequence
Magento_Shipping
Magento_Store
Magento_Tax
Magento_Theme
Magento_Ui
Magento_User
Magento_Variable
Magento_Vault
Magento_Widget
Yireo_CspUtilities
Composer details
LokiCheckout_AbTestingloki-checkout/magento2-ab-testing
loki-checkout/magento2-core: ^2.3
loki-checkout/magento2-quote-extended: ^0.0.2
magento/framework: ^103.0
magento/module-backend: ^102.0
magento/module-checkout: ^100.4
magento/module-config: ^101.2
magento/module-store: ^101.1
php: >=8.2 <8.6
psr/log: ^1.0 || ^2.0 || ^3.0
Releases
| 1.0.3 | 11 November 2026 |
| 1.0.2 | 11 November 2026 |
| 1.0.1 | 11 November 2026 |
| 1.0.0 | 11 November 2026 |
Changelog
[1.0.3] - 01 October 2026
Removed
- Remove PHP 8.1 support from pipeline, add PHP 8.5 support
[1.0.2] - 28 August 2026
Fixed
- Make sure system.xml tooltips and comments are translatable
[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