Pass data to child template in cart-items of checkout pageMagento2 override admin js filemain.CRITICAL: Plugin class doesn't existOneStepCheckout - display subtotals of tax classPrice not getting updated for second product…Magento 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

The Digit Triangles

What is going on with gets(stdin) on the site coderbyte?

Find the next value of this number series

Why do ¬, ∀ and ∃ have the same precedence?

Does grappling negate Mirror Image?

How to draw a matrix with arrows in limited space

What to do when eye contact makes your coworker uncomfortable?

Has the laser at Magurele, Romania reached a tenth of the Sun's power?

Why is the Sun approximated as a black body at ~ 5800 K?

What are some good ways to treat frozen vegetables such that they behave like fresh vegetables when stir frying them?

Can I cause damage to electrical appliances by unplugging them when they are turned on?

Doesn't the system of the Supreme Court oppose justice?

Review your own paper in Mathematics

Is it ethical to recieve stipend after publishing enough papers?

Change the color of a single dot in `ddot` symbol

What fields between the rationals and the reals allow a good notion of 2D distance?

awk assign to multiple variables at once

Is there any evidence that Cleopatra and Caesarion considered fleeing to India to escape the Romans?

Do we have to expect a queue for the shuttle from Watford Junction to Harry Potter Studio?

What is Cash Advance APR?

What is the English pronunciation of "pain au chocolat"?

When were female captains banned from Starfleet?

How to convince somebody that he is fit for something else, but not this job?

Merge org tables



Pass data to child template in cart-items of checkout page


Magento2 override admin js filemain.CRITICAL: Plugin class doesn't existOneStepCheckout - display subtotals of tax classPrice not getting updated for second product…Magento 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













5















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 ()
return quote.isVirtual() ,
/**
* 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










share|improve this question














bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • 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















5















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 ()
return quote.isVirtual() ,
/**
* 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










share|improve this question














bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • 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













5












5








5








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 ()
return quote.isVirtual() ,
/**
* 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










share|improve this question














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 ()
return quote.isVirtual() ,
/**
* 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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 13 '17 at 4:58









Toàn TamToàn Tam

424314




424314





bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • 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











  • 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










1 Answer
1






active

oldest

votes


















0














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>





share|improve this answer






















    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
    );



    );













    draft saved

    draft discarded


















    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









    0














    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>





    share|improve this answer



























      0














      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>





      share|improve this answer

























        0












        0








        0







        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>





        share|improve this answer













        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>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 25 '18 at 12:53









        sterossteros

        827629




        827629



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

            Magento2 - How to hide price filter only in specific categories?Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?