Magento 2 How to add custom attribute to Quote Item Rest API The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Magento 2 CMS Page getList() repository methods does not return expected objectmain.CRITICAL: Plugin class doesn't existMagento2 add custom address attributeAdd value for custom quote item attribute using REST apiHow to add new field in the Default API responseMagento 2 - Save Extension Attribute afterSave() returns voidCart page error in Magento 2.2.3Add configure product in Cart using Magento 2 API facing an issueMagento2 REST API get all customers detailsMagento 2 REST - SKU to items on cart totals API response is not available, How to get SKU in response API

Why did Peik Lin say, "I'm not an animal"?

How do spell lists change if the party levels up without taking a long rest?

What is the padding with red substance inside of steak packaging?

Drawing vertical/oblique lines in Metrical tree (tikz-qtree, tipa)

Match Roman Numerals

Working through the single responsibility principle (SRP) in Python when calls are expensive

Single author papers against my advisor's will?

How did the crowd guess the pentatonic scale in Bobby McFerrin's presentation?

How do you keep chess fun when your opponent constantly beats you?

What do I do when my TA workload is more than expected?

What happens to a Warlock's expended Spell Slots when they gain a Level?

How to determine omitted units in a publication

60's-70's movie: home appliances revolting against the owners

Identify 80s or 90s comics with ripped creatures (not dwarves)

Why not take a picture of a closer black hole?

Make it rain characters

Am I ethically obligated to go into work on an off day if the reason is sudden?

How do I design a circuit to convert a 100 mV and 50 Hz sine wave to a square wave?

Is 'stolen' appropriate word?

What was the last x86 CPU that did not have the x87 floating-point unit built in?

How to handle characters who are more educated than the author?

What can I do if neighbor is blocking my solar panels intentionally?

Circular reasoning in L'Hopital's rule

When did F become S? Why?



Magento 2 How to add custom attribute to Quote Item Rest API



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Magento 2 CMS Page getList() repository methods does not return expected objectmain.CRITICAL: Plugin class doesn't existMagento2 add custom address attributeAdd value for custom quote item attribute using REST apiHow to add new field in the Default API responseMagento 2 - Save Extension Attribute afterSave() returns voidCart page error in Magento 2.2.3Add configure product in Cart using Magento 2 API facing an issueMagento2 REST API get all customers detailsMagento 2 REST - SKU to items on cart totals API response is not available, How to get SKU in response API



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I want to add custom attribute to http://magento2/rest/V1/carts/mine/totals API response.



I have done follwing way but it not working.



extension_attributes.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
<extension_attributes for="MagentoQuoteApiDataCartItemInterface">
<attribute code="product_option" type="float" />
</extension_attributes>
</config>

di.xml

<type name="MagentoQuoteModelQuoteItem">
<plugin name="cs_product_opt" type="NamespaceProductPluginModelCartCartTotalRepositoryPlugin" />
</type>

Plugin file

<?php
/**
* Copyright 2016 aheadWorks. All rights reserved.
* See LICENSE.txt for license details.
*/

namespace NamespaceProductPluginModelCart;

use MagentoQuoteApiDataTotalsExtensionInterface;
use MagentoQuoteApiDataTotalsExtensionFactory;
use MagentoQuoteApiDataCartItemExtensionFactory;
use MagentoQuoteApiDataTotalsInterface;
use MagentoQuoteApiCartRepositoryInterface;
use MagentoQuoteModelCartCartTotalRepository as TotalRepository;
use MagentoQuoteModelQuote;

/**
* Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
*/
class CartTotalRepositoryPlugin

/**
* @var CartRepositoryInterface
*/
private $quoteRepository;

/**
* @var CartItemExtensionFactory
*/
private $totalsExtensionFactory;

/**
* @param CartRepositoryInterface $quoteRepository
* @param CartItemExtensionFactory $totalsExtensionFactory
*/
public function __construct(
CartRepositoryInterface $quoteRepository,
CartItemExtensionFactory $totalsExtensionFactory
)
$this->quoteRepository = $quoteRepository;
$this->totalsExtensionFactory = $totalsExtensionFactory;


/**
* Apply extension attributes to totals
*
* @param TotalRepository $subject
* @param Closure $proceed
* @param int $cartId
* @return TotalsInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

/** @var TotalsInterface $totals */
$totals = $proceed($cartId);

/** @var MagentoQuoteApiDataTotalsExtensionInterface $extensionAttributes */
$extensionAttributes = $totals->getExtensionAttributes()
? $totals->getExtensionAttributes()
: $this->totalsExtensionFactory->create();

/** @var Quote $quote */
$quote = $this->quoteRepository->getActive($cartId);

$extensionAttributes->setProductOption(1.11);
$totals->setExtensionAttributes($extensionAttributes);
return $totals;




anyone have idea how to add custom attribute to Quote Item Rest API.










share|improve this question














