{"id":767,"date":"2020-01-20T10:46:36","date_gmt":"2020-01-20T10:46:36","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/01\/20\/get-store-information-on-magento-2-checkout-page-by-knockout-js\/"},"modified":"2025-03-18T06:44:04","modified_gmt":"2025-03-18T06:44:04","slug":"get-store-information-on-magento-2-checkout-page-by-knockout-js","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/get-store-information-on-magento-2-checkout-page-by-knockout-js\/","title":{"rendered":"How to Get Store Information on Magento 2 Checkout Page by Knockout Js"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Knockout is a JavaScript library that is widely used to develop the Magento 2 frontend part, particularly the checkout page. You can create dynamic pages based on the user&#8217;s action as Knockout implements the Model-View-View Model (MVVM) design pattern. With the introduction to the Knockout Js in Magento 2, it&#8217;s now become easy to develop responsive frontend components such as date picker, color picker, custom image viewer, popups, and other custom design elements which contribute a lot to UI convenience.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Even though this huge pool of benefit Knockout Js offers, it&#8217;s quite complicated to implement it in Magento 2. You may also love to read our another blog post on <a href=\"https:\/\/meetanshi.com\/blog\/configure-checkout-totals-sort-order-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Configure Checkout Totals Sort Order in Magento 2<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of the website where you have <a href=\"https:\/\/meetanshi.com\/blog\/set-up-store-information-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">set up store information<\/a> for multiple stores and you require to show store information like store ID, store name, URL, phone number, email address and store website on the checkout page. You can also <a href=\"https:\/\/meetanshi.com\/blog\/get-selected-shipping-rate-in-magento-2-checkout-page\/\">select shipping rate in the checkout page in Magento 2<\/a> to know which shipping rate is chosen by customers for customizable and information purpose. Today, I&#8217;ve come up with the solution to <em><strong>get store information on Magento 2 checkout page by Knockout Js<\/strong><\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to get store information on Magento 2 checkout page by Knockout Js<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Create <strong>app\/code\/[NameSpace]\/[ModuleName]\/etc\/frontend\/di.xml<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"lib\/internal\/Magento\/Framework\/ObjectManager\/etc\/config.xsd\">\n    &lt;type name=\"Magento\\Checkout\\Model\\DefaultConfigProvider\">\n        &lt;plugin name=\"rh-checkout-summary-modify\" type=\"[NameSpace]\\[MOduleName]\\Plugin\\CheckoutSummaryModify\" sortOrder=\"10\" \/>\n    &lt;\/type>\n&lt;\/config><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create&nbsp;<strong>app\/code\/[NameSpace]\/[ModuleName]\/Plugin\/CheckoutSummaryModify.php<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace [NameSpace]\\[MOduleName]\\Plugin;\n\nclass CheckoutSummaryModify {\n\n    \/**\n     * @var \\Magento\\Store\\Model\\StoreManagerInterface\n     *\/\n    protected $storeManager;\n\n    \/**\n     * @param \\Magento\\Store\\Model\\StoreManagerInterface $storeManager\n     *\/\n    public function __construct(\n        \\Magento\\Store\\Model\\StoreManagerInterface $storeManager\n    ) {\n        $this->storeManager = $storeManager;\n    }\n    public function afterGetConfig(\\Magento\\Checkout\\Model\\DefaultConfigProvider $subject, $result) {\n        $items = $result['totalsData']['items'];\n        foreach ($items as $key => $value) {\n            $items[$key]['storeName'] = $this->storeManager->getStore()->getName();\n        }\n        $result['totalsData']['items'] = $items;\n        return $result;\n    }\n}\n?><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. Now, copy the file from<br><strong>vendor\/magento\/module-checkout\/view\/frontend\/web\/template\/summary\/item\/details.html<\/strong><br>and add it to&nbsp;<strong>app\/design\/frontend\/Vendor\/YourTheme\/Magento_Checkout\/web\/template\/summary\/item\/details.html<\/strong>&nbsp;and add below line of code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;strong class=\"store-name\" data-bind=\"text: $parent.storeName\"&gt;&lt;\/strong&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;strong class=\"product-item-name\" data-bind=\"text: $parent.name\"&gt;&lt;\/strong&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">4. Deploy the files and clean the cache.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Implementing the above code, you will be able to get store information on Magento 2 checkout page by Knockout Js. Comment down if you stuck somewhere or have any queries, I would be happy to help \ud83d\ude42 Don&#8217;t forget to share the solution with your Magento buddies.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Knockout is a JavaScript library that is widely used to develop the Magento 2 frontend part, particularly the checkout page. You can create dynamic pages&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-767","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/767","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=767"}],"version-history":[{"count":2,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/767\/revisions"}],"predecessor-version":[{"id":10426,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/767\/revisions\/10426"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=767"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}