Pass data to child template in cart-items of checkout page Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar ManaraMagento2 override admin js filemain.CRITICAL: Plugin class doesn't existOneStepCheckout - display subtotals of tax classPrice not getting updated for second product…Magento 2 Add new field to Magento_User admin formMagento 2: Pass data in checkoutMultiple knockout uiComponents should not share the same data / seperate view instancesMagento 2.2.1: Add Custom Upload file attribute in CheckoutPass the values to rest api from magento2 checkout pageCheckout cart xml move items
What is this word supposed to be?
The weakest link
What is purpose of DB Browser(dbbrowser.aspx) under admin tool?
Is there really no use for MD5 anymore?
Why did C use the -> operator instead of reusing the . operator?
Air bladders in bat-like skin wings for better lift?
Can a stored procedure reference the database in which it is stored?
Older movie/show about humans on derelict alien warship which refuels by passing through a star
How to translate "red flag" into Spanish?
Should the Product Owner dictate what info the UI needs to display?
finding a tangent line to a parabola
Why do games have consumables?
Sharepoint Designer Discontinuation - software to modify existing workflows
What *exactly* is electrical current, voltage, and resistance?
How to find the stem of any word?
Mistake in years of experience in resume?
Is Diceware more secure than a long passphrase?
What is it called when you ride around on your front wheel?
I preordered a game on my Xbox while on the home screen of my friend's account. Which of us owns the game?
Crossed out red box fitting tightly around image
How much of a wave function must reside inside event horizon for it to be consumed by the black hole?
Was Dennis Ritchie being too modest in this quote about C and Pascal?
What makes accurate emulation of old systems a difficult task?
How to have a sharp product image?
Pass data to child template in cart-items of checkout page
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraMagento2 override admin js filemain.CRITICAL: Plugin class doesn't existOneStepCheckout - display subtotals of tax classPrice not getting updated for second product…Magento 2 Add new field to Magento_User admin formMagento 2: Pass data in checkoutMultiple knockout uiComponents should not share the same data / seperate view instancesMagento 2.2.1: Add Custom Upload file attribute in CheckoutPass the values to rest api from magento2 checkout pageCheckout cart xml move items
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
My site is a market place site where vendors(sellers can sell their product).
Now i want to customize the to group items in cart by each vendor like this:
http://prntscr.com/hmsam6
checkout_index_index.xml
<item name="cart_groups" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/cart-groups</item>
<item name="children" xsi:type="array">
<item name="cart_items" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/cart_groups/cart-items</item>
<item name="children" xsi:type="array">
<item name="details" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details</item>
<item name="children" xsi:type="array">
<item name="thumbnail" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/thumbnail</item>
<item name="displayArea" xsi:type="string">before_details</item>
</item>
<item name="subtotal" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/subtotal</item>
<item name="displayArea" xsi:type="string">after_details</item>
</item>
</item>
</item>
</item>
</item>
</item>
cart-group.js
define([
'ko',
'Magento_Checkout/js/model/totals',
'uiComponent',
'Magento_Checkout/js/model/step-navigator',
'Magento_Checkout/js/model/quote'], function (ko, totals, Component, stepNavigator, quote)
'use strict';
return Component.extend(
defaults:
template: 'Magento_Checkout/summary/cart-groups'
,
groups: window.checkoutConfig.quoteItemData,
getGroups:function()
var tempGroups = this.groups;
var arr = Object.keys(tempGroups).map(function (key) return tempGroups[key]; );
return arr;
,
/**
* Returns bool value for items block state (expanded or not)
*
* @returns *
*/
isItemsBlockExpanded: function () stepNavigator.isProcessed('shipping');
,
/**
* Returns cart items qty
*
* @returns Number
*/
getItemsQty: function ()
return parseFloat(this.totals['items_qty']);
,
/**
* Returns count of cart line items
*
* @returns Number
*/
getCartLineItemsCount: function ()
return parseInt(totals.getItems()().length, 10);
,
););
cart-group.html
<div class="block items-in-cart"
data-bind="mageInit: 'collapsible':'openedState': 'active', 'active': isItemsBlockExpanded()">
<div class="title" data-role="title">
<strong role="heading">
<translate args="'Item in Cart'" if="getCartLineItemsCount() === 1"/>
<translate args="'Items in Cart'" if="getCartLineItemsCount() > 1"/>
</strong>
</div>
<div class="content minicart-items" data-role="content">
<div class="minicart-items-wrapper overflowed">
<each args="getGroups()">
<p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
<!-- ko foreach: $parent.elems() -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</each>
</div>
</div>
The problem is here:
<each args="getGroups()">
<p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
<!-- ko foreach: $parent.elems() -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</each>
How can i pass data to child template with each data in this loop: getGroups() array. Right now it is all the data in quote, and it is duplicated 2 times
magento2 magento-2.1 checkout magento2.2 knockout
add a comment |
My site is a market place site where vendors(sellers can sell their product).
Now i want to customize the to group items in cart by each vendor like this:
http://prntscr.com/hmsam6
checkout_index_index.xml
<item name="cart_groups" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/cart-groups</item>
<item name="children" xsi:type="array">
<item name="cart_items" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/cart_groups/cart-items</item>
<item name="children" xsi:type="array">
<item name="details" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details</item>
<item name="children" xsi:type="array">
<item name="thumbnail" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/thumbnail</item>
<item name="displayArea" xsi:type="string">before_details</item>
</item>
<item name="subtotal" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/subtotal</item>
<item name="displayArea" xsi:type="string">after_details</item>
</item>
</item>
</item>
</item>
</item>
</item>
cart-group.js
define([
'ko',
'Magento_Checkout/js/model/totals',
'uiComponent',
'Magento_Checkout/js/model/step-navigator',
'Magento_Checkout/js/model/quote'], function (ko, totals, Component, stepNavigator, quote)
'use strict';
return Component.extend(
defaults:
template: 'Magento_Checkout/summary/cart-groups'
,
groups: window.checkoutConfig.quoteItemData,
getGroups:function()
var tempGroups = this.groups;
var arr = Object.keys(tempGroups).map(function (key) return tempGroups[key]; );
return arr;
,
/**
* Returns bool value for items block state (expanded or not)
*
* @returns *
*/
isItemsBlockExpanded: function () stepNavigator.isProcessed('shipping');
,
/**
* Returns cart items qty
*
* @returns Number
*/
getItemsQty: function ()
return parseFloat(this.totals['items_qty']);
,
/**
* Returns count of cart line items
*
* @returns Number
*/
getCartLineItemsCount: function ()
return parseInt(totals.getItems()().length, 10);
,
););
cart-group.html
<div class="block items-in-cart"
data-bind="mageInit: 'collapsible':'openedState': 'active', 'active': isItemsBlockExpanded()">
<div class="title" data-role="title">
<strong role="heading">
<translate args="'Item in Cart'" if="getCartLineItemsCount() === 1"/>
<translate args="'Items in Cart'" if="getCartLineItemsCount() > 1"/>
</strong>
</div>
<div class="content minicart-items" data-role="content">
<div class="minicart-items-wrapper overflowed">
<each args="getGroups()">
<p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
<!-- ko foreach: $parent.elems() -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</each>
</div>
</div>
The problem is here:
<each args="getGroups()">
<p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
<!-- ko foreach: $parent.elems() -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</each>
How can i pass data to child template with each data in this loop: getGroups() array. Right now it is all the data in quote, and it is duplicated 2 times
magento2 magento-2.1 checkout magento2.2 knockout
Yes. Magento 2.2.x. But it is related to knockoutjs, which i am not familiar with. Can you give me some hint to go ?
– Toàn Tam
Dec 13 '17 at 5:59
have you fond solution?
– Abdul
Jan 25 '18 at 5:55
@ToànTam have you found any solution?
– user00247
Dec 10 '18 at 7:33
add a comment |
My site is a market place site where vendors(sellers can sell their product).
Now i want to customize the to group items in cart by each vendor like this:
http://prntscr.com/hmsam6
checkout_index_index.xml
<item name="cart_groups" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/cart-groups</item>
<item name="children" xsi:type="array">
<item name="cart_items" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/cart_groups/cart-items</item>
<item name="children" xsi:type="array">
<item name="details" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details</item>
<item name="children" xsi:type="array">
<item name="thumbnail" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/thumbnail</item>
<item name="displayArea" xsi:type="string">before_details</item>
</item>
<item name="subtotal" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/subtotal</item>
<item name="displayArea" xsi:type="string">after_details</item>
</item>
</item>
</item>
</item>
</item>
</item>
cart-group.js
define([
'ko',
'Magento_Checkout/js/model/totals',
'uiComponent',
'Magento_Checkout/js/model/step-navigator',
'Magento_Checkout/js/model/quote'], function (ko, totals, Component, stepNavigator, quote)
'use strict';
return Component.extend(
defaults:
template: 'Magento_Checkout/summary/cart-groups'
,
groups: window.checkoutConfig.quoteItemData,
getGroups:function()
var tempGroups = this.groups;
var arr = Object.keys(tempGroups).map(function (key) return tempGroups[key]; );
return arr;
,
/**
* Returns bool value for items block state (expanded or not)
*
* @returns *
*/
isItemsBlockExpanded: function () stepNavigator.isProcessed('shipping');
,
/**
* Returns cart items qty
*
* @returns Number
*/
getItemsQty: function ()
return parseFloat(this.totals['items_qty']);
,
/**
* Returns count of cart line items
*
* @returns Number
*/
getCartLineItemsCount: function ()
return parseInt(totals.getItems()().length, 10);
,
););
cart-group.html
<div class="block items-in-cart"
data-bind="mageInit: 'collapsible':'openedState': 'active', 'active': isItemsBlockExpanded()">
<div class="title" data-role="title">
<strong role="heading">
<translate args="'Item in Cart'" if="getCartLineItemsCount() === 1"/>
<translate args="'Items in Cart'" if="getCartLineItemsCount() > 1"/>
</strong>
</div>
<div class="content minicart-items" data-role="content">
<div class="minicart-items-wrapper overflowed">
<each args="getGroups()">
<p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
<!-- ko foreach: $parent.elems() -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</each>
</div>
</div>
The problem is here:
<each args="getGroups()">
<p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
<!-- ko foreach: $parent.elems() -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</each>
How can i pass data to child template with each data in this loop: getGroups() array. Right now it is all the data in quote, and it is duplicated 2 times
magento2 magento-2.1 checkout magento2.2 knockout
My site is a market place site where vendors(sellers can sell their product).
Now i want to customize the to group items in cart by each vendor like this:
http://prntscr.com/hmsam6
checkout_index_index.xml
<item name="cart_groups" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/cart-groups</item>
<item name="children" xsi:type="array">
<item name="cart_items" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/cart_groups/cart-items</item>
<item name="children" xsi:type="array">
<item name="details" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details</item>
<item name="children" xsi:type="array">
<item name="thumbnail" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/thumbnail</item>
<item name="displayArea" xsi:type="string">before_details</item>
</item>
<item name="subtotal" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/subtotal</item>
<item name="displayArea" xsi:type="string">after_details</item>
</item>
</item>
</item>
</item>
</item>
</item>
cart-group.js
define([
'ko',
'Magento_Checkout/js/model/totals',
'uiComponent',
'Magento_Checkout/js/model/step-navigator',
'Magento_Checkout/js/model/quote'], function (ko, totals, Component, stepNavigator, quote)
'use strict';
return Component.extend(
defaults:
template: 'Magento_Checkout/summary/cart-groups'
,
groups: window.checkoutConfig.quoteItemData,
getGroups:function()
var tempGroups = this.groups;
var arr = Object.keys(tempGroups).map(function (key) return tempGroups[key]; );
return arr;
,
/**
* Returns bool value for items block state (expanded or not)
*
* @returns *
*/
isItemsBlockExpanded: function () stepNavigator.isProcessed('shipping');
,
/**
* Returns cart items qty
*
* @returns Number
*/
getItemsQty: function ()
return parseFloat(this.totals['items_qty']);
,
/**
* Returns count of cart line items
*
* @returns Number
*/
getCartLineItemsCount: function ()
return parseInt(totals.getItems()().length, 10);
,
););
cart-group.html
<div class="block items-in-cart"
data-bind="mageInit: 'collapsible':'openedState': 'active', 'active': isItemsBlockExpanded()">
<div class="title" data-role="title">
<strong role="heading">
<translate args="'Item in Cart'" if="getCartLineItemsCount() === 1"/>
<translate args="'Items in Cart'" if="getCartLineItemsCount() > 1"/>
</strong>
</div>
<div class="content minicart-items" data-role="content">
<div class="minicart-items-wrapper overflowed">
<each args="getGroups()">
<p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
<!-- ko foreach: $parent.elems() -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</each>
</div>
</div>
The problem is here:
<each args="getGroups()">
<p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
<!-- ko foreach: $parent.elems() -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</each>
How can i pass data to child template with each data in this loop: getGroups() array. Right now it is all the data in quote, and it is duplicated 2 times
magento2 magento-2.1 checkout magento2.2 knockout
magento2 magento-2.1 checkout magento2.2 knockout
asked Dec 13 '17 at 4:58
Toàn TamToàn Tam
424315
424315
Yes. Magento 2.2.x. But it is related to knockoutjs, which i am not familiar with. Can you give me some hint to go ?
– Toàn Tam
Dec 13 '17 at 5:59
have you fond solution?
– Abdul
Jan 25 '18 at 5:55
@ToànTam have you found any solution?
– user00247
Dec 10 '18 at 7:33
add a comment |
Yes. Magento 2.2.x. But it is related to knockoutjs, which i am not familiar with. Can you give me some hint to go ?
– Toàn Tam
Dec 13 '17 at 5:59
have you fond solution?
– Abdul
Jan 25 '18 at 5:55
@ToànTam have you found any solution?
– user00247
Dec 10 '18 at 7:33
Yes. Magento 2.2.x. But it is related to knockoutjs, which i am not familiar with. Can you give me some hint to go ?
– Toàn Tam
Dec 13 '17 at 5:59
Yes. Magento 2.2.x. But it is related to knockoutjs, which i am not familiar with. Can you give me some hint to go ?
– Toàn Tam
Dec 13 '17 at 5:59
have you fond solution?
– Abdul
Jan 25 '18 at 5:55
have you fond solution?
– Abdul
Jan 25 '18 at 5:55
@ToànTam have you found any solution?
– user00247
Dec 10 '18 at 7:33
@ToànTam have you found any solution?
– user00247
Dec 10 '18 at 7:33
add a comment |
1 Answer
1
active
oldest
votes
https://stackoverflow.com/questions/20430976/can-i-pass-a-variable-in-a-template-binding
So something like this:
<div data-bind="foreach: getGroups">
<p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
<!-- ko foreach: $parent.elems() -->
<!-- ko template: name: getTemplate(), templateOptions: myvar: $data --><!-- /ko -->
<!-- /ko -->
</div>
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%2f205564%2fpass-data-to-child-template-in-cart-items-of-checkout-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
https://stackoverflow.com/questions/20430976/can-i-pass-a-variable-in-a-template-binding
So something like this:
<div data-bind="foreach: getGroups">
<p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
<!-- ko foreach: $parent.elems() -->
<!-- ko template: name: getTemplate(), templateOptions: myvar: $data --><!-- /ko -->
<!-- /ko -->
</div>
add a comment |
https://stackoverflow.com/questions/20430976/can-i-pass-a-variable-in-a-template-binding
So something like this:
<div data-bind="foreach: getGroups">
<p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
<!-- ko foreach: $parent.elems() -->
<!-- ko template: name: getTemplate(), templateOptions: myvar: $data --><!-- /ko -->
<!-- /ko -->
</div>
add a comment |
https://stackoverflow.com/questions/20430976/can-i-pass-a-variable-in-a-template-binding
So something like this:
<div data-bind="foreach: getGroups">
<p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
<!-- ko foreach: $parent.elems() -->
<!-- ko template: name: getTemplate(), templateOptions: myvar: $data --><!-- /ko -->
<!-- /ko -->
</div>
https://stackoverflow.com/questions/20430976/can-i-pass-a-variable-in-a-template-binding
So something like this:
<div data-bind="foreach: getGroups">
<p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
<!-- ko foreach: $parent.elems() -->
<!-- ko template: name: getTemplate(), templateOptions: myvar: $data --><!-- /ko -->
<!-- /ko -->
</div>
answered Jan 25 '18 at 12:53
sterossteros
859730
859730
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%2f205564%2fpass-data-to-child-template-in-cart-items-of-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
Yes. Magento 2.2.x. But it is related to knockoutjs, which i am not familiar with. Can you give me some hint to go ?
– Toàn Tam
Dec 13 '17 at 5:59
have you fond solution?
– Abdul
Jan 25 '18 at 5:55
@ToànTam have you found any solution?
– user00247
Dec 10 '18 at 7:33