Home » Magento, Magento 226 September 2016

Magento 2: Get Product’s Custom Option Value from Cart & Order

This article shows how to get custom option values of products/items added to cart or products of any order in Magento 2.

I will simply be using ObjectManager for this example.

Get custom options of products present in shopping cart

Get custom options of products present any order

It is always recommended to use the above code with dependency injection in your custom module instead of directly using Object Manager. Here is how you can do it:

Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of \Magento\Sales\Model\Order in the constructor of my module’s block class.


Now, we use can the function in our template (.phtml) file.

Hope this helps. Thanks.

Magento 2

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Ubed Arab

    How to get attribute on cart page in imagento2 ?
    like selected size and color for configrable product.

  • Purushotam Sangroula

    How to set values in custom option programatically?

  • Dhaval Mistry

    Can you please tell me that how can i load a particular order into cart?