πŸ“ Bolt / Developers / Developer Guides / Checkout Setup / Managed Checkout Setup / Manage Bolt for Adobe Commerce / Set Up SSO Commerce for Adobe Commerce

Set Up SSO Commerce for Adobe Commerce

Prerequisites

  • You have contacted Bolt and begun account migration
  • You have contacted Bolt and requested SSO Commerce to be enabled for your account
  • You have made a copy of your active theme as a backup

How to Set Up SSO Buttons and Scripts

1. Replace all Log in and Track My Order buttons

  1. Log in to the M2 Admin Console.
  2. Navigate to Stores > Configuration > Sales > Payment Methods > Bolt.
  3. Enable Bolt SSO Commerce.

You can also run the following command instead: sudo php bin/magento config:set payment/boltpay/bolt_sso 1

Examples include:

  • Wishlist buttons
  • My Account buttons

You can specify where a link or button redirects to after successful login, using the following HTML attribute: data-destination-on-success=”{{urls.accounts.example.all}}”

For example, you can redirect to a wishlist when a non-logged in user selects a wishlist link. This would present the SSO Commerce modal for authentication before redirecting the shopper to their wishlist page.

data-destination-on-success=”{{urls.accounts.wishlists.all}}”

2. Install Required Scripts

  1. Navigate to Content > Blocks.
  2. Add a new block:
    • Name: Bolt SSO JS
    • Identifier: bolt-js
  3. Save.
  4. Navigate to Content > Widgets.
  5. Create a new widget:
    • Name: Bolt SSO JS
    • Theme: Select the active theme.
  6. Save.
  7. Navigate to Widget Options.
  8. Add the Bolt SSO JS block.
  9. Scroll to Layout Updates.
  10. Select Display on Every Page.
  11. Choose the Page Header as the container.
  12. Add a script element with the following custom Javascript to the Bolt SSO JS block:
    <!-- You can add any additional custom CSS here -->
<style>
    .block-amazon-login {
        display: none;
    }

    .login-container {
        display: none;
    }

    .form-create-account {
        display: none;
    }

    .login-page-sso {
        --bolt-account-sso-font-size: 16px;
        --bolt-account-sso-font: 'Roboto','Helvetica Neue',Helvetica,Arial,sans-serif;
        --bolt-account-sso-color: #fff;
    }

    .login-page-sso button {
        background-color: #18284C;
        border: none;
    }
</style>

<!-- This script selects and replaces the native sign-in, register, and logout buttons -->
<script>
    function insertButtons() {
        if (typeof BoltAccount === 'undefined') {
            window.setTimeout(insertButtons, 100);
            return;
        }

        BoltAccount.injectButtons();
    }

    function insertAccountScript() {
        var scriptTag = document.getElementById('bolt-account');
        if (scriptTag) {
            return;
        }
        scriptTag = document.createElement('script');
        scriptTag.setAttribute('type', 'text/javascript');
        scriptTag.setAttribute('async', '');
        scriptTag.setAttribute('src', '{account-url}/account.js');
        scriptTag.setAttribute('id', 'bolt-account');
        scriptTag.setAttribute('data-publishable-key', '{publishable-key}');
        document.head.appendChild(scriptTag);
    }

    function replaceButtons() {
        let loginButton = document.querySelector('[href^="{store-url}/customer/account/login/"]')
        let registerButton = document.querySelector('[href="{store-url}/customer/account/create/"]');
        let logoutButton = document.querySelector('[href="{store-url}/customer/account/logout/"]');

        // one of these buttons should be present. if not, the page likely just hasn't loaded yet
        if (!registerButton && !loginButton && !logoutButton) {
            window.setTimeout(replaceButtons, 100);
            return;
        }

        if (registerButton) {
            registerButton.removeAttribute('href');
            registerButton.setAttribute('class', registerButton.getAttribute('class') + ' bolt-sso-custom');
            registerButton.setAttribute('style', 'cursor:pointer;');
        }

        if (loginButton) {
            loginButton.removeAttribute('href');
            loginButton.setAttribute('class', loginButton.getAttribute('class') + ' bolt-sso-custom');
            loginButton.setAttribute('style', 'cursor:pointer;');
        }

        if (logoutButton) {
            logoutButton.removeAttribute('href');
            logoutButton.setAttribute('class', logoutButton.getAttribute('class') + ' bolt-sso-custom');
            logoutButton.setAttribute('data-logged-in', 'true');
            logoutButton.setAttribute('style', 'cursor:pointer;');
        }

        insertButtons();
    }

    insertAccountScript();
    replaceButtons();
</script>

{account-url} should be one of the following:

  • Sandbox: https://account-sandbox.bolt.com
  • Production: https://account.bolt.com

{store-url} should be your adobe commerce store URL.

3. Customize Button Styling

Use the following styles to override the button’s font and icon color:

<style>
    --bolt-account-sso-color: #fff;
    --bolt-account-sso-font: 'Verdana';
    --bolt-account-sso-font-size: 16px;
    --bolt-account-sso-font-weight: 700;
</style>

You can also add classes to the bolt-account-sso div as necessary to customize the style further.

Do not replace icon-only buttons. Instead, add class=”bolt-sso-custom" data-logged-in="true/false". This enables the icon button to trigger Bolt SSO instead of redirecting to the platform login page.

4. Replace Login and Create Account Pages

Ensure that the native Login and Create Account pages have their contents replaced with the SSO Commerce login/register button.

Example of Customized Login Page

    <style>
        .login-page-sso {
            --bolt-account-sso-color: #fff;
            --bolt-account-sso-font: Gibson-Regular,Arial,Helvetica,sans-serif;
            background-color: #444;
            border-color: #444;
            border-style: solid;
            border-width: 1px;
            border-radius: 4px;
            padding: 12px 32px;
            display: block;
            width: fit-content;
            margin: auto;
            cursor: pointer;
        }

        .login-page-sso:hover {
            background-color: #666;
        }
    </style>
    <div class="bolt-account-sso login-page-sso bolt-sso-custom"/>

5. Remove the Addresses, Payment Methods, and Account Details Pages

Remove any fields/pages that let the shopper modify their account on the store website, including:

  • addresses
  • payment methods
  • phone/email
  • passwords

Removing these pages prevents shopper confusion and ensures they make all relevant changes from the Bolt Checkout modal. To remove these pages, you can simply comment out any links or fields related to these pages in the account navigation component.

6. Contact Bolt

Once you have completed setup, contact Bolt so that our team can:

  • Re-run necessary account migrations steps to capture any newly added accounts.
  • Enable all imported accounts.

Testing

Bolt recommends setting up a sandbox environment first before making any changes in production. Preview mode does not work for testing Bolt SSO Commerce.

  1. Test the Login/Register button. This action should populate the SSO Modal. Try going all the way through the login flow with your own Bolt account.
  2. Test any Icons or Elements with the id=”bolt-sso-custom” attribute. This action should populate the SSO modal.
πŸ‘Ž

How did we do?

πŸ“–On This Page