bumped to the homepage by Community 2 days ago


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





















    1















    I want to add custom attribute to http://magento2/rest/V1/carts/mine/totals API response.



    I have done follwing way but it not working.



    extension_attributes.xml

    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
    <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
    <attribute code="product_option" type="float" />
    </extension_attributes>
    </config>

    di.xml

    <type name="MagentoQuoteModelQuoteItem">
    <plugin name="cs_product_opt" type="NamespaceProductPluginModelCartCartTotalRepositoryPlugin" />
    </type>

    Plugin file

    <?php
    /**
    * Copyright 2016 aheadWorks. All rights reserved.
    * See LICENSE.txt for license details.
    */

    namespace NamespaceProductPluginModelCart;

    use MagentoQuoteApiDataTotalsExtensionInterface;
    use MagentoQuoteApiDataTotalsExtensionFactory;
    use MagentoQuoteApiDataCartItemExtensionFactory;
    use MagentoQuoteApiDataTotalsInterface;
    use MagentoQuoteApiCartRepositoryInterface;
    use MagentoQuoteModelCartCartTotalRepository as TotalRepository;
    use MagentoQuoteModelQuote;

    /**
    * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
    */
    class CartTotalRepositoryPlugin

    /**
    * @var CartRepositoryInterface
    */
    private $quoteRepository;

    /**
    * @var CartItemExtensionFactory
    */
    private $totalsExtensionFactory;

    /**
    * @param CartRepositoryInterface $quoteRepository
    * @param CartItemExtensionFactory $totalsExtensionFactory
    */
    public function __construct(
    CartRepositoryInterface $quoteRepository,
    CartItemExtensionFactory $totalsExtensionFactory
    )
    $this->quoteRepository = $quoteRepository;
    $this->totalsExtensionFactory = $totalsExtensionFactory;


    /**
    * Apply extension attributes to totals
    *
    * @param TotalRepository $subject
    * @param Closure $proceed
    * @param int $cartId
    * @return TotalsInterface
    * @SuppressWarnings(PHPMD.UnusedFormalParameter)
    */
    public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

    /** @var TotalsInterface $totals */
    $totals = $proceed($cartId);

    /** @var MagentoQuoteApiDataTotalsExtensionInterface $extensionAttributes */
    $extensionAttributes = $totals->getExtensionAttributes()
    ? $totals->getExtensionAttributes()
    : $this->totalsExtensionFactory->create();

    /** @var Quote $quote */
    $quote = $this->quoteRepository->getActive($cartId);

    $extensionAttributes->setProductOption(1.11);
    $totals->setExtensionAttributes($extensionAttributes);
    return $totals;




    anyone have idea how to add custom attribute to Quote Item Rest API.










    share|improve this question














    bumped to the homepage by Community 2 days ago


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

















      1












      1








      1


      1






      I want to add custom attribute to http://magento2/rest/V1/carts/mine/totals API response.



      I have done follwing way but it not working.



      extension_attributes.xml

      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
      <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
      <attribute code="product_option" type="float" />
      </extension_attributes>
      </config>

      di.xml

      <type name="MagentoQuoteModelQuoteItem">
      <plugin name="cs_product_opt" type="NamespaceProductPluginModelCartCartTotalRepositoryPlugin" />
      </type>

      Plugin file

      <?php
      /**
      * Copyright 2016 aheadWorks. All rights reserved.
      * See LICENSE.txt for license details.
      */

      namespace NamespaceProductPluginModelCart;

      use MagentoQuoteApiDataTotalsExtensionInterface;
      use MagentoQuoteApiDataTotalsExtensionFactory;
      use MagentoQuoteApiDataCartItemExtensionFactory;
      use MagentoQuoteApiDataTotalsInterface;
      use MagentoQuoteApiCartRepositoryInterface;
      use MagentoQuoteModelCartCartTotalRepository as TotalRepository;
      use MagentoQuoteModelQuote;

      /**
      * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
      */
      class CartTotalRepositoryPlugin

      /**
      * @var CartRepositoryInterface
      */
      private $quoteRepository;

      /**
      * @var CartItemExtensionFactory
      */
      private $totalsExtensionFactory;

      /**
      * @param CartRepositoryInterface $quoteRepository
      * @param CartItemExtensionFactory $totalsExtensionFactory
      */
      public function __construct(
      CartRepositoryInterface $quoteRepository,
      CartItemExtensionFactory $totalsExtensionFactory
      )
      $this->quoteRepository = $quoteRepository;
      $this->totalsExtensionFactory = $totalsExtensionFactory;


      /**
      * Apply extension attributes to totals
      *
      * @param TotalRepository $subject
      * @param Closure $proceed
      * @param int $cartId
      * @return TotalsInterface
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
      public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

      /** @var TotalsInterface $totals */
      $totals = $proceed($cartId);

      /** @var MagentoQuoteApiDataTotalsExtensionInterface $extensionAttributes */
      $extensionAttributes = $totals->getExtensionAttributes()
      ? $totals->getExtensionAttributes()
      : $this->totalsExtensionFactory->create();

      /** @var Quote $quote */
      $quote = $this->quoteRepository->getActive($cartId);

      $extensionAttributes->setProductOption(1.11);
      $totals->setExtensionAttributes($extensionAttributes);
      return $totals;




      anyone have idea how to add custom attribute to Quote Item Rest API.










      share|improve this question














      I want to add custom attribute to http://magento2/rest/V1/carts/mine/totals API response.



      I have done follwing way but it not working.



      extension_attributes.xml

      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
      <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
      <attribute code="product_option" type="float" />
      </extension_attributes>
      </config>

      di.xml

      <type name="MagentoQuoteModelQuoteItem">
      <plugin name="cs_product_opt" type="NamespaceProductPluginModelCartCartTotalRepositoryPlugin" />
      </type>

      Plugin file

      <?php
      /**
      * Copyright 2016 aheadWorks. All rights reserved.
      * See LICENSE.txt for license details.
      */

      namespace NamespaceProductPluginModelCart;

      use MagentoQuoteApiDataTotalsExtensionInterface;
      use MagentoQuoteApiDataTotalsExtensionFactory;
      use MagentoQuoteApiDataCartItemExtensionFactory;
      use MagentoQuoteApiDataTotalsInterface;
      use MagentoQuoteApiCartRepositoryInterface;
      use MagentoQuoteModelCartCartTotalRepository as TotalRepository;
      use MagentoQuoteModelQuote;

      /**
      * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
      */
      class CartTotalRepositoryPlugin

      /**
      * @var CartRepositoryInterface
      */
      private $quoteRepository;

      /**
      * @var CartItemExtensionFactory
      */
      private $totalsExtensionFactory;

      /**
      * @param CartRepositoryInterface $quoteRepository
      * @param CartItemExtensionFactory $totalsExtensionFactory
      */
      public function __construct(
      CartRepositoryInterface $quoteRepository,
      CartItemExtensionFactory $totalsExtensionFactory
      )
      $this->quoteRepository = $quoteRepository;
      $this->totalsExtensionFactory = $totalsExtensionFactory;


      /**
      * Apply extension attributes to totals
      *
      * @param TotalRepository $subject
      * @param Closure $proceed
      * @param int $cartId
      * @return TotalsInterface
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
      public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

      /** @var TotalsInterface $totals */
      $totals = $proceed($cartId);

      /** @var MagentoQuoteApiDataTotalsExtensionInterface $extensionAttributes */
      $extensionAttributes = $totals->getExtensionAttributes()
      ? $totals->getExtensionAttributes()
      : $this->totalsExtensionFactory->create();

      /** @var Quote $quote */
      $quote = $this->quoteRepository->getActive($cartId);

      $extensionAttributes->setProductOption(1.11);
      $totals->setExtensionAttributes($extensionAttributes);
      return $totals;




      anyone have idea how to add custom attribute to Quote Item Rest API.







      magento2 api rest-api






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 6:01









      Niranjan GondaliyaNiranjan Gondaliya

      1789




      1789





      bumped to the homepage by Community 2 days ago


      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 2 days ago


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






















          1 Answer
          1






          active

          oldest

          votes


















          0














          To add new attribute on cart item. you need to consume V1/carts/mine service.



          CartRepositoryPlugin.php



          <?php
          /**
          * Copyright 2016 aheadWorks. All rights reserved.
          * See LICENSE.txt for license details.
          */

          namespace NamespaceProductPluginModelCart;

          use MagentoQuoteApi;
          use MagentoQuoteApiCartRepositoryInterface;
          use MagentoQuoteApiCartTotalRepositoryInterface;
          use MagentoCatalogHelperProductConfigurationPool;
          use MagentoFrameworkApiDataObjectHelper;
          use MagentoFrameworkApiExtensibleDataInterface;
          use MagentoQuoteModelCartTotalsItemConverter;
          use MagentoQuoteApiCouponManagementInterface;
          use MagentoQuoteModelCartTotalsConverter;
          use MagentoQuoteApiDataCartItemExtensionFactory;
          use MagentoQuoteModelCartCartTotalRepository as TotalRepository;

          /**
          * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
          */
          class CartRepositoryPlugin

          /**
          * Cart totals factory.
          *
          * @var ApiDataTotalsInterfaceFactory
          */
          private $totalsFactory;

          /**
          * Quote repository.
          *
          * @var MagentoQuoteApiCartRepositoryInterface
          */
          private $quoteRepository;

          /**
          * @var MagentoFrameworkApiDataObjectHelper
          */
          private $dataObjectHelper;

          /**
          * @var ConfigurationPool
          */
          private $itemConverter;

          /**
          * @var CouponManagementInterface
          */
          protected $couponService;

          /**
          * @var TotalsConverter
          */
          protected $totalsConverter;

          /**
          * @param ApiDataTotalsInterfaceFactory $totalsFactory
          * @param CartRepositoryInterface $quoteRepository
          * @param DataObjectHelper $dataObjectHelper
          * @param CouponManagementInterface $couponService
          * @param TotalsConverter $totalsConverter
          * @param ItemConverter $converter
          */
          public function __construct(
          ApiDataTotalsInterfaceFactory $totalsFactory,
          CartRepositoryInterface $quoteRepository,
          DataObjectHelper $dataObjectHelper,
          CouponManagementInterface $couponService,
          TotalsConverter $totalsConverter,
          CartItemExtensionFactory $cartItemInterfaceFactory,
          ItemConverter $converter
          )
          $this->totalsFactory = $totalsFactory;
          $this->quoteRepository = $quoteRepository;
          $this->dataObjectHelper = $dataObjectHelper;
          $this->couponService = $couponService;
          $this->totalsConverter = $totalsConverter;
          $this->cartItemInterfaceFactory = $cartItemInterfaceFactory;
          $this->itemConverter = $converter;


          /**
          * Apply extension attributes to totals
          *
          * @param TotalRepository $subject
          * @param Closure $proceed
          * @param int $cartId
          * @return TotalsInterface
          * @SuppressWarnings(PHPMD.UnusedFormalParameter)
          */

          public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

          /** @var MagentoQuoteModelQuote $quote */
          $quote = $this->quoteRepository->getActive($cartId);
          if ($quote->isVirtual())
          $addressTotalsData = $quote->getBillingAddress()->getData();
          $addressTotals = $quote->getBillingAddress()->getTotals();
          else
          $addressTotalsData = $quote->getShippingAddress()->getData();
          $addressTotals = $quote->getShippingAddress()->getTotals();

          unset($addressTotalsData[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);

          /** @var MagentoQuoteApiDataTotalsInterface $quoteTotals */
          $quoteTotals = $this->totalsFactory->create();
          $this->dataObjectHelper->populateWithArray(
          $quoteTotals,
          $addressTotalsData,
          MagentoQuoteApiDataTotalsInterface::class
          );
          $items = [];
          foreach ($quote->getAllVisibleItems() as $index => $item)
          $cartItemExtensionAttributes = $item->getExtensionAttributes();
          if($cartItemExtensionAttributes == null)
          $cartItemExtensionAttributes = $this->cartItemInterfaceFactory->create();
          $cartItemExtensionAttributes->setProductOption('Product Option Check');
          $item->setExtensionAttributes($cartItemExtensionAttributes);
          $item->save();

          $items[$index] = $this->itemConverter->modelToDataObject($item);


          $calculatedTotals = $this->totalsConverter->process($addressTotals);
          $quoteTotals->setTotalSegments($calculatedTotals);
          $amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
          $amount = $amount > 0 ? $amount : 0;
          $quoteTotals->setCouponCode($this->couponService->get($cartId));
          $quoteTotals->setGrandTotal($amount);
          $quoteTotals->setItems($items);
          $quoteTotals->setItemsQty($quote->getItemsQty());
          $quoteTotals->setBaseCurrencyCode($quote->getBaseCurrencyCode());
          $quoteTotals->setQuoteCurrencyCode($quote->getQuoteCurrencyCode());
          return $quoteTotals;




          extension_attributes.xml



           <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
          <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
          <attribute code="product_option" type="string" />
          </extension_attributes>




          di.xml



           <type name="MagentoQuoteModelCartCartTotalRepository">
          <plugin name="cp_product_opt" type="CommercepunditProductPluginModelCartCartRepositoryPlugin" />
          </type>


          I hope it'll work for you. Let me know if you need further help.






          share|improve this answer

























          • no i no needed in total i want this in Quote Item.

            – Niranjan Gondaliya
            Nov 21 '18 at 6:32











          • if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

            – Ramkishan Suthar
            Nov 21 '18 at 6:57











          • Please check updated answer.

            – Ramkishan Suthar
            Nov 21 '18 at 7:05











          • ok Let me implement

            – Niranjan Gondaliya
            Nov 21 '18 at 7:13











          • Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

            – Niranjan Gondaliya
            Nov 21 '18 at 7:32











          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%2f250744%2fmagento-2-how-to-add-custom-attribute-to-quote-item-rest-api%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














          To add new attribute on cart item. you need to consume V1/carts/mine service.



          CartRepositoryPlugin.php



          <?php
          /**
          * Copyright 2016 aheadWorks. All rights reserved.
          * See LICENSE.txt for license details.
          */

          namespace NamespaceProductPluginModelCart;

          use MagentoQuoteApi;
          use MagentoQuoteApiCartRepositoryInterface;
          use MagentoQuoteApiCartTotalRepositoryInterface;
          use MagentoCatalogHelperProductConfigurationPool;
          use MagentoFrameworkApiDataObjectHelper;
          use MagentoFrameworkApiExtensibleDataInterface;
          use MagentoQuoteModelCartTotalsItemConverter;
          use MagentoQuoteApiCouponManagementInterface;
          use MagentoQuoteModelCartTotalsConverter;
          use MagentoQuoteApiDataCartItemExtensionFactory;
          use MagentoQuoteModelCartCartTotalRepository as TotalRepository;

          /**
          * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
          */
          class CartRepositoryPlugin

          /**
          * Cart totals factory.
          *
          * @var ApiDataTotalsInterfaceFactory
          */
          private $totalsFactory;

          /**
          * Quote repository.
          *
          * @var MagentoQuoteApiCartRepositoryInterface
          */
          private $quoteRepository;

          /**
          * @var MagentoFrameworkApiDataObjectHelper
          */
          private $dataObjectHelper;

          /**
          * @var ConfigurationPool
          */
          private $itemConverter;

          /**
          * @var CouponManagementInterface
          */
          protected $couponService;

          /**
          * @var TotalsConverter
          */
          protected $totalsConverter;

          /**
          * @param ApiDataTotalsInterfaceFactory $totalsFactory
          * @param CartRepositoryInterface $quoteRepository
          * @param DataObjectHelper $dataObjectHelper
          * @param CouponManagementInterface $couponService
          * @param TotalsConverter $totalsConverter
          * @param ItemConverter $converter
          */
          public function __construct(
          ApiDataTotalsInterfaceFactory $totalsFactory,
          CartRepositoryInterface $quoteRepository,
          DataObjectHelper $dataObjectHelper,
          CouponManagementInterface $couponService,
          TotalsConverter $totalsConverter,
          CartItemExtensionFactory $cartItemInterfaceFactory,
          ItemConverter $converter
          )
          $this->totalsFactory = $totalsFactory;
          $this->quoteRepository = $quoteRepository;
          $this->dataObjectHelper = $dataObjectHelper;
          $this->couponService = $couponService;
          $this->totalsConverter = $totalsConverter;
          $this->cartItemInterfaceFactory = $cartItemInterfaceFactory;
          $this->itemConverter = $converter;


          /**
          * Apply extension attributes to totals
          *
          * @param TotalRepository $subject
          * @param Closure $proceed
          * @param int $cartId
          * @return TotalsInterface
          * @SuppressWarnings(PHPMD.UnusedFormalParameter)
          */

          public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

          /** @var MagentoQuoteModelQuote $quote */
          $quote = $this->quoteRepository->getActive($cartId);
          if ($quote->isVirtual())
          $addressTotalsData = $quote->getBillingAddress()->getData();
          $addressTotals = $quote->getBillingAddress()->getTotals();
          else
          $addressTotalsData = $quote->getShippingAddress()->getData();
          $addressTotals = $quote->getShippingAddress()->getTotals();

          unset($addressTotalsData[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);

          /** @var MagentoQuoteApiDataTotalsInterface $quoteTotals */
          $quoteTotals = $this->totalsFactory->create();
          $this->dataObjectHelper->populateWithArray(
          $quoteTotals,
          $addressTotalsData,
          MagentoQuoteApiDataTotalsInterface::class
          );
          $items = [];
          foreach ($quote->getAllVisibleItems() as $index => $item)
          $cartItemExtensionAttributes = $item->getExtensionAttributes();
          if($cartItemExtensionAttributes == null)
          $cartItemExtensionAttributes = $this->cartItemInterfaceFactory->create();
          $cartItemExtensionAttributes->setProductOption('Product Option Check');
          $item->setExtensionAttributes($cartItemExtensionAttributes);
          $item->save();

          $items[$index] = $this->itemConverter->modelToDataObject($item);


          $calculatedTotals = $this->totalsConverter->process($addressTotals);
          $quoteTotals->setTotalSegments($calculatedTotals);
          $amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
          $amount = $amount > 0 ? $amount : 0;
          $quoteTotals->setCouponCode($this->couponService->get($cartId));
          $quoteTotals->setGrandTotal($amount);
          $quoteTotals->setItems($items);
          $quoteTotals->setItemsQty($quote->getItemsQty());
          $quoteTotals->setBaseCurrencyCode($quote->getBaseCurrencyCode());
          $quoteTotals->setQuoteCurrencyCode($quote->getQuoteCurrencyCode());
          return $quoteTotals;




          extension_attributes.xml



           <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
          <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
          <attribute code="product_option" type="string" />
          </extension_attributes>




          di.xml



           <type name="MagentoQuoteModelCartCartTotalRepository">
          <plugin name="cp_product_opt" type="CommercepunditProductPluginModelCartCartRepositoryPlugin" />
          </type>


          I hope it'll work for you. Let me know if you need further help.






          share|improve this answer

























          • no i no needed in total i want this in Quote Item.

            – Niranjan Gondaliya
            Nov 21 '18 at 6:32











          • if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

            – Ramkishan Suthar
            Nov 21 '18 at 6:57











          • Please check updated answer.

            – Ramkishan Suthar
            Nov 21 '18 at 7:05











          • ok Let me implement

            – Niranjan Gondaliya
            Nov 21 '18 at 7:13











          • Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

            – Niranjan Gondaliya
            Nov 21 '18 at 7:32















          0














          To add new attribute on cart item. you need to consume V1/carts/mine service.



          CartRepositoryPlugin.php



          <?php
          /**
          * Copyright 2016 aheadWorks. All rights reserved.
          * See LICENSE.txt for license details.
          */

          namespace NamespaceProductPluginModelCart;

          use MagentoQuoteApi;
          use MagentoQuoteApiCartRepositoryInterface;
          use MagentoQuoteApiCartTotalRepositoryInterface;
          use MagentoCatalogHelperProductConfigurationPool;
          use MagentoFrameworkApiDataObjectHelper;
          use MagentoFrameworkApiExtensibleDataInterface;
          use MagentoQuoteModelCartTotalsItemConverter;
          use MagentoQuoteApiCouponManagementInterface;
          use MagentoQuoteModelCartTotalsConverter;
          use MagentoQuoteApiDataCartItemExtensionFactory;
          use MagentoQuoteModelCartCartTotalRepository as TotalRepository;

          /**
          * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
          */
          class CartRepositoryPlugin

          /**
          * Cart totals factory.
          *
          * @var ApiDataTotalsInterfaceFactory
          */
          private $totalsFactory;

          /**
          * Quote repository.
          *
          * @var MagentoQuoteApiCartRepositoryInterface
          */
          private $quoteRepository;

          /**
          * @var MagentoFrameworkApiDataObjectHelper
          */
          private $dataObjectHelper;

          /**
          * @var ConfigurationPool
          */
          private $itemConverter;

          /**
          * @var CouponManagementInterface
          */
          protected $couponService;

          /**
          * @var TotalsConverter
          */
          protected $totalsConverter;

          /**
          * @param ApiDataTotalsInterfaceFactory $totalsFactory
          * @param CartRepositoryInterface $quoteRepository
          * @param DataObjectHelper $dataObjectHelper
          * @param CouponManagementInterface $couponService
          * @param TotalsConverter $totalsConverter
          * @param ItemConverter $converter
          */
          public function __construct(
          ApiDataTotalsInterfaceFactory $totalsFactory,
          CartRepositoryInterface $quoteRepository,
          DataObjectHelper $dataObjectHelper,
          CouponManagementInterface $couponService,
          TotalsConverter $totalsConverter,
          CartItemExtensionFactory $cartItemInterfaceFactory,
          ItemConverter $converter
          )
          $this->totalsFactory = $totalsFactory;
          $this->quoteRepository = $quoteRepository;
          $this->dataObjectHelper = $dataObjectHelper;
          $this->couponService = $couponService;
          $this->totalsConverter = $totalsConverter;
          $this->cartItemInterfaceFactory = $cartItemInterfaceFactory;
          $this->itemConverter = $converter;


          /**
          * Apply extension attributes to totals
          *
          * @param TotalRepository $subject
          * @param Closure $proceed
          * @param int $cartId
          * @return TotalsInterface
          * @SuppressWarnings(PHPMD.UnusedFormalParameter)
          */

          public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

          /** @var MagentoQuoteModelQuote $quote */
          $quote = $this->quoteRepository->getActive($cartId);
          if ($quote->isVirtual())
          $addressTotalsData = $quote->getBillingAddress()->getData();
          $addressTotals = $quote->getBillingAddress()->getTotals();
          else
          $addressTotalsData = $quote->getShippingAddress()->getData();
          $addressTotals = $quote->getShippingAddress()->getTotals();

          unset($addressTotalsData[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);

          /** @var MagentoQuoteApiDataTotalsInterface $quoteTotals */
          $quoteTotals = $this->totalsFactory->create();
          $this->dataObjectHelper->populateWithArray(
          $quoteTotals,
          $addressTotalsData,
          MagentoQuoteApiDataTotalsInterface::class
          );
          $items = [];
          foreach ($quote->getAllVisibleItems() as $index => $item)
          $cartItemExtensionAttributes = $item->getExtensionAttributes();
          if($cartItemExtensionAttributes == null)
          $cartItemExtensionAttributes = $this->cartItemInterfaceFactory->create();
          $cartItemExtensionAttributes->setProductOption('Product Option Check');
          $item->setExtensionAttributes($cartItemExtensionAttributes);
          $item->save();

          $items[$index] = $this->itemConverter->modelToDataObject($item);


          $calculatedTotals = $this->totalsConverter->process($addressTotals);
          $quoteTotals->setTotalSegments($calculatedTotals);
          $amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
          $amount = $amount > 0 ? $amount : 0;
          $quoteTotals->setCouponCode($this->couponService->get($cartId));
          $quoteTotals->setGrandTotal($amount);
          $quoteTotals->setItems($items);
          $quoteTotals->setItemsQty($quote->getItemsQty());
          $quoteTotals->setBaseCurrencyCode($quote->getBaseCurrencyCode());
          $quoteTotals->setQuoteCurrencyCode($quote->getQuoteCurrencyCode());
          return $quoteTotals;




          extension_attributes.xml



           <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
          <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
          <attribute code="product_option" type="string" />
          </extension_attributes>




          di.xml



           <type name="MagentoQuoteModelCartCartTotalRepository">
          <plugin name="cp_product_opt" type="CommercepunditProductPluginModelCartCartRepositoryPlugin" />
          </type>


          I hope it'll work for you. Let me know if you need further help.






          share|improve this answer

























          • no i no needed in total i want this in Quote Item.

            – Niranjan Gondaliya
            Nov 21 '18 at 6:32











          • if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

            – Ramkishan Suthar
            Nov 21 '18 at 6:57











          • Please check updated answer.

            – Ramkishan Suthar
            Nov 21 '18 at 7:05











          • ok Let me implement

            – Niranjan Gondaliya
            Nov 21 '18 at 7:13











          • Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

            – Niranjan Gondaliya
            Nov 21 '18 at 7:32













          0












          0








          0







          To add new attribute on cart item. you need to consume V1/carts/mine service.



          CartRepositoryPlugin.php



          <?php
          /**
          * Copyright 2016 aheadWorks. All rights reserved.
          * See LICENSE.txt for license details.
          */

          namespace NamespaceProductPluginModelCart;

          use MagentoQuoteApi;
          use MagentoQuoteApiCartRepositoryInterface;
          use MagentoQuoteApiCartTotalRepositoryInterface;
          use MagentoCatalogHelperProductConfigurationPool;
          use MagentoFrameworkApiDataObjectHelper;
          use MagentoFrameworkApiExtensibleDataInterface;
          use MagentoQuoteModelCartTotalsItemConverter;
          use MagentoQuoteApiCouponManagementInterface;
          use MagentoQuoteModelCartTotalsConverter;
          use MagentoQuoteApiDataCartItemExtensionFactory;
          use MagentoQuoteModelCartCartTotalRepository as TotalRepository;

          /**
          * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
          */
          class CartRepositoryPlugin

          /**
          * Cart totals factory.
          *
          * @var ApiDataTotalsInterfaceFactory
          */
          private $totalsFactory;

          /**
          * Quote repository.
          *
          * @var MagentoQuoteApiCartRepositoryInterface
          */
          private $quoteRepository;

          /**
          * @var MagentoFrameworkApiDataObjectHelper
          */
          private $dataObjectHelper;

          /**
          * @var ConfigurationPool
          */
          private $itemConverter;

          /**
          * @var CouponManagementInterface
          */
          protected $couponService;

          /**
          * @var TotalsConverter
          */
          protected $totalsConverter;

          /**
          * @param ApiDataTotalsInterfaceFactory $totalsFactory
          * @param CartRepositoryInterface $quoteRepository
          * @param DataObjectHelper $dataObjectHelper
          * @param CouponManagementInterface $couponService
          * @param TotalsConverter $totalsConverter
          * @param ItemConverter $converter
          */
          public function __construct(
          ApiDataTotalsInterfaceFactory $totalsFactory,
          CartRepositoryInterface $quoteRepository,
          DataObjectHelper $dataObjectHelper,
          CouponManagementInterface $couponService,
          TotalsConverter $totalsConverter,
          CartItemExtensionFactory $cartItemInterfaceFactory,
          ItemConverter $converter
          )
          $this->totalsFactory = $totalsFactory;
          $this->quoteRepository = $quoteRepository;
          $this->dataObjectHelper = $dataObjectHelper;
          $this->couponService = $couponService;
          $this->totalsConverter = $totalsConverter;
          $this->cartItemInterfaceFactory = $cartItemInterfaceFactory;
          $this->itemConverter = $converter;


          /**
          * Apply extension attributes to totals
          *
          * @param TotalRepository $subject
          * @param Closure $proceed
          * @param int $cartId
          * @return TotalsInterface
          * @SuppressWarnings(PHPMD.UnusedFormalParameter)
          */

          public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

          /** @var MagentoQuoteModelQuote $quote */
          $quote = $this->quoteRepository->getActive($cartId);
          if ($quote->isVirtual())
          $addressTotalsData = $quote->getBillingAddress()->getData();
          $addressTotals = $quote->getBillingAddress()->getTotals();
          else
          $addressTotalsData = $quote->getShippingAddress()->getData();
          $addressTotals = $quote->getShippingAddress()->getTotals();

          unset($addressTotalsData[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);

          /** @var MagentoQuoteApiDataTotalsInterface $quoteTotals */
          $quoteTotals = $this->totalsFactory->create();
          $this->dataObjectHelper->populateWithArray(
          $quoteTotals,
          $addressTotalsData,
          MagentoQuoteApiDataTotalsInterface::class
          );
          $items = [];
          foreach ($quote->getAllVisibleItems() as $index => $item)
          $cartItemExtensionAttributes = $item->getExtensionAttributes();
          if($cartItemExtensionAttributes == null)
          $cartItemExtensionAttributes = $this->cartItemInterfaceFactory->create();
          $cartItemExtensionAttributes->setProductOption('Product Option Check');
          $item->setExtensionAttributes($cartItemExtensionAttributes);
          $item->save();

          $items[$index] = $this->itemConverter->modelToDataObject($item);


          $calculatedTotals = $this->totalsConverter->process($addressTotals);
          $quoteTotals->setTotalSegments($calculatedTotals);
          $amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
          $amount = $amount > 0 ? $amount : 0;
          $quoteTotals->setCouponCode($this->couponService->get($cartId));
          $quoteTotals->setGrandTotal($amount);
          $quoteTotals->setItems($items);
          $quoteTotals->setItemsQty($quote->getItemsQty());
          $quoteTotals->setBaseCurrencyCode($quote->getBaseCurrencyCode());
          $quoteTotals->setQuoteCurrencyCode($quote->getQuoteCurrencyCode());
          return $quoteTotals;




          extension_attributes.xml



           <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
          <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
          <attribute code="product_option" type="string" />
          </extension_attributes>




          di.xml



           <type name="MagentoQuoteModelCartCartTotalRepository">
          <plugin name="cp_product_opt" type="CommercepunditProductPluginModelCartCartRepositoryPlugin" />
          </type>


          I hope it'll work for you. Let me know if you need further help.






          share|improve this answer















          To add new attribute on cart item. you need to consume V1/carts/mine service.



          CartRepositoryPlugin.php



          <?php
          /**
          * Copyright 2016 aheadWorks. All rights reserved.
          * See LICENSE.txt for license details.
          */

          namespace NamespaceProductPluginModelCart;

          use MagentoQuoteApi;
          use MagentoQuoteApiCartRepositoryInterface;
          use MagentoQuoteApiCartTotalRepositoryInterface;
          use MagentoCatalogHelperProductConfigurationPool;
          use MagentoFrameworkApiDataObjectHelper;
          use MagentoFrameworkApiExtensibleDataInterface;
          use MagentoQuoteModelCartTotalsItemConverter;
          use MagentoQuoteApiCouponManagementInterface;
          use MagentoQuoteModelCartTotalsConverter;
          use MagentoQuoteApiDataCartItemExtensionFactory;
          use MagentoQuoteModelCartCartTotalRepository as TotalRepository;

          /**
          * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
          */
          class CartRepositoryPlugin

          /**
          * Cart totals factory.
          *
          * @var ApiDataTotalsInterfaceFactory
          */
          private $totalsFactory;

          /**
          * Quote repository.
          *
          * @var MagentoQuoteApiCartRepositoryInterface
          */
          private $quoteRepository;

          /**
          * @var MagentoFrameworkApiDataObjectHelper
          */
          private $dataObjectHelper;

          /**
          * @var ConfigurationPool
          */
          private $itemConverter;

          /**
          * @var CouponManagementInterface
          */
          protected $couponService;

          /**
          * @var TotalsConverter
          */
          protected $totalsConverter;

          /**
          * @param ApiDataTotalsInterfaceFactory $totalsFactory
          * @param CartRepositoryInterface $quoteRepository
          * @param DataObjectHelper $dataObjectHelper
          * @param CouponManagementInterface $couponService
          * @param TotalsConverter $totalsConverter
          * @param ItemConverter $converter
          */
          public function __construct(
          ApiDataTotalsInterfaceFactory $totalsFactory,
          CartRepositoryInterface $quoteRepository,
          DataObjectHelper $dataObjectHelper,
          CouponManagementInterface $couponService,
          TotalsConverter $totalsConverter,
          CartItemExtensionFactory $cartItemInterfaceFactory,
          ItemConverter $converter
          )
          $this->totalsFactory = $totalsFactory;
          $this->quoteRepository = $quoteRepository;
          $this->dataObjectHelper = $dataObjectHelper;
          $this->couponService = $couponService;
          $this->totalsConverter = $totalsConverter;
          $this->cartItemInterfaceFactory = $cartItemInterfaceFactory;
          $this->itemConverter = $converter;


          /**
          * Apply extension attributes to totals
          *
          * @param TotalRepository $subject
          * @param Closure $proceed
          * @param int $cartId
          * @return TotalsInterface
          * @SuppressWarnings(PHPMD.UnusedFormalParameter)
          */

          public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

          /** @var MagentoQuoteModelQuote $quote */
          $quote = $this->quoteRepository->getActive($cartId);
          if ($quote->isVirtual())
          $addressTotalsData = $quote->getBillingAddress()->getData();
          $addressTotals = $quote->getBillingAddress()->getTotals();
          else
          $addressTotalsData = $quote->getShippingAddress()->getData();
          $addressTotals = $quote->getShippingAddress()->getTotals();

          unset($addressTotalsData[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);

          /** @var MagentoQuoteApiDataTotalsInterface $quoteTotals */
          $quoteTotals = $this->totalsFactory->create();
          $this->dataObjectHelper->populateWithArray(
          $quoteTotals,
          $addressTotalsData,
          MagentoQuoteApiDataTotalsInterface::class
          );
          $items = [];
          foreach ($quote->getAllVisibleItems() as $index => $item)
          $cartItemExtensionAttributes = $item->getExtensionAttributes();
          if($cartItemExtensionAttributes == null)
          $cartItemExtensionAttributes = $this->cartItemInterfaceFactory->create();
          $cartItemExtensionAttributes->setProductOption('Product Option Check');
          $item->setExtensionAttributes($cartItemExtensionAttributes);
          $item->save();

          $items[$index] = $this->itemConverter->modelToDataObject($item);


          $calculatedTotals = $this->totalsConverter->process($addressTotals);
          $quoteTotals->setTotalSegments($calculatedTotals);
          $amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
          $amount = $amount > 0 ? $amount : 0;
          $quoteTotals->setCouponCode($this->couponService->get($cartId));
          $quoteTotals->setGrandTotal($amount);
          $quoteTotals->setItems($items);
          $quoteTotals->setItemsQty($quote->getItemsQty());
          $quoteTotals->setBaseCurrencyCode($quote->getBaseCurrencyCode());
          $quoteTotals->setQuoteCurrencyCode($quote->getQuoteCurrencyCode());
          return $quoteTotals;




          extension_attributes.xml



           <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
          <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
          <attribute code="product_option" type="string" />
          </extension_attributes>




          di.xml



           <type name="MagentoQuoteModelCartCartTotalRepository">
          <plugin name="cp_product_opt" type="CommercepunditProductPluginModelCartCartRepositoryPlugin" />
          </type>


          I hope it'll work for you. Let me know if you need further help.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 22 '18 at 6:07

























          answered Nov 21 '18 at 6:19









          Ramkishan SutharRamkishan Suthar

          2,29221435




          2,29221435












          • no i no needed in total i want this in Quote Item.

            – Niranjan Gondaliya
            Nov 21 '18 at 6:32











          • if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

            – Ramkishan Suthar
            Nov 21 '18 at 6:57











          • Please check updated answer.

            – Ramkishan Suthar
            Nov 21 '18 at 7:05











          • ok Let me implement

            – Niranjan Gondaliya
            Nov 21 '18 at 7:13











          • Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

            – Niranjan Gondaliya
            Nov 21 '18 at 7:32

















          • no i no needed in total i want this in Quote Item.

            – Niranjan Gondaliya
            Nov 21 '18 at 6:32











          • if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

            – Ramkishan Suthar
            Nov 21 '18 at 6:57











          • Please check updated answer.

            – Ramkishan Suthar
            Nov 21 '18 at 7:05











          • ok Let me implement

            – Niranjan Gondaliya
            Nov 21 '18 at 7:13











          • Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

            – Niranjan Gondaliya
            Nov 21 '18 at 7:32
















          no i no needed in total i want this in Quote Item.

          – Niranjan Gondaliya
          Nov 21 '18 at 6:32





          no i no needed in total i want this in Quote Item.

          – Niranjan Gondaliya
          Nov 21 '18 at 6:32













          if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

          – Ramkishan Suthar
          Nov 21 '18 at 6:57





          if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

          – Ramkishan Suthar
          Nov 21 '18 at 6:57













          Please check updated answer.

          – Ramkishan Suthar
          Nov 21 '18 at 7:05





          Please check updated answer.

          – Ramkishan Suthar
          Nov 21 '18 at 7:05













          ok Let me implement

          – Niranjan Gondaliya
          Nov 21 '18 at 7:13





          ok Let me implement

          – Niranjan Gondaliya
          Nov 21 '18 at 7:13













          Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

          – Niranjan Gondaliya
          Nov 21 '18 at 7:32





          Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

          – Niranjan Gondaliya
          Nov 21 '18 at 7:32

















          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%2f250744%2fmagento-2-how-to-add-custom-attribute-to-quote-item-rest-api%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

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?