They do make smaller shelves that fold up like this.
But these are easy to make.
The shelves are just slats, should be held together with a small strip of wood under it at the ends and middle to make stronger.
Ends are folding together with a hinge.
I would use thicker wood for the slats as those are like 1/2 inch thick and soap can get heavy. Anything can get heavy.
You can screw from the front and back on the frame. You don't have to do the fancy hiding screws on the sides... forgot what they call them.
I have been looking to do these too, just have no room to make them inside as it is Winter