0

I have upgraded from Magento 2.4.6 to version 2.4.6-p6.

Then I'm having troubles when shopping with my store (at the checkout instance), as it does not return the payment methods enabled in the product purchase gateway. The Chrome browser console (and the same in Firefox or Edge) returns the following error:

TypeError: Cannot read properties of undefined (reading 'isLoggedInBolt'). 
at customer.js:19:81
at Object.execCb (require.js:1696:33)
at context.execCb (resolver.js:156:31)
at Module.check (require.js:883:51)
at Module.enable (require.js:1176:22)
at Module.init (require.js:788:26)
at callGetModule (require.js:1203:63)
at Object.completeLoad (require.js:1590:21)
at HTMLScriptElement.onScriptLoad (require.js:1717:29)

Which I think refers to the "BOLT QUICK CHECKOUT" plugin (https://www.bolt.com/adobe) I didn't have in my previous version.

My customer.js code (in the Magento_QuickCheckout folder) is as follows:

/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

define([
    'ko',
    'Magento_Checkout/js/checkout-data'
], function (ko, checkoutData) {
    'use strict';
    console.log('window.checkoutConfig:', window.checkoutConfig);
    console.log('window.checkoutConfig.payment:', window.checkoutConfig.payment);
    console.log('window.checkoutConfig.payment.quick_checkout:', window.checkoutConfig.payment.quick_checkout);
    var isBoltUser = ko.observable(
        checkoutData.getBoltAccountDetails() !== null && typeof checkoutData.getBoltAccountDetails() !== 'undefined'
    ),
        hasBoltAccount = ko.observable(checkoutData.getHasBoltAccount()).extend({ notify: 'always' }),
        isLoggedIn = ko.observable(window.checkoutConfig.payment.quick_checkout.isLoggedInBolt),
        hasWriteAccess = ko.observable(window.checkoutConfig.payment.quick_checkout.hasWriteAccess);

    return {
        isLoggedIn: isLoggedIn,
        isBoltUser: isBoltUser,
        hasBoltAccount: hasBoltAccount,
        hasWriteAccess: hasWriteAccess,

        /**
         * @param {Boolean} flag
         */
        setIsLoggedIn: function (flag) {
            isBoltUser(flag);
            if (flag) {
                this.setHasBoltAccount(flag);
            }
        },

        /**
         * @param {Boolean} flag
         */
        setHasBoltAccount: function (flag) {
            hasBoltAccount(flag);
            checkoutData.setHasBoltAccount(flag);
        },

        /**
         * @param {Boolean} flag
         */
        setHasWriteAccess: function (flag) {
            this.hasWriteAccess(flag);
        },

        /**
         * @returns {Boolean}
         */
        getHasWriteAccess: function () {
            return hasWriteAccess();
        },

        /**
         * Checks is the customer has the Bolt account info
         *
         * @returns {Boolean}
         */
        hasAccountInformation: function () {
            return checkoutData.getAccountInformationLoaded();
        },

        /**
         * Returns the customer email
         *
         * @returns {String}
         */
        getEmail: function () {
            var boltAccountDetails = checkoutData.getBoltAccountDetails();

            if (!boltAccountDetails || !boltAccountDetails.email) {
                return '';
            }

            return boltAccountDetails.email;
        }
    };
});

And my console in the browser prints the window.checkoutConfig and window.checkoutConfig.payment instances, but it breaks on window.checkoutConfig.payment.quick_checkout (seems quick_layout is not a parameter in window.checkoutConfig.payment) which is supposed to be related to the Bolt plugin and is what populates the "isLoggedInBolt" function.

This is my console log:

window.checkoutConfig: {payment: {…}, captcha: {…}, formKey: '#', customerData: {…}, quoteData: {…}, …}

window.checkoutConfig.payment: {ccform: {…}, customerBalance: {…}, giftCardAccount: {…}, paypalExpress: {…}, paypalIframe: Array(0), …}braintree_cc_vault: {cvvVerify: false}ccform: {icons: {…}}customerBalance: {isAvailable: false, amountSubstracted: false, usedAmount: 0, balance: 0, balanceRemoveUrl: 'https://#/storecredit/cart/remove/'}giftCardAccount: {hasUsage: false, amount: '0.0000', cards: Array(0), available_amount: '0.0000'}iframe: {timeoutTime: {…}, dateDelim: {…}, cardFieldsMap: {…}, source: {…}, controllerName: {…}, …}paypalBillingAgreement: {agreements: Array(0), transportName: '#'}paypalExpress: {paymentAcceptanceMarkHref: 'https://#', paymentAcceptanceMarkSrc: 'https://#', isContextCheckout: false, inContextConfig: Array(0)}paypalIframe: []reward: {isAvailable: false, amountSubstracted: false, usedAmount: 0, balance: 0, label: '#'}[[Prototype]]: Object

window.checkoutConfig.payment.quick_checkout: undefined

I'd appreciate any advice. Thanks in advance.

1 Answer 1

0

Do you have the Quick Checkout module enabled in the admin panel? If it's not enabled it won't add the data to window.checkoutConfig:

vendor/magento/module-quick-checkout/Model/ConfigProvider.php

public function getConfig(): array
{
    if (!$this->config->isEnabled()) {
        return [];
    }

    return [
        'payment' => [
            self::CODE => [
                'publishableKey' => $this->config->getPublishableKey(),
                'locale' => str_replace('_', '-', $this->localeResolver->getLocale()),
                'canDisplayOtpPopup' => $this->config->canDisplayOtpPopup(),
                'creditCardComponentConfig' => $this->config->getCreditCardFormConfig(),
                'isLoggedInBolt' => $this->isLoggedInBolt(),
                'canUseSso' => $this->customerSession->getCanUseBoltSso(),
                'canTrackCheckout' => $this->config->isCheckoutTrackingEnabled(),
                'canNavigateToPayment' => $this->config->isPaymentTheNextStage(),
                'isBoltLoginAvailable' => $this->isBoltLoginAvailable(),
                'isAutoLoginEnabled' => $this->config->isAutoLoginEnabled(),
                'autoLoginNetwork' => $this->getAutoLoginNetwork(),
                'hasWriteAccess' => $this->hasWriteAccess()
            ]
        ]
    ];
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.