To create or edit a product category, proceed to your WordPress Dashboard → Products → Product Categories:
Here you can create a new category on your site. Enter the name of the category and click the Add a new category button:
To create a subcategory, add its name, select the corresponding Parent category from the dropdown menu, and click the Add a new category button:
Then you need to place categories on your site in Appearance → Menus by adding them from the panel on the left side of the screen.
Go to Appearance → Menus, select a menu to make changes to (or create a new one) and click Select:
In Add menu items → Product Categories, click View All. Check items which should be added to you menu in the left-hand sidebar and click Add to Menu:
Drag items to change their display order and move them to the right to make sub items. You can edit them by clicking the down arrow symbol. Click Save Menu to save changes.