Magento 2: How can I add custom attribute in order summery for checkout page?Add Custom Attribute to show on Checkout pageMagento 2 : Uncollapse Summery On First Step Of Checkout PageHow set custom Row Total in Checkout page(Order Summery Block) in Magento2?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 Add new field to Magento_User admin formMagento 2 Refresh Checkout SummeryMagento 2: custom attribute value disappear after page load in order summery checkout page. how to solve?Magento 2.2.1: Add Custom Upload file attribute in CheckoutMagento2 : Show summery total on checkout pageCustom attribute address in checkout page
Disk usage confusion: 10G missing on Linux home partition on SSD
Does friction always oppose motion?
How do I tell my girlfriend she's been buying me books by the wrong author for the last nine months?
What was the point of separating stdout and stderr?
Why should I allow multiple IP addresses on a website for a single session?
Sentences with no verb, but an ablative
What's the idiomatic (or best) way to trim surrounding whitespace from a string?
Searching for single buildings in QGIS
Does the Grothendieck group of finitely generated modules form a commutative ring where the multiplication structure is induced from tensor product?
How soon after takeoff can you recline your airplane seat?
How to track mail undetectably?
How can I smooth the top side of this ring?
Is a ccH, ccX and ccH equivalent to a cH, ccX and cH sequence?
Why is quantum gravity non-renormalizable?
German idiomatic equivalents of 能骗就骗 (if you can cheat, then cheat)
Classify 2-dim p-adic galois representations
How come having a Deathly Hallow is not a big deal?
Emphasize numbers in tables
How to extract coefficients of a generating function like this one, using a computer?
Why can't i use !(single pattern) in zsh even after i turn on kshglob?
Is it advisable to inform the CEO about his brother accessing his office?
My mom helped me cosign a car and now she wants to take it
Is my background sufficient to start Quantum Computing
Trace in the category of propositional statements
Magento 2: How can I add custom attribute in order summery for checkout page?
Add Custom Attribute to show on Checkout pageMagento 2 : Uncollapse Summery On First Step Of Checkout PageHow set custom Row Total in Checkout page(Order Summery Block) in Magento2?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 Add new field to Magento_User admin formMagento 2 Refresh Checkout SummeryMagento 2: custom attribute value disappear after page load in order summery checkout page. how to solve?Magento 2.2.1: Add Custom Upload file attribute in CheckoutMagento2 : Show summery total on checkout pageCustom attribute address in checkout page
I am trying to display a product attribute value
I have found the template where it is displayed:
vendor/magento/module-checkout/view/frontend/web/template/summary/item/details.html
How can I get the value of an attribute to display?
<div class="product-item-details">
<div class="product-item-inner">
<div class="product-item-name-block">
<strong class="product-item-name" data-bind="text: $parent.name"></strong>
<div class="details-qty">
<span class="label"><!-- ko i18n: 'Qty' --><!-- /ko --></span>
<span class="value" data-bind="text: $parent.qty"></span>
</div>
</div>
<!-- ko foreach: getRegion('after_details') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</div>
<!-- ko if: (JSON.parse($parent.options).length > 0)-->
<div class="product options" data-bind="mageInit: 'collapsible':'openedState': 'active'">
<span data-role="title" class="toggle"><!-- ko i18n: 'View Details' --><!-- /ko --></span>
<div data-role="content" class="content">
<strong class="subtitle"><!-- ko i18n: 'Options Details' --><!-- /ko --></strong>
<dl class="item-options">
<!--ko foreach: JSON.parse($parent.options)-->
<dt class="label" data-bind="text: label"></dt>
<!-- ko if: ($data.full_view)-->
<dd class="values" data-bind="html: full_view"></dd>
<!-- /ko -->
<!-- ko ifnot: ($data.full_view)-->
<dd class="values" data-bind="html: value"></dd>
<!-- /ko -->
<!-- /ko -->
</dl>
</div>
</div>
<!-- /ko -->
</div>
magento2 magento-2.1 checkout attributes
add a comment |
I am trying to display a product attribute value
I have found the template where it is displayed:
vendor/magento/module-checkout/view/frontend/web/template/summary/item/details.html
How can I get the value of an attribute to display?
<div class="product-item-details">
<div class="product-item-inner">
<div class="product-item-name-block">
<strong class="product-item-name" data-bind="text: $parent.name"></strong>
<div class="details-qty">
<span class="label"><!-- ko i18n: 'Qty' --><!-- /ko --></span>
<span class="value" data-bind="text: $parent.qty"></span>
</div>
</div>
<!-- ko foreach: getRegion('after_details') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</div>
<!-- ko if: (JSON.parse($parent.options).length > 0)-->
<div class="product options" data-bind="mageInit: 'collapsible':'openedState': 'active'">
<span data-role="title" class="toggle"><!-- ko i18n: 'View Details' --><!-- /ko --></span>
<div data-role="content" class="content">
<strong class="subtitle"><!-- ko i18n: 'Options Details' --><!-- /ko --></strong>
<dl class="item-options">
<!--ko foreach: JSON.parse($parent.options)-->
<dt class="label" data-bind="text: label"></dt>
<!-- ko if: ($data.full_view)-->
<dd class="values" data-bind="html: full_view"></dd>
<!-- /ko -->
<!-- ko ifnot: ($data.full_view)-->
<dd class="values" data-bind="html: value"></dd>
<!-- /ko -->
<!-- /ko -->
</dl>
</div>
</div>
<!-- /ko -->
</div>
magento2 magento-2.1 checkout attributes
add a comment |
I am trying to display a product attribute value
I have found the template where it is displayed:
vendor/magento/module-checkout/view/frontend/web/template/summary/item/details.html
How can I get the value of an attribute to display?
<div class="product-item-details">
<div class="product-item-inner">
<div class="product-item-name-block">
<strong class="product-item-name" data-bind="text: $parent.name"></strong>
<div class="details-qty">
<span class="label"><!-- ko i18n: 'Qty' --><!-- /ko --></span>
<span class="value" data-bind="text: $parent.qty"></span>
</div>
</div>
<!-- ko foreach: getRegion('after_details') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</div>
<!-- ko if: (JSON.parse($parent.options).length > 0)-->
<div class="product options" data-bind="mageInit: 'collapsible':'openedState': 'active'">
<span data-role="title" class="toggle"><!-- ko i18n: 'View Details' --><!-- /ko --></span>
<div data-role="content" class="content">
<strong class="subtitle"><!-- ko i18n: 'Options Details' --><!-- /ko --></strong>
<dl class="item-options">
<!--ko foreach: JSON.parse($parent.options)-->
<dt class="label" data-bind="text: label"></dt>
<!-- ko if: ($data.full_view)-->
<dd class="values" data-bind="html: full_view"></dd>
<!-- /ko -->
<!-- ko ifnot: ($data.full_view)-->
<dd class="values" data-bind="html: value"></dd>
<!-- /ko -->
<!-- /ko -->
</dl>
</div>
</div>
<!-- /ko -->
</div>
magento2 magento-2.1 checkout attributes
I am trying to display a product attribute value
I have found the template where it is displayed:
vendor/magento/module-checkout/view/frontend/web/template/summary/item/details.html
How can I get the value of an attribute to display?
<div class="product-item-details">
<div class="product-item-inner">
<div class="product-item-name-block">
<strong class="product-item-name" data-bind="text: $parent.name"></strong>
<div class="details-qty">
<span class="label"><!-- ko i18n: 'Qty' --><!-- /ko --></span>
<span class="value" data-bind="text: $parent.qty"></span>
</div>
</div>
<!-- ko foreach: getRegion('after_details') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</div>
<!-- ko if: (JSON.parse($parent.options).length > 0)-->
<div class="product options" data-bind="mageInit: 'collapsible':'openedState': 'active'">
<span data-role="title" class="toggle"><!-- ko i18n: 'View Details' --><!-- /ko --></span>
<div data-role="content" class="content">
<strong class="subtitle"><!-- ko i18n: 'Options Details' --><!-- /ko --></strong>
<dl class="item-options">
<!--ko foreach: JSON.parse($parent.options)-->
<dt class="label" data-bind="text: label"></dt>
<!-- ko if: ($data.full_view)-->
<dd class="values" data-bind="html: full_view"></dd>
<!-- /ko -->
<!-- ko ifnot: ($data.full_view)-->
<dd class="values" data-bind="html: value"></dd>
<!-- /ko -->
<!-- /ko -->
</dl>
</div>
</div>
<!-- /ko -->
</div>
magento2 magento-2.1 checkout attributes
magento2 magento-2.1 checkout attributes
edited Feb 22 '18 at 17:22
Rafael Corrêa Gomes
4,9402 gold badges35 silver badges69 bronze badges
4,9402 gold badges35 silver badges69 bronze badges
asked Aug 31 '16 at 13:44
Sagar DobariyaSagar Dobariya
1,1401 gold badge8 silver badges28 bronze badges
1,1401 gold badge8 silver badges28 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can set your custom attribute inside checkout page summary block using below way,
app/code/Package/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Set Custom attribute in chekcout page summary block -->
<type name="MagentoCheckoutModelDefaultConfigProvider">
<plugin name="default_config_provider" type="PackageModuleModelDefaultConfigProvider"/>
</type>
</config>
app/code/Package/Module/Model/DefaultConfigProvider.php file
<?php
namespace PackageModuleModel;
use MagentoCheckoutModelSession as CheckoutSession;
use MagentoQuoteApiCartItemRepositoryInterface as QuoteItemRepository;
class DefaultConfigProvider
private $checkoutSession;
private $quoteItemRepository;
protected $scopeConfig;
public function __construct(
CheckoutSession $checkoutSession,
QuoteItemRepository $quoteItemRepository,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
)
$this->_scopeConfig = $scopeConfig;
$this->checkoutSession = $checkoutSession;
$this->quoteItemRepository = $quoteItemRepository;
public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, $result)
$quoteId = $this->checkoutSession->getQuote()->getId();
if ($quoteId)
$itemOptionCount = count($result['totalsData']['items']);
$quoteItems = $this->quoteItemRepository->getList($quoteId);
$isbnOptions = array();
foreach ($quoteItems as $index => $quoteItem)
$quoteItemId = $quoteItem['item_id'];
$isbnOptions[$quoteItemId] = $quoteItem['isbn'];
for($i=0;$i<$itemOptionCount;$i++)
$quoteParentId = $result['totalsData']['items'][$i]['item_id'];
$currentOption = array();
$currentOption = json_decode($result['totalsData']['items'][$i]['options'],true);
$newOption = $isbnOptions[$quoteParentId];
//for set new option inside current option tab
if(count($newOption) > 0 && is_array($newOption))
foreach($newOption as $key=>$value)
if( !is_array($value) )
$currentOption[] = array('value'=>$value,'label'=>$key);
$result['totalsData']['items'][$i]['options'] = json_encode($currentOption);
return $result;
add a comment |
Yeah, We can set the custom attribute in order summary in checkout.
Create a custom Extension
Step 1:
Declare plugin
app/code/Package/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Set Custom attribute in chekcout page summary block -->
<type name="MagentoCheckoutModelDefaultConfigProvider">
<plugin name="default_config_provider" type="PackageModuleModelDefaultConfigProvider"/>
</type>
</config>
Step 2 :
Declare new file
app/code/Package/Module/Model/DefaultConfigProvider.php file
Create a plugin to set custom value in checkoutConfig Json
public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, $result)
$quoteId = $this->_checkoutSession->getQuote()->getId();
$writer = new ZendLogWriterStream(BP . '/var/log/test.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
if ($quoteId)
$itemOptionCount = count($result['quoteItemData']);
$quoteItems = $this->_quoteItemRepository->getList($quoteId);
//$logger->info(print_R($itemOptionCount,1));
$isbnOptions = [];
foreach ($quoteItems as $index => $quoteItem)
$quoteItemId = $quoteItem['item_id'];
$isbnOptions[$quoteItemId] = $quoteItem['isbn'];
for ($i=0; $i < $itemOptionCount; $i++)
$quoteParentId = $result['totalsData']['items'][$i]['item_id'];
$currentOption = [];
$isNew = null;
$result['quoteItemData'][$i]['new'] = 'newvv';
$productId = $result['quoteItemData'][$i]['product']['entity_id'];
$productObj = $this->_productRepository->load($productId);
$isNew = $productObj->getCustomAttribute();
$result['quoteItemData'][$i]['new'] = $isNew;
json_encode($currentOption);
return $result;
Step 3 : Add custom atribute in JS file
Put vendor file in theme Json
vendor/magento/module-checkout/view/frontend/web/js/view/summary/item/details.js
define(
[
'uiComponent'
],
function (Component)
"use strict";
var quoteItemData = window.checkoutConfig.quoteItemData;
return Component.extend(
defaults:
template: 'Magento_Checkout/summary/item/details'
,
quoteItemData: quoteItemData,
getValue: function(quoteItem)
return quoteItem.name;
,
getItemTag: function(quoteItem)
var itemProduct = this.getItemProduct(quoteItem.item_id);
return (itemProduct.new == true) ? 'new!' : null;
,
getItemProduct: function(item_id)
var itemElement = null;
_.each(this.quoteItemData, function(element, index)
if (element.item_id == item_id)
itemElement = element;
);
return itemElement;
);
);
Step 4 : Copy below code in Html file to show in order summary
vendor/magento/module-checkout/view/frontend/web/template/summary/item/details.html
<span class="product-item-new" data-bind="text: getItemTag($parent)"></span>
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f134057%2fmagento-2-how-can-i-add-custom-attribute-in-order-summery-for-checkout-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can set your custom attribute inside checkout page summary block using below way,
app/code/Package/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Set Custom attribute in chekcout page summary block -->
<type name="MagentoCheckoutModelDefaultConfigProvider">
<plugin name="default_config_provider" type="PackageModuleModelDefaultConfigProvider"/>
</type>
</config>
app/code/Package/Module/Model/DefaultConfigProvider.php file
<?php
namespace PackageModuleModel;
use MagentoCheckoutModelSession as CheckoutSession;
use MagentoQuoteApiCartItemRepositoryInterface as QuoteItemRepository;
class DefaultConfigProvider
private $checkoutSession;
private $quoteItemRepository;
protected $scopeConfig;
public function __construct(
CheckoutSession $checkoutSession,
QuoteItemRepository $quoteItemRepository,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
)
$this->_scopeConfig = $scopeConfig;
$this->checkoutSession = $checkoutSession;
$this->quoteItemRepository = $quoteItemRepository;
public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, $result)
$quoteId = $this->checkoutSession->getQuote()->getId();
if ($quoteId)
$itemOptionCount = count($result['totalsData']['items']);
$quoteItems = $this->quoteItemRepository->getList($quoteId);
$isbnOptions = array();
foreach ($quoteItems as $index => $quoteItem)
$quoteItemId = $quoteItem['item_id'];
$isbnOptions[$quoteItemId] = $quoteItem['isbn'];
for($i=0;$i<$itemOptionCount;$i++)
$quoteParentId = $result['totalsData']['items'][$i]['item_id'];
$currentOption = array();
$currentOption = json_decode($result['totalsData']['items'][$i]['options'],true);
$newOption = $isbnOptions[$quoteParentId];
//for set new option inside current option tab
if(count($newOption) > 0 && is_array($newOption))
foreach($newOption as $key=>$value)
if( !is_array($value) )
$currentOption[] = array('value'=>$value,'label'=>$key);
$result['totalsData']['items'][$i]['options'] = json_encode($currentOption);
return $result;
add a comment |
You can set your custom attribute inside checkout page summary block using below way,
app/code/Package/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Set Custom attribute in chekcout page summary block -->
<type name="MagentoCheckoutModelDefaultConfigProvider">
<plugin name="default_config_provider" type="PackageModuleModelDefaultConfigProvider"/>
</type>
</config>
app/code/Package/Module/Model/DefaultConfigProvider.php file
<?php
namespace PackageModuleModel;
use MagentoCheckoutModelSession as CheckoutSession;
use MagentoQuoteApiCartItemRepositoryInterface as QuoteItemRepository;
class DefaultConfigProvider
private $checkoutSession;
private $quoteItemRepository;
protected $scopeConfig;
public function __construct(
CheckoutSession $checkoutSession,
QuoteItemRepository $quoteItemRepository,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
)
$this->_scopeConfig = $scopeConfig;
$this->checkoutSession = $checkoutSession;
$this->quoteItemRepository = $quoteItemRepository;
public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, $result)
$quoteId = $this->checkoutSession->getQuote()->getId();
if ($quoteId)
$itemOptionCount = count($result['totalsData']['items']);
$quoteItems = $this->quoteItemRepository->getList($quoteId);
$isbnOptions = array();
foreach ($quoteItems as $index => $quoteItem)
$quoteItemId = $quoteItem['item_id'];
$isbnOptions[$quoteItemId] = $quoteItem['isbn'];
for($i=0;$i<$itemOptionCount;$i++)
$quoteParentId = $result['totalsData']['items'][$i]['item_id'];
$currentOption = array();
$currentOption = json_decode($result['totalsData']['items'][$i]['options'],true);
$newOption = $isbnOptions[$quoteParentId];
//for set new option inside current option tab
if(count($newOption) > 0 && is_array($newOption))
foreach($newOption as $key=>$value)
if( !is_array($value) )
$currentOption[] = array('value'=>$value,'label'=>$key);
$result['totalsData']['items'][$i]['options'] = json_encode($currentOption);
return $result;
add a comment |
You can set your custom attribute inside checkout page summary block using below way,
app/code/Package/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Set Custom attribute in chekcout page summary block -->
<type name="MagentoCheckoutModelDefaultConfigProvider">
<plugin name="default_config_provider" type="PackageModuleModelDefaultConfigProvider"/>
</type>
</config>
app/code/Package/Module/Model/DefaultConfigProvider.php file
<?php
namespace PackageModuleModel;
use MagentoCheckoutModelSession as CheckoutSession;
use MagentoQuoteApiCartItemRepositoryInterface as QuoteItemRepository;
class DefaultConfigProvider
private $checkoutSession;
private $quoteItemRepository;
protected $scopeConfig;
public function __construct(
CheckoutSession $checkoutSession,
QuoteItemRepository $quoteItemRepository,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
)
$this->_scopeConfig = $scopeConfig;
$this->checkoutSession = $checkoutSession;
$this->quoteItemRepository = $quoteItemRepository;
public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, $result)
$quoteId = $this->checkoutSession->getQuote()->getId();
if ($quoteId)
$itemOptionCount = count($result['totalsData']['items']);
$quoteItems = $this->quoteItemRepository->getList($quoteId);
$isbnOptions = array();
foreach ($quoteItems as $index => $quoteItem)
$quoteItemId = $quoteItem['item_id'];
$isbnOptions[$quoteItemId] = $quoteItem['isbn'];
for($i=0;$i<$itemOptionCount;$i++)
$quoteParentId = $result['totalsData']['items'][$i]['item_id'];
$currentOption = array();
$currentOption = json_decode($result['totalsData']['items'][$i]['options'],true);
$newOption = $isbnOptions[$quoteParentId];
//for set new option inside current option tab
if(count($newOption) > 0 && is_array($newOption))
foreach($newOption as $key=>$value)
if( !is_array($value) )
$currentOption[] = array('value'=>$value,'label'=>$key);
$result['totalsData']['items'][$i]['options'] = json_encode($currentOption);
return $result;
You can set your custom attribute inside checkout page summary block using below way,
app/code/Package/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Set Custom attribute in chekcout page summary block -->
<type name="MagentoCheckoutModelDefaultConfigProvider">
<plugin name="default_config_provider" type="PackageModuleModelDefaultConfigProvider"/>
</type>
</config>
app/code/Package/Module/Model/DefaultConfigProvider.php file
<?php
namespace PackageModuleModel;
use MagentoCheckoutModelSession as CheckoutSession;
use MagentoQuoteApiCartItemRepositoryInterface as QuoteItemRepository;
class DefaultConfigProvider
private $checkoutSession;
private $quoteItemRepository;
protected $scopeConfig;
public function __construct(
CheckoutSession $checkoutSession,
QuoteItemRepository $quoteItemRepository,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
)
$this->_scopeConfig = $scopeConfig;
$this->checkoutSession = $checkoutSession;
$this->quoteItemRepository = $quoteItemRepository;
public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, $result)
$quoteId = $this->checkoutSession->getQuote()->getId();
if ($quoteId)
$itemOptionCount = count($result['totalsData']['items']);
$quoteItems = $this->quoteItemRepository->getList($quoteId);
$isbnOptions = array();
foreach ($quoteItems as $index => $quoteItem)
$quoteItemId = $quoteItem['item_id'];
$isbnOptions[$quoteItemId] = $quoteItem['isbn'];
for($i=0;$i<$itemOptionCount;$i++)
$quoteParentId = $result['totalsData']['items'][$i]['item_id'];
$currentOption = array();
$currentOption = json_decode($result['totalsData']['items'][$i]['options'],true);
$newOption = $isbnOptions[$quoteParentId];
//for set new option inside current option tab
if(count($newOption) > 0 && is_array($newOption))
foreach($newOption as $key=>$value)
if( !is_array($value) )
$currentOption[] = array('value'=>$value,'label'=>$key);
$result['totalsData']['items'][$i]['options'] = json_encode($currentOption);
return $result;
answered Feb 16 '17 at 6:50
Akshay VermaAkshay Verma
215 bronze badges
215 bronze badges
add a comment |
add a comment |
Yeah, We can set the custom attribute in order summary in checkout.
Create a custom Extension
Step 1:
Declare plugin
app/code/Package/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Set Custom attribute in chekcout page summary block -->
<type name="MagentoCheckoutModelDefaultConfigProvider">
<plugin name="default_config_provider" type="PackageModuleModelDefaultConfigProvider"/>
</type>
</config>
Step 2 :
Declare new file
app/code/Package/Module/Model/DefaultConfigProvider.php file
Create a plugin to set custom value in checkoutConfig Json
public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, $result)
$quoteId = $this->_checkoutSession->getQuote()->getId();
$writer = new ZendLogWriterStream(BP . '/var/log/test.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
if ($quoteId)
$itemOptionCount = count($result['quoteItemData']);
$quoteItems = $this->_quoteItemRepository->getList($quoteId);
//$logger->info(print_R($itemOptionCount,1));
$isbnOptions = [];
foreach ($quoteItems as $index => $quoteItem)
$quoteItemId = $quoteItem['item_id'];
$isbnOptions[$quoteItemId] = $quoteItem['isbn'];
for ($i=0; $i < $itemOptionCount; $i++)
$quoteParentId = $result['totalsData']['items'][$i]['item_id'];
$currentOption = [];
$isNew = null;
$result['quoteItemData'][$i]['new'] = 'newvv';
$productId = $result['quoteItemData'][$i]['product']['entity_id'];
$productObj = $this->_productRepository->load($productId);
$isNew = $productObj->getCustomAttribute();
$result['quoteItemData'][$i]['new'] = $isNew;
json_encode($currentOption);
return $result;
Step 3 : Add custom atribute in JS file
Put vendor file in theme Json
vendor/magento/module-checkout/view/frontend/web/js/view/summary/item/details.js
define(
[
'uiComponent'
],
function (Component)
"use strict";
var quoteItemData = window.checkoutConfig.quoteItemData;
return Component.extend(
defaults:
template: 'Magento_Checkout/summary/item/details'
,
quoteItemData: quoteItemData,
getValue: function(quoteItem)
return quoteItem.name;
,
getItemTag: function(quoteItem)
var itemProduct = this.getItemProduct(quoteItem.item_id);
return (itemProduct.new == true) ? 'new!' : null;
,
getItemProduct: function(item_id)
var itemElement = null;
_.each(this.quoteItemData, function(element, index)
if (element.item_id == item_id)
itemElement = element;
);
return itemElement;
);
);
Step 4 : Copy below code in Html file to show in order summary
vendor/magento/module-checkout/view/frontend/web/template/summary/item/details.html
<span class="product-item-new" data-bind="text: getItemTag($parent)"></span>
add a comment |
Yeah, We can set the custom attribute in order summary in checkout.
Create a custom Extension
Step 1:
Declare plugin
app/code/Package/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Set Custom attribute in chekcout page summary block -->
<type name="MagentoCheckoutModelDefaultConfigProvider">
<plugin name="default_config_provider" type="PackageModuleModelDefaultConfigProvider"/>
</type>
</config>
Step 2 :
Declare new file
app/code/Package/Module/Model/DefaultConfigProvider.php file
Create a plugin to set custom value in checkoutConfig Json
public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, $result)
$quoteId = $this->_checkoutSession->getQuote()->getId();
$writer = new ZendLogWriterStream(BP . '/var/log/test.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
if ($quoteId)
$itemOptionCount = count($result['quoteItemData']);
$quoteItems = $this->_quoteItemRepository->getList($quoteId);
//$logger->info(print_R($itemOptionCount,1));
$isbnOptions = [];
foreach ($quoteItems as $index => $quoteItem)
$quoteItemId = $quoteItem['item_id'];
$isbnOptions[$quoteItemId] = $quoteItem['isbn'];
for ($i=0; $i < $itemOptionCount; $i++)
$quoteParentId = $result['totalsData']['items'][$i]['item_id'];
$currentOption = [];
$isNew = null;
$result['quoteItemData'][$i]['new'] = 'newvv';
$productId = $result['quoteItemData'][$i]['product']['entity_id'];
$productObj = $this->_productRepository->load($productId);
$isNew = $productObj->getCustomAttribute();
$result['quoteItemData'][$i]['new'] = $isNew;
json_encode($currentOption);
return $result;
Step 3 : Add custom atribute in JS file
Put vendor file in theme Json
vendor/magento/module-checkout/view/frontend/web/js/view/summary/item/details.js
define(
[
'uiComponent'
],
function (Component)
"use strict";
var quoteItemData = window.checkoutConfig.quoteItemData;
return Component.extend(
defaults:
template: 'Magento_Checkout/summary/item/details'
,
quoteItemData: quoteItemData,
getValue: function(quoteItem)
return quoteItem.name;
,
getItemTag: function(quoteItem)
var itemProduct = this.getItemProduct(quoteItem.item_id);
return (itemProduct.new == true) ? 'new!' : null;
,
getItemProduct: function(item_id)
var itemElement = null;
_.each(this.quoteItemData, function(element, index)
if (element.item_id == item_id)
itemElement = element;
);
return itemElement;
);
);
Step 4 : Copy below code in Html file to show in order summary
vendor/magento/module-checkout/view/frontend/web/template/summary/item/details.html
<span class="product-item-new" data-bind="text: getItemTag($parent)"></span>
add a comment |
Yeah, We can set the custom attribute in order summary in checkout.
Create a custom Extension
Step 1:
Declare plugin
app/code/Package/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Set Custom attribute in chekcout page summary block -->
<type name="MagentoCheckoutModelDefaultConfigProvider">
<plugin name="default_config_provider" type="PackageModuleModelDefaultConfigProvider"/>
</type>
</config>
Step 2 :
Declare new file
app/code/Package/Module/Model/DefaultConfigProvider.php file
Create a plugin to set custom value in checkoutConfig Json
public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, $result)
$quoteId = $this->_checkoutSession->getQuote()->getId();
$writer = new ZendLogWriterStream(BP . '/var/log/test.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
if ($quoteId)
$itemOptionCount = count($result['quoteItemData']);
$quoteItems = $this->_quoteItemRepository->getList($quoteId);
//$logger->info(print_R($itemOptionCount,1));
$isbnOptions = [];
foreach ($quoteItems as $index => $quoteItem)
$quoteItemId = $quoteItem['item_id'];
$isbnOptions[$quoteItemId] = $quoteItem['isbn'];
for ($i=0; $i < $itemOptionCount; $i++)
$quoteParentId = $result['totalsData']['items'][$i]['item_id'];
$currentOption = [];
$isNew = null;
$result['quoteItemData'][$i]['new'] = 'newvv';
$productId = $result['quoteItemData'][$i]['product']['entity_id'];
$productObj = $this->_productRepository->load($productId);
$isNew = $productObj->getCustomAttribute();
$result['quoteItemData'][$i]['new'] = $isNew;
json_encode($currentOption);
return $result;
Step 3 : Add custom atribute in JS file
Put vendor file in theme Json
vendor/magento/module-checkout/view/frontend/web/js/view/summary/item/details.js
define(
[
'uiComponent'
],
function (Component)
"use strict";
var quoteItemData = window.checkoutConfig.quoteItemData;
return Component.extend(
defaults:
template: 'Magento_Checkout/summary/item/details'
,
quoteItemData: quoteItemData,
getValue: function(quoteItem)
return quoteItem.name;
,
getItemTag: function(quoteItem)
var itemProduct = this.getItemProduct(quoteItem.item_id);
return (itemProduct.new == true) ? 'new!' : null;
,
getItemProduct: function(item_id)
var itemElement = null;
_.each(this.quoteItemData, function(element, index)
if (element.item_id == item_id)
itemElement = element;
);
return itemElement;
);
);
Step 4 : Copy below code in Html file to show in order summary
vendor/magento/module-checkout/view/frontend/web/template/summary/item/details.html
<span class="product-item-new" data-bind="text: getItemTag($parent)"></span>
Yeah, We can set the custom attribute in order summary in checkout.
Create a custom Extension
Step 1:
Declare plugin
app/code/Package/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Set Custom attribute in chekcout page summary block -->
<type name="MagentoCheckoutModelDefaultConfigProvider">
<plugin name="default_config_provider" type="PackageModuleModelDefaultConfigProvider"/>
</type>
</config>
Step 2 :
Declare new file
app/code/Package/Module/Model/DefaultConfigProvider.php file
Create a plugin to set custom value in checkoutConfig Json
public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, $result)
$quoteId = $this->_checkoutSession->getQuote()->getId();
$writer = new ZendLogWriterStream(BP . '/var/log/test.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
if ($quoteId)
$itemOptionCount = count($result['quoteItemData']);
$quoteItems = $this->_quoteItemRepository->getList($quoteId);
//$logger->info(print_R($itemOptionCount,1));
$isbnOptions = [];
foreach ($quoteItems as $index => $quoteItem)
$quoteItemId = $quoteItem['item_id'];
$isbnOptions[$quoteItemId] = $quoteItem['isbn'];
for ($i=0; $i < $itemOptionCount; $i++)
$quoteParentId = $result['totalsData']['items'][$i]['item_id'];
$currentOption = [];
$isNew = null;
$result['quoteItemData'][$i]['new'] = 'newvv';
$productId = $result['quoteItemData'][$i]['product']['entity_id'];
$productObj = $this->_productRepository->load($productId);
$isNew = $productObj->getCustomAttribute();
$result['quoteItemData'][$i]['new'] = $isNew;
json_encode($currentOption);
return $result;
Step 3 : Add custom atribute in JS file
Put vendor file in theme Json
vendor/magento/module-checkout/view/frontend/web/js/view/summary/item/details.js
define(
[
'uiComponent'
],
function (Component)
"use strict";
var quoteItemData = window.checkoutConfig.quoteItemData;
return Component.extend(
defaults:
template: 'Magento_Checkout/summary/item/details'
,
quoteItemData: quoteItemData,
getValue: function(quoteItem)
return quoteItem.name;
,
getItemTag: function(quoteItem)
var itemProduct = this.getItemProduct(quoteItem.item_id);
return (itemProduct.new == true) ? 'new!' : null;
,
getItemProduct: function(item_id)
var itemElement = null;
_.each(this.quoteItemData, function(element, index)
if (element.item_id == item_id)
itemElement = element;
);
return itemElement;
);
);
Step 4 : Copy below code in Html file to show in order summary
vendor/magento/module-checkout/view/frontend/web/template/summary/item/details.html
<span class="product-item-new" data-bind="text: getItemTag($parent)"></span>
edited Jun 24 at 8:49
Ghulam.M
4891 silver badge13 bronze badges
4891 silver badge13 bronze badges
answered Apr 21 '17 at 9:58
Chirag JainChirag Jain
793 bronze badges
793 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f134057%2fmagento-2-how-can-i-add-custom-attribute-in-order-summery-for-checkout-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown