I have been trying to find out the total price based on the product quantity, I am saving quantity and price in database following is the query that i am using to find out the total price
SELECT SUM( price * quantity ) AS subtotal, SUM( quantity ) AS qty
FROM `cart`
WHERE user
IN (
SELECT id
FROM users
WHERE email = 'test'
)
Now what i want , i need add shipping charges, if the quantity is 1-5 than shipping charges would be 50 and if 6-10 than it would be 100 ad so on
How can i achieve this ? this is what i am trying but wrong! Please find me a solution.
$subtotalquery=" SELECT SUM( price * quantity ) as subtotal, SUM(quantity) as qty FROM `cart` WHERE user IN (select id from users where email='$user_check')";
$t_con=$conn->query($subtotalquery);
$subtotalrow = $t_con->fetch_assoc();
$subtotal= $subtotalrow['subtotal'];
$qty= $subtotalrow['qty'];
if($qty>=5)
{
$shipping=50 ;
$ithship=$subtotalrow+($shipping);
}else
{
$shipping=50*2 ;
$ithship=$subtotalrow+($shipping*2);
}