PHP develops simple shopping cart shopping cart page
cart.php This page displays the products, price, quantity, total price and other information in the shopping cart.
Continue to enable the session, take out various information in the product from the session and display it
The foreach loop output is used here.
You can return to the product display page to continue purchasing
PHP购物车页面
'; foreach ($goods as $value) { echo '商品名称:' . " " . $value['name'] . ' ' . ' 价格: ' . " " . $value['price'] . ' ' . ' 数量: ' . $value['number'] . '
'; } echo '总价:' . $_SESSION['totalPrice'] . '
'; ?> 返回商品列表
Such a simple shopping cart function is completed, friends can try it by themselves.
This tutorial is only suitable for friends to learn and reference, and cannot be used for actual projects.