Adding a Tab on the Product Page
Another example of overriding a tab configuration
In this quick guide, you will learn about adding a tab to the product page. As you'll see, it will be very similar to the previous tutorial, as it uses the same pattern.
Inspecting the Codebase
First, we need to find the code responsible for rendering the product page tabs. You can use the React developer tools extension to find which components are being rendered. Searching the codebase can also be useful.
We find that the ProductPage route is itself responsible for configuring the tabs:
tabMap = {
[PRODUCT_INFORMATION]: {
name: __('About'),
shouldTabRender: () => {
const { isInformationTabEmpty } = this.props;
return isInformationTabEmpty;
},
render: (key) => this.renderProductInformationTab(key)
},
[PRODUCT_ATTRIBUTES]: {...},
[PRODUCT_REVIEWS]: {...}
};Now, we want to add our own tab to the mix!
Adding a New Tab
First, let's override the .component file of the ProductPage route. You can easily do this using the scandipwa CLI:
Make sure to select the ProductPage class in the .component file, because this is where we want to make modifications. You can also extend the styles if you intend to update them.
Now, jump into the .component file and update the tabMap by adding your own tab.
Result
If you check the product page in your app, you'll see that the tabs are now updated, and include our new tab:

Last updated
Was this helpful?