I think the problem is this line in the instructions:
$price = ($price * $shop_markup) + $price;
change it to
$price = ($price * $shop_markup);
the first way, you apply the discount, and then add the regular price on top of it, which explains the prices you were seeing.
$13.49 + $7.25 = $20.74
$13.49 + $13.49 = $26.98
Hope this helps.