Proof of concept for shipping costs
<?php
// array with product names
$products = array('iphone 6', 'samsung galaxy s3', 'nokia lumnia');
// count products in array
$quantity = count($products);
// minimum number of products to append additional shipping cost
$min = 2;
// cost for first product
$basecost = 10;
// cost for each additional product
$addedcost = 3;
// calculation if there is more then 1 product in the shopping bag
if($min > 1) {
$count = $quantity - 1;
$total = $basecost + ($count * $addedcost);
}
// calculation if there is only 1 product in the shopping bag
else {
$count = $quantity;
$total = $basecost;
}
echo 'There are '.$quantity.' products in your shopping bag<br>';
echo 'Shipping cost is '.$total.' USD';
?>