An easy point of sale system with automatic inventory tracking. https://netsyms.biz/apps/nickelbox/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cart.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /*
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. */
  7. if (!defined('NICKELBOX')) {
  8. die("Direct access denied.");
  9. }
  10. $cart = [];
  11. if (!empty($_SESSION['cart'])) {
  12. $cart = $_SESSION['cart'];
  13. }
  14. $total = 0.0;
  15. $tax = 0.0;
  16. $listhtml = "";
  17. if (count($cart) > 0) {
  18. foreach ($cart as $i => $qty) {
  19. $item = new Item($i);
  20. $listhtml .= RenderItem::cart($item, $qty);
  21. $total += ($item->getPrice() * $qty);
  22. }
  23. } else {
  24. $listhtml = "<p>The cart is empty.</p>";
  25. }
  26. $tax = $total * ($settings['tax'] / 100.0);
  27. ?>
  28. <div class="container mt-4">
  29. <h1 class="display-4">Cart</h1>
  30. <div class="list-group list-group-flush">
  31. <?php
  32. echo $listhtml;
  33. ?>
  34. </div>
  35. <div class="d-flex mt-3 justify-content-between">
  36. <div class="ml-auto text-right">
  37. <?php
  38. if ($tax > 0.0) {
  39. ?>
  40. <h5 class="mr-3">
  41. Subtotal: <?php
  42. echo "$" . number_format($total, 2);
  43. ?>
  44. </h5>
  45. <h5 class="mr-3">
  46. Tax: <?php
  47. echo "$" . number_format($tax, 2);
  48. ?>
  49. </h5>
  50. <?php
  51. }
  52. ?>
  53. <h4 class="mr-3">
  54. Total: <?php
  55. echo "$" . number_format($total + $tax, 2);
  56. ?>
  57. </h4>
  58. </div>
  59. </div>
  60. </div>