If you want to show tab in simple product create catalog_product_view_type_simple.xml
file add your code in it.
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.details">
<block class="Test\CustomCart\Block\CustomTab" name="mycustom.tab" as="mycustom" template="Test_CustomCart::kit.phtml" group="detailed_info">
<arguments>
<argument name="title" translate="true" xsi:type="string">Custom Tab</argument>
<argument name="sortOrder" xsi:type="string">0</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
If you want to display tab in bundle product add code in catalog_product_view_type_bundle.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.details">
<block class="Test\CustomCart\Block\CustomTab" name="mycustom.tab" as="mycustom" template="Test_CustomCart::kit.phtml" group="detailed_info">
<arguments>
<argument name="title" translate="true" xsi:type="string">Custom Tab</argument>
<argument name="sortOrder" xsi:type="string">0</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
Creating additional tab is quite easy as one two three. Its been well described by "Claudiu Creanga" in another relevant question answer here: https://magento.stackexchange.com/a/123693
A quick overview considering the Mayur answer and a quick one I used in my scenario follows this way.
In your catalog_product_view.xml
usually available in app/design/frontend/{vendor}/{theme}/Magento_Catalog/layout/catalog_product_view.xml
use this
<referenceBlock name="product.info.details">
<block class="Magento\Catalog\Block\Product\ProductList\Related" name="product.info.related" template="Magento_Catalog::product/list/items.phtml" group="detailed_info">
<arguments>
<argument name="type" xsi:type="string">related</argument>
<argument translate="true" name="title" xsi:type="string">Related Products</argument>
<argument name="sort_order" xsi:type="string">40</argument>
</arguments>
</block>
</referenceBlock>
Take a note on sort_order
, this will help you move its position in tabs, in my case I used 40 to make it appear next to Review. 30 is set for Review block as its seen here: https://github.com/magento/magento2/blob/2.3.3/app/code/Magento/Review/view/frontend/layout/catalog_product_view.xml#L23
You can adjust this position as per your need.
NOTE: You may wish to remove existing Related product block from the theme, to do this add this line to your catalog_product_view.xml
<referenceBlock name="catalog.product.related" remove="true"/>
IMPORTANT: Don't forget to change the template path, or adjustments to your related product template to match with your theme design.
Best Answer
So your new catalog_product_view.xml within theme should look like below (if there are no other modifications):
Changing the Tab Title
Change title of tab within title argument of the added upsell block e.g.