$qv) { $pid = (int) $pid; $qv = max(0, (int) $qv); if ($qv <= 0) { unset($cart[$pid]); } else { $cart[$pid] = $qv; } } $_SESSION['cart'] = $cart; } redirect('cart.php'); } $items = []; if (!empty($cart)) { $ids = array_keys($cart); $ph = implode(',', array_fill(0, count($ids), '?')); $stmt = db()->prepare('SELECT * FROM ' . tn('products') . ' WHERE id IN (' . $ph . ') AND status = 1'); $stmt->execute($ids); foreach ($stmt->fetchAll() as $p) { $qty = (int) $cart[$p['id']]; if ($qty > $p['stock']) $qty = $p['stock']; // 超出库存则裁剪 $pointsSub = (!empty($p['points_price']) ? (int)$p['points_price'] * $qty : 0); $items[] = ['p' => $p, 'qty' => $qty, 'points_sub' => $pointsSub]; } } require 'includes/header.php'; ?>

' . __('cart_page.empty_link') . '', __('cart_page.empty')) ?>

0 ? (int)$it['points_sub'] . ' ' . __('common.points') : __('cart_page.subtotal_free') ?>