Let $n_a,n_o$, and $n_p$ be the numbers of apples, oranges, and pears, respectively, in a selection of four pieces of fruit. We’re told to consider all pieces of one kind of fruit equivalent, and we’re told that only the number of pieces of each kind matters, not the order in which they are chosen. Thus, the three numbers $n_a,n_o$, and $n_p$ completely describe a selection of fruit. The question then amounts to asking how many solutions there are to the equation $n_a+n_o+n_p=4$ if the numbers $n_a,n_o$, and $n_p$ must be non-negative integers. (We’re told that at least $4$ pieces of each type of fruit are available, so every solution corresponds to a possible selection of fruit.)
This is a classic stars-and-bars problem; the answer, which is explained reasonably well in the Wikipedia article to which I linked, is that there are
$$\binom{4+3-1}{3-1}=\binom62=15$$
solutions in non-negative integers and hence $15$ possible selections of fruit.
Quite a few combinatorial problems can be reduced to this form or to something similar; it’s well worth learning to spot them. Here is an answer to another problem of this type that goes into more detail; in this answer I listed several of the guises in which this kind of problem can appear.
If repetition were not allowed, we couldn’t select more than three pieces of fruit, one of each kind. If the order of selections mattered, we’d have to argue very differently: the first piece could be any one of $3$ types, as could the second, third, and fourth, so there would be $3^4=81$ different ordered selections.
You are on the right track except that the all fruits of the same kind are identical. $3^{12}$ would be right if all fruits were different.
So you should instead be using stars and bars. You are looking for solution to
$x_1 + x_2 + x_3 = 12$
where $x_1, x_2, x_3$ are number of apples, oranges and grapefruits.
That is given by, $\displaystyle {12 + 3 - 1 \choose 3 - 1} = {14 \choose 2}$
Now subtract all unfavorable cases from it as you mentioned.
Best Answer
As stated in the comment, this is a stars and bars problem. The supply of the grocery store is of no concern as long as they have more than your maximum amount for each fruit (10 of each fruit in this case)
Now let o denote a fruit and | denote a bracket. You'll have 10 o as you are going to pick 10 fruits. You'll need only 3 | tho, because 3 separation points are enough to divide into 4 groups.
Now that you have 10 fruits and 3 seperation points, each of the combinations will represent you how much to buy which fruit. for instance;
000|00|00|000 denotes you'll buy 3 of the first fruit 2 of the second 2 of the third and 3 of the 4th. 0000000||000| denotes that you'll get 7 of the first fruit , 3 of the thrid and none of the others.
As you can see we can arrange it in $\frac {13!} {10!.3!}$ = $13 \choose 3$ ways.
For the second part of the question, we need to pre-allocate 1 fruit each to all brackets, so you will have 4 of the 10 fruits already allocated, for the remaining 6 we can use the same method and find that we can choose in $6+3 \choose 3$ = $9 \choose 3 $ ways