购物车价格根据数量价格折扣

时间:2017-02-10 12:21:08

标签: php

如何在自定义电子商务中的数量交叉15后应用基本价格的5%折扣。

代码:

$price = $_POST['price'];
$quantity = $_POST['quantity'];
$discount = $_POST['discount'];
$tax = $_POST['tax'];
$shipping = $_POST['shipping'];
$payments = $_POST['payments'];

$total = (($price * $quantity) + $shipping) - $discount;

1 个答案:

答案 0 :(得分:-2)

    $price = mysqli_real_escape_string($conn , $_POST['price']);  
    $quantity =mysqli_real_escape_string($conn , $_POST['quantity']);

    if ($quantity > 15)
    {
      $discount = ($price/100)*5;
      $price = $price - $discount;
    }

    else 
    {
      $price = $price;
    }