Steps to get store information on Magento 2 checkout page by Knockout Js

Follow the following steps to get the store the information on Magento 2

Create di.xml

Directory

app/code/VendorName/ModuleName/etc/frontend/di.xml

Content of di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<type name="Magento\Checkout\Model\DefaultConfigProvider">
<plugin name="rh-checkout-summary-modify" type="VendorName\ModuleName\Plugin\CheckoutSummaryModify" sortOrder="10" />
</type>
</config>

Create CheckoutSummaryModify.php

Directory

app/code/VendorName/ModuleName/Plugin/CheckoutSummaryModify.php

Content of CheckoutSummaryModify.php

<?php
namespace VendorName\ModuleName\Plugin;
class CheckoutSummaryModify {
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $storeManager;
/**
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
*/
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
$this->storeManager = $storeManager;
}
public function afterGetConfig(\Magento\Checkout\Model\DefaultConfigProvider $subject, $result) {
$items = $result['totalsData']['items'];
foreach ($items as $key => $value) {
$items[$key]['storeName'] = $this->storeManager->getStore()->getName();
}
$result['totalsData']['items'] = $items;
return $result;
}
}
?>

Extend the details.html

Copy the file from 

vendor/magento/module-checkout/view/frontend/web/template/summary/item/details.html

and create the file to extend in this directory

app/design/frontend/Vendor/YourTheme/Magento_Checkout/web/template/summary/item/details.html

And add the code in this file.

To check changes clean the cache.

We are providing the best Magento 2 Extensions at the lowest prices. 
Related Products