How to track costs and calculate price?
The concept which you should be looking it is called prime costs. Businesses use prime cost as a way of measuring the total cost of the production inputs needed to create a given output. Usually this would be e.g. material, working hours, machine time and so on; since in your case there are only materials they are the only components you should consider when calculating the price.

So in your example the prime costs would be cost of purchased material + cost of donated material at market price. After this you would have to add a profit margin which you feel comfortable offering to your members.

As you mentioned their might be cases when the prime costs are higher then prices on the open market. In this case the only thing you can do is sell your material and buy the product directly on the market this is classical make or buy decision. If you still want to offer these product at a discount to the market price your only option is to take a loss on every sold item.