cancel
Showing results for 
Search instead for 
Did you mean: 

Remove Customizable Options in Invoice/Order/

Remove Customizable Options in Invoice/Order/

Hi guys,

 

I have a product with a Color option which is the Configurable Product. It has 2 customizable options Flavour and Size. However, I would like to remove it from everywhere (invoice/order/etc..). 

 

I was able to remove it in the mini cart and Order summary. but I do not know where to find the code when the product is added to cart and the order is placed

Capture.PNG

 

Kind Regards

1 REPLY 1

Re: Remove Customizable Options in Order, Invoice, Shipment and Credit-Memo

Yes it is possible, to remove this..

Create plugin of 

Magento\Sales\Model\Order\Item class.

Create below method plugin


/**
* Modify product options to hide configurable options for ordered items
*
* @param Item $subject
* @param array|null $result
* @return array|null
*/
public function afterGetProductOptions(Item $subject, $result)
{
     if (!$this->isEnable()) {
         return $result;
     }

     if ($subject->getProductType() === 'configurable' && isset($result['attributes_info'])) {
         $productId = $subject->getProductId();

         $temp_result = $result;
         try {
             $product = $this->productRepository->getById($productId);
             $configurableAttributes = $this->configurableType->getConfigurableAttributesAsArray($product);

             $configurableAttributeLabels = array_column($configurableAttributes, 'label');

             $filteredAttributes = array_filter($result['attributes_info'], function ($attribute) use ($configurableAttributeLabels) {
                    return isset($attribute['label']) && !in_array($attribute['label'], $configurableAttributeLabels);
             });

             $result['attributes_info'] = $filteredAttributes;
        } catch (\Exception $e) {
             $result = $temp_result;
        }
    }
    return $result;
}

@tony_le2 wrote:

Hi guys,

 

I have a product with a Color option which is the Configurable Product. It has 2 customizable options Flavour and Size. However, I would like to remove it from everywhere (invoice/order/etc..). 

 

I was able to remove it in the mini cart and Order summary. but I do not know where to find the code when the product is added to cart and the order is placed

Capture.PNG

 

Kind Regards





@tony_le2 wrote:

Hi guys,

 

I have a product with a Color option which is the Configurable Product. It has 2 customizable options Flavour and Size. However, I would like to remove it from everywhere (invoice/order/etc..). 

 

I was able to remove it in the mini cart and Order summary. but I do not know where to find the code when the product is added to cart and the order is placed

Capture.PNG

 

Kind Regards