Javascript 迷你购物车js-购买多个商品时应用折扣
我已经在我的网站上实现了微型购物车js,我可以在购物车上添加物品,它可以正常工作。我想做的是,当一个用户以一个特定的价格(比如11.99)添加两个项目时,它会将其折扣到20 我知道minicart js有一个折扣功能,但文档不太清楚。我只想知道实现这一目标的最佳途径是什么 以下是我正在使用的代码:Javascript 迷你购物车js-购买多个商品时应用折扣,javascript,php,html,cart,Javascript,Php,Html,Cart,我已经在我的网站上实现了微型购物车js,我可以在购物车上添加物品,它可以正常工作。我想做的是,当一个用户以一个特定的价格(比如11.99)添加两个项目时,它会将其折扣到20 我知道minicart js有一个折扣功能,但文档不太清楚。我只想知道实现这一目标的最佳途径是什么 以下是我正在使用的代码: <?php // Connect to the MySQL database include "store_scripts/connect_to_mysql.php";
<?php
// Connect to the MySQL database
include "store_scripts/connect_to_mysql.php";
$dynamicList = '';
$sql = mysqli_query($dbc, "SELECT * FROM products where category = 'Rings'");
$productCount = mysqli_num_rows($sql);
if($productCount > 0)
{
while($row = mysqli_fetch_array($sql))
{
$id = $row['id'];
$product_name = $row['product_name'];
$price = $row['price'];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
$dynamicList .= '
<div id="floatedImage">
<a href="product.php?id=' . $id . '"><img src="images/' . $product_name . '.jpg" alt="' . $product_name . '" /></a>
<p>' . $product_name . '</p>
<p>€' . $price . '</p>
<p><a href="product.php?id=' . $id . '">View Product Details</a><p>
<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart"/>
<input type="hidden" name="business" value="test@test.com"/>
<input type="hidden" name="item_name" value="' . $product_name . '"/>
<input type="hidden" name="amount" value="' . $price . '"/>
<input type="hidden" name="currency_code" value="EUR"/>
<input type="hidden" name="add" value="1"/>
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_cart_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online!"/>
<img alt="" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"/>
</form>
</div>';
}
}
else
{
$dynamicList = "We have no products listed in our store yet";
}
mysqli_close($dbc);
?>
<!DOCTYPE html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link href="css/styles.css" rel="stylesheet" type="text/css" media="screen"/>
<title>Rings</title>
</head>
<body>
<div id="wrapper">
<div id="top">
<?php include('templates/top_template.php'); ?>
</div>
<div id="topnav">
<?php include('templates/topnav_template.php'); ?>
</div>
<div id="banner">
</div>
<div id="content">
<p><?php echo $dynamicList ?></p>
</div>
<div id="rightSide">
<?php include('templates/rightSide_template.php'); ?>
</div>
<div id="footer">
<?php include('templates/footer_template.php'); ?>
</div>
<div id="copyrightFooter">
<?php include('templates/copyrightFooter_template.php'); ?>
</div>
<script src="minicart.js"></script>
<script>
paypal.minicart.render();
</script>
</div>
</body>
</html>