0

I followed this instruction for attribute on checkout summary , but I need to add two attributes to the checkout summary.

In file SampWork/ConfigCheckoutDynamicPCB/etc/catalog_attributes.xml I modified it like this:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd">
    <group name="quote_item">
        <attribute name="custom_attr1"/>
        <attribute name="custom_attr2"/>
    </group>
</config>

In file SampWork/ConfigCheckoutDynamicPCB/Plugin/Checkout/Model/DefaultConfigProvider.php I modified it like this:

        foreach ($items as $index => $item) {
            $quoteItem = $this->checkoutSession->getQuote()->getItemById($item['item_id']);
            $result['quoteItemData'][$index]['custom_attr1'] = $quoteItem->getProduct()->getAttributeText('custom_attr1');
            $result['quoteItemData'][$index]['custom_attr2'] = $quoteItem->getProduct()->getAttributeText('custom_attr2');
        }

In file SampWork/SampWork/ConfigCheckoutDynamicPCB/view/frontend/web/js/view/summary/item/details.js I modified it like this:

        return Component.extend({
            defaults: {
                template: 'EszCorp_HideShipping/summary/item/details'
            },
            quoteItemData: quoteItemData,
            getValue: function(quoteItem) {
                return quoteItem.name;
            },
            getCHAttr1: function(quoteItem) {
                var item = this.getItem(quoteItem.item_id);
                return item.custom_attr1;
            },
            getCHAttr2: function(quoteItem) {
                var item = this.getItem(quoteItem.item_id);
                return item.custom_attr2;
            },
            getItem: function(item_id) {
                var itemElement = null;
                _.each(this.quoteItemData, function(element, index) {
                    if (element.item_id == item_id) {
                        itemElement = element;
                    }
                });
                return itemElement;
            }
        });

And after this modification extension doesn't work properly.

Hope for your advice.

Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.