{"id":133573,"date":"2018-07-14T13:37:30","date_gmt":"2018-07-14T13:37:30","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=133573"},"modified":"2023-01-03T13:36:30","modified_gmt":"2023-01-03T13:36:30","slug":"adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/","title":{"rendered":"Adding additional variables in window.checkoutConfig on Magento 2 Checkout page"},"content":{"rendered":"\n<p>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.<\/p>\n\n\n\n<p>The first step is to add the following code in Vendor\/Module\/etc\/frontend\/di.xml of your custom module &#8211;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted brush:xml\">&lt;?xml version=\"1.0\"?&gt;\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n       xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager\/etc\/config.xsd\"&gt;\n   &lt;type name=\"Magento\\Checkout\\Model\\CompositeConfigProvider\"&gt;\n       &lt;arguments&gt;\n           &lt;argument name=\"configProviders\" xsi:type=\"array\"&gt;\n               &lt;item name=\"additional_provider\" xsi:type=\"object\"&gt;Webkul\\Test\\Model\\AdditionalConfigVars&lt;\/item&gt;\n           &lt;\/argument&gt;\n       &lt;\/arguments&gt;\n   &lt;\/type&gt;\n&lt;\/config&gt;\n<\/pre>\n\n\n\n<p>After this, we will create AdditionalConfigVars.php in&nbsp;Vendor\/Module\/Model and add the following code to it &#8211;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted brush:php\">&lt;?php\n\nnamespace Webkul\\Test\\Model;\n\nuse \\Magento\\Checkout\\Model\\ConfigProviderInterface;\n\nclass AdditionalConfigVars implements ConfigProviderInterface\n{\n \u00a0\u00a0public function getConfig()\n \u00a0\u00a0{\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$additionalVariables['test_var'] = 'Test Var';\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return $additionalVariables;\n \u00a0\u00a0}\n}\n<\/pre>\n\n\n\n<p>Now all you need to do is flush Magento&nbsp;cache and check&nbsp; &#8216;window.checkoutConfig.test_var&#8217; in your js on the checkout page. It will return &#8216;Test Var&#8217;.<\/p>\n\n\n\n<p>This is all for now.<\/p>\n\n\n\n<p>Suggestions and queries are welcome.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8211; &lt;?xml version=&#8221;1.0&#8243;?&gt; &lt;config xmlns:xsi=&#8221;http:\/\/www.w3.org\/2001\/XMLSchema-instance&#8221; xsi:noNamespaceSchemaLocation=&#8221;urn:magento:framework:ObjectManager\/etc\/config.xsd&#8221;&gt; &lt;type name=&#8221;Magento\\Checkout\\Model\\CompositeConfigProvider&#8221;&gt; &lt;arguments&gt; &lt;argument name=&#8221;configProviders&#8221; xsi:type=&#8221;array&#8221;&gt; <a href=\"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":167,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302],"tags":[7083,7082],"class_list":["post-133573","post","type-post","status-publish","format-standard","hentry","category-magento2","tag-additonal-variables","tag-window-checkoutconfig"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Adding additional variables in window.checkoutConfig on Magento 2 Checkout page - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Adding additional variables in window.checkoutConfig on Magento 2 Checkout page - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"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 &#8211; &lt;?xml version=&quot;1.0&quot;?&gt; &lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:ObjectManager\/etc\/config.xsd&quot;&gt; &lt;type name=&quot;MagentoCheckoutModelCompositeConfigProvider&quot;&gt; &lt;arguments&gt; &lt;argument name=&quot;configProviders&quot; xsi:type=&quot;array&quot;&gt; [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-07-14T13:37:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-03T13:36:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Hemant Jain\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Hemant Jain\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/\"},\"author\":{\"name\":\"Hemant Jain\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/a824ac6c5c14d32569263100b85f47c6\"},\"headline\":\"Adding additional variables in window.checkoutConfig on Magento 2 Checkout page\",\"datePublished\":\"2018-07-14T13:37:30+00:00\",\"dateModified\":\"2023-01-03T13:36:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/\"},\"wordCount\":119,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"keywords\":[\"additonal variables\",\"window.checkoutConfig\"],\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/\",\"url\":\"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/\",\"name\":\"Adding additional variables in window.checkoutConfig on Magento 2 Checkout page - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2018-07-14T13:37:30+00:00\",\"dateModified\":\"2023-01-03T13:36:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Adding additional variables in window.checkoutConfig on Magento 2 Checkout page\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/a824ac6c5c14d32569263100b85f47c6\",\"name\":\"Hemant Jain\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/184358b1c25c580a3e32952605156294dedfff2b8b75bdb2a719c8e6a5d318b6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/184358b1c25c580a3e32952605156294dedfff2b8b75bdb2a719c8e6a5d318b6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Hemant Jain\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/hemant-jain591\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Adding additional variables in window.checkoutConfig on Magento 2 Checkout page - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/","og_locale":"en_US","og_type":"article","og_title":"Adding additional variables in window.checkoutConfig on Magento 2 Checkout page - Webkul Blog","og_description":"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 &#8211; &lt;?xml version=\"1.0\"?&gt; &lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager\/etc\/config.xsd\"&gt; &lt;type name=\"MagentoCheckoutModelCompositeConfigProvider\"&gt; &lt;arguments&gt; &lt;argument name=\"configProviders\" xsi:type=\"array\"&gt; [...]","og_url":"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2018-07-14T13:37:30+00:00","article_modified_time":"2023-01-03T13:36:30+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Hemant Jain","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Hemant Jain","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/"},"author":{"name":"Hemant Jain","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/a824ac6c5c14d32569263100b85f47c6"},"headline":"Adding additional variables in window.checkoutConfig on Magento 2 Checkout page","datePublished":"2018-07-14T13:37:30+00:00","dateModified":"2023-01-03T13:36:30+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/"},"wordCount":119,"commentCount":2,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"keywords":["additonal variables","window.checkoutConfig"],"articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/","url":"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/","name":"Adding additional variables in window.checkoutConfig on Magento 2 Checkout page - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2018-07-14T13:37:30+00:00","dateModified":"2023-01-03T13:36:30+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/adding-additional-variables-in-window-checkoutconfig-on-magento-2-checkout-page\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Adding additional variables in window.checkoutConfig on Magento 2 Checkout page"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/a824ac6c5c14d32569263100b85f47c6","name":"Hemant Jain","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/184358b1c25c580a3e32952605156294dedfff2b8b75bdb2a719c8e6a5d318b6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/184358b1c25c580a3e32952605156294dedfff2b8b75bdb2a719c8e6a5d318b6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Hemant Jain"},"url":"https:\/\/webkul.com\/blog\/author\/hemant-jain591\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/133573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/167"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=133573"}],"version-history":[{"count":6,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/133573\/revisions"}],"predecessor-version":[{"id":362980,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/133573\/revisions\/362980"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=133573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=133573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=133573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}