Adding additional variables in window.checkoutConfig on Magento 2 Checkout page

We often need to add more variables that we need to use on the checkout page at the time of checkout. Here is how we can do that.

The first step is to add the following code in Vendor/Module/etc/frontend/di.xml of your custom module –


After this, we will create AdditionalConfigVars.php in Vendor/Module/Model and add the following code to it –


namespace Armmage\Test\Model;

use \Magento\Checkout\Model\ConfigProviderInterface

class AdditionalConfigVars implements ConfigProviderInterface
   public function getConfig()
       $additionalVariables['test_var'] = 'Test Var';
       return $additionalVariables;

Now all you need to do is flush the Magento cache and check  ‘window.checkoutConfig.test_var’ in your js on the checkout page. It will return ‘Test Var’.

This is all for now.

Basic module create --> link

Ready to elevate your e-commerce business?

Discuss your business objectives with us. Get in touch today to explore ways we can assist in reaching them.

Copyright © 2021-2024 ArmMage LLC. All rights reserved.