5ba2598910b42d68a926ab3b3e91eddcb5a87bc0.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. if (auth()->user() != null) {
  3. $user_id = Auth::user()->id;
  4. $cart = \App\Models\Cart::where('user_id', $user_id)->get();
  5. } else {
  6. $temp_user_id = Session()->get('temp_user_id');
  7. if ($temp_user_id) {
  8. $cart = \App\Models\Cart::where('temp_user_id', $temp_user_id)->get();
  9. }
  10. }
  11. ?>
  12. <a href="javascript:void(0)" class="d-flex align-items-center text-reset h-100" data-toggle="dropdown"
  13. data-display="static">
  14. <i class="la la-shopping-cart la-2x opacity-80"></i>
  15. <span class="flex-grow-1 ml-1">
  16. <?php if(isset($cart) && count($cart) > 0): ?>
  17. <span class="badge badge-primary badge-inline badge-pill cart-count">
  18. <?php echo e(count($cart)); ?>
  19. </span>
  20. <?php else: ?>
  21. <span class="badge badge-primary badge-inline badge-pill cart-count">0</span>
  22. <?php endif; ?>
  23. <span class="nav-box-text d-none d-xl-block opacity-70"><?php echo e(translate('Cart')); ?></span>
  24. </span>
  25. </a>
  26. <div class="dropdown-menu dropdown-menu-right dropdown-menu-lg p-0 stop-propagation">
  27. <?php if(isset($cart) && count($cart) > 0): ?>
  28. <div class="p-3 fs-15 fw-600 p-3 border-bottom">
  29. <?php echo e(translate('Cart Items')); ?>
  30. </div>
  31. <ul class="h-250px overflow-auto c-scrollbar-light list-group list-group-flush">
  32. <?php
  33. $total = 0;
  34. ?>
  35. <?php $__currentLoopData = $cart; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $cartItem): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
  36. <?php
  37. $product = \App\Models\Product::find($cartItem['product_id']);
  38. // $total = $total + ($cartItem['price'] + $cartItem['tax']) * $cartItem['quantity'];
  39. $total = $total + cart_product_price($cartItem, $product, false) * $cartItem['quantity'];
  40. ?>
  41. <?php if($product != null): ?>
  42. <li class="list-group-item">
  43. <span class="d-flex align-items-center">
  44. <a href="<?php echo e(route('product', $product->slug)); ?>"
  45. class="text-reset d-flex align-items-center flex-grow-1">
  46. <img src="<?php echo e(static_asset('assets/img/placeholder.jpg')); ?>"
  47. data-src="<?php echo e(uploaded_asset($product->thumbnail_img)); ?>"
  48. class="img-fit lazyload size-60px rounded"
  49. alt="<?php echo e($product->getTranslation('name')); ?>">
  50. <span class="minw-0 pl-2 flex-grow-1">
  51. <span class="fw-600 mb-1 text-truncate-2">
  52. <?php echo e($product->getTranslation('name')); ?>
  53. </span>
  54. <span class=""><?php echo e($cartItem['quantity']); ?>x</span>
  55. <span class=""><?php echo e(cart_product_price($cartItem, $product)); ?></span>
  56. </span>
  57. </a>
  58. <span class="">
  59. <button onclick="removeFromCart(<?php echo e($cartItem['id']); ?>)"
  60. class="btn btn-sm btn-icon stop-propagation">
  61. <i class="la la-close"></i>
  62. </button>
  63. </span>
  64. </span>
  65. </li>
  66. <?php endif; ?>
  67. <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
  68. </ul>
  69. <div class="px-3 py-2 fs-15 border-top d-flex justify-content-between">
  70. <span class="opacity-60"><?php echo e(translate('Subtotal')); ?></span>
  71. <span class="fw-600"><?php echo e(single_price($total)); ?></span>
  72. </div>
  73. <div class="px-3 py-2 text-center border-top">
  74. <ul class="list-inline mb-0">
  75. <li class="list-inline-item">
  76. <a href="<?php echo e(route('cart')); ?>" class="btn btn-soft-primary btn-sm">
  77. <?php echo e(translate('View cart')); ?>
  78. </a>
  79. </li>
  80. <?php if(Auth::check()): ?>
  81. <li class="list-inline-item">
  82. <a href="<?php echo e(route('checkout.shipping_info')); ?>" class="btn btn-primary btn-sm">
  83. <?php echo e(translate('Checkout')); ?>
  84. </a>
  85. </li>
  86. <?php endif; ?>
  87. </ul>
  88. </div>
  89. <?php else: ?>
  90. <div class="text-center p-3">
  91. <i class="las la-frown la-3x opacity-60 mb-3"></i>
  92. <h3 class="h6 fw-700"><?php echo e(translate('Your Cart is empty')); ?></h3>
  93. </div>
  94. <?php endif; ?>
  95. </div>
  96. <?php /**PATH /Users/shaoguo/Desktop/公司资料/小梦/商城/ebayShop/resources/views/frontend/partials/cart.blade.php ENDPATH**/ ?>