1

If you buy a configurable product, then all options are showing in the invoice for example at www.example.com/sales/order/print/order_id/14807/

My team wants me to remove all the configurable options and only show the product name.

enter image description here

I figured out, that the layout is here:

vendor\magento\module-sales\view\frontend\layout\sales_order_print.xml

this is the template:

vendor\magento\module-sales\view\frontend\templates\order\items.phtml

it contains this line, which is reponsible for the items being rendered:

<?= $block->getItemHtml($item) ?>

So I analysed the method in the block

vendor\magento\module-sales\Block\Items\AbstractItems.php

public function getItemHtml(\Magento\Framework\DataObject $item)
{
    $type = $this->_getItemType($item);

    $block = $this->getItemRenderer($type)->setItem($item);
    $this->_prepareItem($block);
    return $block->toHtml();
}

but I have no clue how I have to modify it

1 Answer 1

1

You are so closed on finding out the answer on yourself.

If you dig further, you will find the item renderer uses item template vendor/magento/module-sales/view/frontend/templates/email/items/order/default.phtml You can just override this template and remove the option display from line 19-28

Or with a better DI plugin approach, create a afterGetItemOptions plugin to Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder to return an empty array.

If you need to modify other product types too, you need to find out their own renderer class or template

3
  • Thank you so much, I had no clue on how to find that template, I tried to echo it into a logfile, but it showed nothing. I will try and upvote and accept if it works, thx :)
    – Black
    Commented Jul 2, 2021 at 7:27
  • 1
    that is driven by layout xml files, if you do a search for 'sales.email.order.renderers', you will find multiple sales_email_order_renderers.xml files defining the renderer for different product types, you can also create your own renderer. There is no renderer for configurable defined, so it uses default renderer
    – Ryan Sun
    Commented Jul 2, 2021 at 11:34
  • Nice, now I understand, thank you so much mate!
    – Black
    Commented Jul 2, 2021 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.